diff --git a/connector_ambugest/__manifest__.py b/connector_ambugest/__manifest__.py index 2f4211a4e..510f4f029 100644 --- a/connector_ambugest/__manifest__.py +++ b/connector_ambugest/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Ambugest-Odoo connector", - "version": "14.0.1.0.1", + "version": "14.0.1.0.2", "author": "NuoBiT Solutions, S.L., Eric Antones", "license": "AGPL-3", "category": "Connector", diff --git a/connector_ambugest/models/ambugest_backend/common.py b/connector_ambugest/models/ambugest_backend/common.py index ca50cac8e..480711322 100644 --- a/connector_ambugest/models/ambugest_backend/common.py +++ b/connector_ambugest/models/ambugest_backend/common.py @@ -142,14 +142,18 @@ def _scheduler_import_services(self): domain = [("company_id", "=", company_id.id)] self.search(domain).import_services_since() - def tz_to_utc(self, dt): - t = pytz.timezone(self.tz).localize(dt) - t = t.astimezone(pytz.utc) - t = t.replace(tzinfo=None) - return t - - def tz_to_local(self, dt): - local_tz = pytz.timezone(self.tz) - datetime_utc = pytz.utc.localize(dt) - datetime_local = datetime_utc.astimezone(local_tz) - return datetime_local + @staticmethod + def _convert_tz(dt_naive, from_tz, to_tz): + dt = pytz.timezone(from_tz).localize(dt_naive) + dt = dt.astimezone(pytz.timezone(to_tz)) + return dt.replace(tzinfo=None) + + def tz_to_utc(self, datetime_local_naive): + return self._convert_tz(datetime_local_naive, self.tz, "UTC") + + def utc_to_local(self, datetime_utc_naive): + return self._convert_tz(datetime_utc_naive, "UTC", self.tz) + + # Deprecated: use utc_to_local instead + def tz_to_local(self, datetime_utc_naive): + return self.utc_to_local(datetime_utc_naive) diff --git a/connector_ambugest/models/sale_order/exporter.py b/connector_ambugest/models/sale_order/exporter.py index 4cc9083ec..a59a997b0 100644 --- a/connector_ambugest/models/sale_order/exporter.py +++ b/connector_ambugest/models/sale_order/exporter.py @@ -23,7 +23,7 @@ def run_order_data(self, binding, clear=False): order_number, order_date = None, None if not clear: order_number = binding.name - order_date = binding.date_order + order_date = self.backend_record.utc_to_local(binding.date_order) values = { "Odoo_Numero_Albaran": order_number,