[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:
@@ -92,8 +92,13 @@ class SaleOrder(models.Model):
|
|||||||
}
|
}
|
||||||
if self.order_line:
|
if self.order_line:
|
||||||
values['sequence'] = self.order_line[-1].sequence + 1
|
values['sequence'] = self.order_line[-1].sequence + 1
|
||||||
so = SaleOrderLine.create(values)
|
sol = SaleOrderLine.create(values)
|
||||||
so.product_id_change_margin()
|
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):
|
class SaleOrderLine(models.Model):
|
||||||
|
|||||||
Reference in New Issue
Block a user