From 7102fcfc4fd5f1c7d84f951c473a4b3f0193afa2 Mon Sep 17 00:00:00 2001 From: Invitu Date: Fri, 23 Jun 2017 22:04:15 -1000 Subject: [PATCH 1/2] [FIX] point_of_sale: also clone orderline price Otherwise during e.g. bill splitting of an orderline which had it's price overridden you end up with the original price again. Fixes #17810 Closes #17811 --- addons/point_of_sale/static/src/js/models.js | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index b0abc797f08..5d7d96b5178 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -1108,6 +1108,7 @@ exports.Orderline = Backbone.Model.extend({ orderline.quantity = this.quantity; orderline.quantityStr = this.quantityStr; orderline.discount = this.discount; + orderline.price = this.price; orderline.type = this.type; orderline.selected = false; return orderline; From 49407e46cbf3ad891b7bfb3f73df6bea5defeef7 Mon Sep 17 00:00:00 2001 From: Joren Van Onder Date: Tue, 4 Apr 2017 10:25:52 -0700 Subject: [PATCH 2/2] [FIX] sale_margin: convert standard_price to SO currency before using --- addons/sale_margin/sale_margin.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/addons/sale_margin/sale_margin.py b/addons/sale_margin/sale_margin.py index 0cd3cdf14e4..0cd56669df7 100644 --- a/addons/sale_margin/sale_margin.py +++ b/addons/sale_margin/sale_margin.py @@ -55,7 +55,16 @@ class sale_order_line(osv.osv): cur = line.order_id.pricelist_id.currency_id res[line.id] = 0 if line.product_id: - tmp_margin = line.price_subtotal - ((line.purchase_price or line.product_id.standard_price) * line.product_uos_qty) + price = line.purchase_price + + if not price: + from_cur = self.pool['res.users'].browse(cr, uid, uid, context=context).company_id.currency_id + cost = line.product_id.standard_price + ctx = context.copy() + ctx['date'] = line.order_id.date_order + price = self.pool['res.currency'].compute(cr, uid, from_cur.id, cur.id, cost, round=False, context=ctx) + + tmp_margin = line.price_subtotal - (price * line.product_uos_qty) res[line.id] = cur_obj.round(cr, uid, cur, tmp_margin) return res