From f0a63e591380642a105b7325aa29cd82a2966cda Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Tue, 2 Feb 2016 14:31:30 +0100 Subject: [PATCH] [FIX] delivery: avoid calling unknown method. Only call `product_id_change_margin` method if exists. This method is defined in `sale_margin` module, but as there is no dependency between modules (nor a bridge module), the call have to be done here. --- addons/delivery/models/sale_order.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/addons/delivery/models/sale_order.py b/addons/delivery/models/sale_order.py index 50cebb1da75..233723ce712 100644 --- a/addons/delivery/models/sale_order.py +++ b/addons/delivery/models/sale_order.py @@ -92,8 +92,13 @@ class SaleOrder(models.Model): } if self.order_line: values['sequence'] = self.order_line[-1].sequence + 1 - so = SaleOrderLine.create(values) - so.product_id_change_margin() + sol = SaleOrderLine.create(values) + if hasattr(sol, 'product_id_change_margin'): + # if `sale_margin` module is installed, force computation of field `purchase_price` + # As there is not dependency between modules (nor a bridge module), this is the only + # place we can get the value for this field + sol.product_id_change_margin() + return sol class SaleOrderLine(models.Model):