From a69f781b2896e917607795dfc0504173847c00b6 Mon Sep 17 00:00:00 2001 From: houssine Date: Wed, 2 Aug 2017 14:07:15 +0200 Subject: [PATCH] [IMP] change the module to allow the right calculation of the weight based on the price. We think that this module work as it with configuration where the VAT is included in the price of the products. --- pos_price_to_weight/static/src/js/models.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pos_price_to_weight/static/src/js/models.js b/pos_price_to_weight/static/src/js/models.js index 5c0777b..a33bb04 100644 --- a/pos_price_to_weight/static/src/js/models.js +++ b/pos_price_to_weight/static/src/js/models.js @@ -13,7 +13,18 @@ odoo.define('pos_price_to_weight.models', function (require) { var _super_PosModel = models.PosModel.prototype; models.PosModel = models.PosModel.extend({ + + initialize: function (session, attributes) { + var product_model = _.find(this.models, function(model){ + return model.model === 'product.product'; + }); + product_model.fields.push('total_with_vat'); + + // Inheritance + return _super_PosModel.initialize.call(this, session, attributes); + }, + scan_product: function(parsed_code) { if (! (parsed_code.type === 'price_to_weight')){ // Normal behaviour @@ -28,7 +39,9 @@ odoo.define('pos_price_to_weight.models', function (require) { var quantity = 0; var price = parseFloat(parsed_code.value) || 0; if (price !== 0 && product.price !== 0){ - quantity = price / product.price; + // replace the initial line cause this only work for price with + // vat include in the price in the pos. + quantity = price / product.total_with_vat; } selectedOrder.add_product(product, {quantity: quantity, merge: false}); return true;