diff --git a/addons/delivery/sale.py b/addons/delivery/sale.py index 3512fb53b61c50e2b9fc63bdabfdfb0e7c2161b9..c6b89de649b161a281650bd9b30f5aeb7a2cc7e5 100644 --- a/addons/delivery/sale.py +++ b/addons/delivery/sale.py @@ -94,6 +94,11 @@ class sale_order(osv.Model): 'tax_id': [(6, 0, taxes_ids)], 'is_delivery': True, } + res = line_obj.product_id_change(cr, uid, ids, order.pricelist_id.id, values['product_id'], + qty=values['product_uom_qty'], uom=False, qty_uos=0, uos=False, name='', partner_id=order.partner_id.id, + lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False, context=None) + if res['value'].get('purchase_price'): + values['purchase_price'] = res['value'].get('purchase_price') if order.order_line: values['sequence'] = order.order_line[-1].sequence + 1 line_id = line_obj.create(cr, uid, values, context=context) diff --git a/addons/sale_margin/sale_margin.py b/addons/sale_margin/sale_margin.py index f1d2e7652ce6f94246c5420cbe9daf20cf24ca68..0cd3cdf14e4ccd68aeb107dd3fad70e38e688fc2 100644 --- a/addons/sale_margin/sale_margin.py +++ b/addons/sale_margin/sale_margin.py @@ -87,7 +87,7 @@ class sale_order(osv.osv): _columns = { 'margin': fields.function(_product_margin, string='Margin', help="It gives profitability by calculating the difference between the Unit Price and the cost price.", store={ - 'sale.order.line': (_get_order, ['margin', 'purchase_price'], 20), + 'sale.order.line': (_get_order, ['margin', 'purchase_price', 'order_id'], 20), 'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line'], 20), }, digits_compute= dp.get_precision('Product Price')), }