From e5f4766c63716d86e5428ae3a1887d04763d8898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phan=20Sainl=C3=A9ger?= Date: Tue, 1 Dec 2020 18:09:33 +0100 Subject: [PATCH] Addition of field write_date and method _get_write_date --- partner_gogocarto_export_api/models/res_partner.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/partner_gogocarto_export_api/models/res_partner.py b/partner_gogocarto_export_api/models/res_partner.py index d930da306..88b0c5bd3 100644 --- a/partner_gogocarto_export_api/models/res_partner.py +++ b/partner_gogocarto_export_api/models/res_partner.py @@ -1,5 +1,6 @@ from odoo import models, fields, api from ast import literal_eval +# import datetime import logging _logger = logging.getLogger(__name__) @@ -16,6 +17,9 @@ class ResPartner(models.Model): ,('partner_latitude', '!=', float()) ] + def _get_last_update(self): + return self.write_date.strftime("%d-%m-%Y, %H:%M:%S") + def _get_industry_label(self): if self.industry_id: return self.industry_id.name @@ -41,6 +45,8 @@ class ResPartner(models.Model): self._add_simple_node(element, "name") self._add_simple_node(element, "partner_longitude") self._add_simple_node(element, "partner_latitude") + # to detect the changes in the export compared to the previous one, so that Gogocarto does not import all the data at each synchronization. + self._add_computed_node(element, "last_update", self._get_last_update) return self.add_fields(element, self._get_export_fields())