diff options
| author | Pierre Masereel <pim@odoo.com> | 2019-08-26 13:11:23 +0000 |
|---|---|---|
| committer | Pierre Masereel <pim@odoo.com> | 2019-08-27 09:31:31 +0000 |
| commit | ab0a207a591e11c1c8c47cd7fdfd2037f73bec03 (patch) | |
| tree | 4c42147e9f5382e58ced3b56e9753a50e30a4ceb /addons/pos_discount/static/src/js/discount.js | |
| parent | d0840a5ba62ebb46c84b52d11ba9f9c0b9cc7e17 (diff) | |
[FIX] point_of_sale: force load discount product
When you set up a discount product on your pos config and also some
available categories, it is possible that the discount product is not
loaded in the point of sale, which lead to an error.
Now we are forcing the loading of the discount product to allow using it
even if it is not in the allowed categories, as we don't want to create
a discount product for each category if we want to use both features.
TASK-ID: 2057436
Diffstat (limited to 'addons/pos_discount/static/src/js/discount.js')
| -rw-r--r-- | addons/pos_discount/static/src/js/discount.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/addons/pos_discount/static/src/js/discount.js b/addons/pos_discount/static/src/js/discount.js index fc41e55bc05..991e738b3e1 100644 --- a/addons/pos_discount/static/src/js/discount.js +++ b/addons/pos_discount/static/src/js/discount.js @@ -3,9 +3,27 @@ odoo.define('pos_discount.pos_discount', function (require) { var core = require('web.core'); var screens = require('point_of_sale.screens'); +var models = require('point_of_sale.models'); var _t = core._t; +var existing_models = models.PosModel.prototype.models; +var product_index = _.findIndex(existing_models, function (model) { + return model.model === "product.product"; +}); +var product_model = existing_models[product_index]; + + +models.load_models([{ + model: product_model.model, + fields: product_model.fields, + order: product_model.order, + domain: function(self) {return [['id', '=', self.config.discount_product_id[0]]];}, + context: product_model.context, + loaded: product_model.loaded, +}]); + + var DiscountButton = screens.ActionButtonWidget.extend({ template: 'DiscountButton', button_click: function(){ |
