From e3c94f3a763e0614e41957b227b35df421241ee5 Mon Sep 17 00:00:00 2001 From: Andreas Osim Date: Fri, 4 Dec 2020 10:05:20 +0100 Subject: [PATCH] reengineer tz_last_order (shift from dp_custom.sale to tz_last_order.sale --- ext/custom-addons/dp_custom/models/sale.py | 6 +++--- .../tz_last_order/models/__init__.py | 1 + ext/custom-addons/tz_last_order/models/sale.py | 17 +++++++++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 ext/custom-addons/tz_last_order/models/sale.py diff --git a/ext/custom-addons/dp_custom/models/sale.py b/ext/custom-addons/dp_custom/models/sale.py index 58e5ffc6..113532b7 100644 --- a/ext/custom-addons/dp_custom/models/sale.py +++ b/ext/custom-addons/dp_custom/models/sale.py @@ -553,9 +553,9 @@ class SaleOrder(models.Model): if vals.get('order_line',False): self._reset_sequence() - if self.partner_id: - self.partner_id.last_order_changed = datetime.now() - + # if self.partner_id: + # self.partner_id.last_order_changed = datetime.now() + # return res @api.multi diff --git a/ext/custom-addons/tz_last_order/models/__init__.py b/ext/custom-addons/tz_last_order/models/__init__.py index 5e860e1b..df084f95 100644 --- a/ext/custom-addons/tz_last_order/models/__init__.py +++ b/ext/custom-addons/tz_last_order/models/__init__.py @@ -6,3 +6,4 @@ ################################################################################### from . import res_partner +from . import sale diff --git a/ext/custom-addons/tz_last_order/models/sale.py b/ext/custom-addons/tz_last_order/models/sale.py new file mode 100644 index 00000000..1c5a6315 --- /dev/null +++ b/ext/custom-addons/tz_last_order/models/sale.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- + +from odoo import fields, models, api, _ +from datetime import datetime + +class SaleOrder(models.Model): + _inherit = "sale.order" + + @api.multi + def write(self, vals): + + res = super(SaleOrder, self).write(vals) + + if self.partner_id: + self.partner_id.last_order_changed = datetime.now() + + return res