summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2017-07-11 10:34:07 +0200
committerChristophe Simonis <chs@odoo.com>2017-07-11 10:34:07 +0200
commitd52f0a29b4c812df71f862d20ec7f0f604dac394 (patch)
tree21ae5d860c0705395aedf589025ebd15d2a30822
parent96fa86779b15ada2ae5556e967cc47a1862b0bfa (diff)
parent479facb783bc047c6a5e156430a1131fa8d2540f (diff)
[MERGE] forward port branch 9.0 up to 479facb783b
-rw-r--r--addons/point_of_sale/static/src/js/models.js1
-rw-r--r--addons/sale_margin/models/sale_order.py7
2 files changed, 7 insertions, 1 deletions
diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js
index 859ed9dd146..2ae187ea4ff 100644
--- a/addons/point_of_sale/static/src/js/models.js
+++ b/addons/point_of_sale/static/src/js/models.js
@@ -1101,6 +1101,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;
diff --git a/addons/sale_margin/models/sale_order.py b/addons/sale_margin/models/sale_order.py
index d546882e143..0a852647637 100644
--- a/addons/sale_margin/models/sale_order.py
+++ b/addons/sale_margin/models/sale_order.py
@@ -57,7 +57,12 @@ class SaleOrderLine(models.Model):
def _product_margin(self):
for line in self:
currency = line.order_id.pricelist_id.currency_id
- line.margin = currency.round(line.price_subtotal - ((line.purchase_price or line.product_id.standard_price) * line.product_uom_qty))
+ price = line.purchase_price
+ if not price:
+ from_cur = line.env.user.company_id.currency_id.with_context(date=line.order_id.date_order)
+ price = from_cur.compute(line.product_id.standard_price, currency, round=False)
+
+ line.margin = currency.round(line.price_subtotal - (price * line.product_uom_qty))
class SaleOrder(models.Model):