Skip to content

Commit

Permalink
Merge PR #1180 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by legalsylvain
  • Loading branch information
OCA-git-bot committed Aug 25, 2024
2 parents 2c37484 + aa2015f commit 9612856
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions pos_membership_extension/static/src/js/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ odoo.define("pos_membership_extension.models", function (require) {

var _t = core._t;

// eslint-disable-next-line no-shadow
const OverloadProduct = (Product) =>
// eslint-disable-next-line no-shadow
class OverloadProduct extends Product {
const OverloadProduct = (OriginalProduct) =>
class extends OriginalProduct {
/**
* Return if it's allowed to sell the product to the partner.
*
Expand All @@ -39,10 +37,8 @@ odoo.define("pos_membership_extension.models", function (require) {
};
Registries.Model.extend(Product, OverloadProduct);

// eslint-disable-next-line no-shadow
const OverloadOrder = (Order) =>
// eslint-disable-next-line no-shadow
class OverloadOrder extends Order {
const OverloadOrder = (OriginalOrder) =>
class extends OriginalOrder {
/**
* Overloaded function.
* Check if the product of the order lines are allowed by the
Expand All @@ -53,14 +49,15 @@ odoo.define("pos_membership_extension.models", function (require) {
* @returns {Boolean} In any case, return the result of the super function.
*/
set_partner(partner) {
var self = this;
var bad_product_list = [];
this.orderlines.forEach(function (orderline) {
var i = this.orderlines.length;
while (i--) {
var orderline = this.orderlines[i];
if (!orderline.product.get_membership_allowed(partner)) {
bad_product_list.push(orderline.product.display_name);
self.orderlines.remove(orderline);
this.orderlines.splice(i, 1);
}
});
}
if (bad_product_list.length !== 0) {
var bad_product_text = bad_product_list.join(", ");
Gui.showPopup("ErrorPopup", {
Expand All @@ -69,7 +66,6 @@ odoo.define("pos_membership_extension.models", function (require) {
`The following lines has been removed, as the product cannot be sold to this partner: ${bad_product_text}`
),
});
return;
}

return super.set_partner(...arguments);
Expand Down

0 comments on commit 9612856

Please sign in to comment.