From 03e9d62edb5abe1b0a3bbf983fe590ff71fad016 Mon Sep 17 00:00:00 2001 From: XuanHuyen Date: Sat, 22 Mar 2025 11:26:32 +0700 Subject: [PATCH] fix cron auto update weather --- weather_infor/data/weather_infor_cron.xml | 6 +++--- weather_infor/models/weather_information.py | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/weather_infor/data/weather_infor_cron.xml b/weather_infor/data/weather_infor_cron.xml index 629b2c3..6977748 100644 --- a/weather_infor/data/weather_infor_cron.xml +++ b/weather_infor/data/weather_infor_cron.xml @@ -1,6 +1,5 @@ - Fetch Weather Data @@ -8,7 +7,8 @@ minutes code - model.search([]).fetch_weather() + + model.search([]).fetch_weather() + - diff --git a/weather_infor/models/weather_information.py b/weather_infor/models/weather_information.py index 27bb02c..971dab3 100644 --- a/weather_infor/models/weather_information.py +++ b/weather_infor/models/weather_information.py @@ -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) \ No newline at end of file + for record in self: + weather_data = self.get_weather_information(record.city) + record.write(weather_data) \ No newline at end of file