fix cron auto update weather

This commit is contained in:
XuanHuyen
2025-03-22 11:26:32 +07:00
parent d08f3cb726
commit 03e9d62edb
2 changed files with 6 additions and 5 deletions
+3 -3
View File
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="cron_fetch_weather_data" model="ir.cron">
<field name="name">Fetch Weather Data</field>
<field name="model_id" ref="model_weather_information"/>
@@ -8,7 +7,8 @@
<field name="interval_type">minutes</field>
<!-- <field name="numbercall">-1</field> -->
<field name="state">code</field>
<field name="code">model.search([]).fetch_weather()</field>
<field name="code">
model.search([]).fetch_weather()
</field>
</record>
</odoo>
+3 -2
View File
@@ -34,5 +34,6 @@ class WeatherInformation(models.Model):
def fetch_weather(self):
"""Fetch weather data and update the record"""
weather_data = self.get_weather_information(self.city)
self.write(weather_data)
for record in self:
weather_data = self.get_weather_information(record.city)
record.write(weather_data)