[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.
This commit is contained in:
Christophe Simonis
2016-02-02 14:31:30 +01:00
parent a7c664fb6c
commit f0a63e5913
+7 -2
View File
@@ -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):