diff --git a/pos_pricelist/static/src/js/models.js b/pos_pricelist/static/src/js/models.js index e532455d..1640eaf0 100644 --- a/pos_pricelist/static/src/js/models.js +++ b/pos_pricelist/static/src/js/models.js @@ -206,12 +206,13 @@ odoo.define("pos_pricelist.models", function (require) { models.Orderline.prototype.initialize = function (attr, options) { _Orderline_initialize.apply(this, arguments); if (options.product) { + var product = new exports.Product(this.product); this.set_unit_price( - options.product.price || - this.product.get_price( + product.get_price( this.order.pricelist, this.get_quantity() - ) + ) || + options.product.price ); } }; @@ -225,7 +226,8 @@ odoo.define("pos_pricelist.models", function (require) { delete this.keep_price; // just like in sale.order changing the quantity will recompute the unit price if (!keep_price) { - this.set_unit_price(this.product.get_price( + var product = new exports.Product(this.product); + this.set_unit_price(product.get_price( this.order.pricelist, this.get_quantity() )); @@ -260,8 +262,9 @@ odoo.define("pos_pricelist.models", function (require) { var self = this; this.pricelist = pricelist; _.each(this.get_orderlines(), function (line) { + var product = new exports.Product(line.product); line.set_unit_price( - line.product.get_price(self.pricelist, line.get_quantity()) + product.get_price(self.pricelist, line.get_quantity()) ); self.fix_tax_included_price(line); }); diff --git a/pos_pricelist/static/src/js/screens.js b/pos_pricelist/static/src/js/screens.js index c43342ba..14ecc531 100644 --- a/pos_pricelist/static/src/js/screens.js +++ b/pos_pricelist/static/src/js/screens.js @@ -8,6 +8,7 @@ odoo.define("pos_pricelist.screens", function (require) { var screens = require("point_of_sale.screens"); var _t = core._t; var exports = {}; + var models = require("pos_pricelist.models"); screens.ScaleScreenWidget.include({ _get_active_pricelist: function() { @@ -56,6 +57,7 @@ odoo.define("pos_pricelist.screens", function (require) { screens.ProductListWidget.include({ init: function () { + this.models = models; this._super.apply(this, arguments); this.pos.get('orders').bind( 'add remove change', @@ -84,6 +86,10 @@ odoo.define("pos_pricelist.screens", function (require) { } return current_pricelist; }, + get_price: function(product, pricelist, quantity) { + var product = new this.models.Product(product); + return product.get_price(pricelist, quantity); + }, }); screens.ClientListScreenWidget.include({ diff --git a/pos_pricelist/static/src/xml/pos.xml b/pos_pricelist/static/src/xml/pos.xml index 0b54cd95..07bf5fc0 100644 --- a/pos_pricelist/static/src/xml/pos.xml +++ b/pos_pricelist/static/src/xml/pos.xml @@ -41,11 +41,11 @@ - + - - + +