[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
This commit is contained in:
@@ -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(){
|
||||
|
||||
Reference in New Issue
Block a user