diff --git a/addons/sale_margin/sale_margin.py b/addons/sale_margin/sale_margin.py index 24f36b9f94b..c5ba7f1ea56 100644 --- a/addons/sale_margin/sale_margin.py +++ b/addons/sale_margin/sale_margin.py @@ -49,7 +49,8 @@ class sale_order_line(osv.osv): return res _columns = { - 'margin': fields.function(_product_margin, string='Margin', store=True), + 'margin': fields.function(_product_margin, string='Margin', + store = True), 'purchase_price': fields.float('Cost Price', digits=(16,2)) } @@ -66,8 +67,14 @@ class sale_order(osv.osv): result[sale.id] += line.margin or 0.0 return result + def _get_order(self, cr, uid, ids, context=None): + return super(self,sale_order)._get_order(cr, uid, ids, context=context) + _columns = { - 'margin': fields.function(_product_margin, string='Margin', store=True, help="It gives profitability by calculating the difference between the Unit Price and Cost Price."), + 'margin': fields.function(_product_margin, string='Margin', help="It gives profitability by calculating the difference between the Unit Price and Cost Price.", store={ + 'sale.order.line': (_get_order, ['margin'], 20), + 'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line'], 20), + }), } sale_order()