Skip to content

Commit

Permalink
[ADD] pos_bypass_global_discount
Browse files Browse the repository at this point in the history
  • Loading branch information
trisdoan committed Jul 6, 2024
1 parent ecabff7 commit bc72487
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions pos_bypass_global_discount/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
23 changes: 23 additions & 0 deletions pos_bypass_global_discount/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2024 Camptocamp (https://www.camptocamp.com).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "POS Bypass Global Discount",
"summary": "",
"version": "16.0.1.0.0",
"author": "Camptocamp, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/pos",
"license": "AGPL-3",
"category": "Point of Sale",
"depends": ["sale_global_discount", "pos_discount"],
"installable": True,
"assets": {
"point_of_sale.assets": [
"pos_bypass_global_discount/static/src/js/**/*.js",
],
# "web.assets_tests": [
# "pos_loyalty_exclude/static/src/tours/**/*",
# ],
},
"auto_install": True,
}
1 change: 1 addition & 0 deletions pos_bypass_global_discount/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import pos_session
12 changes: 12 additions & 0 deletions pos_bypass_global_discount/models/pos_session.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2024 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models


class POSSession(models.Model):
_inherit = "pos.session"

def _loader_params_product_product(self):
params = super()._loader_params_product_product()
params["search_params"]["fields"].append("bypass_global_discount")
return params
15 changes: 15 additions & 0 deletions pos_bypass_global_discount/static/src/js/models.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
odoo.define("pos_bypass_global_discount.models", function (require) {
"use strict";

const {Orderline} = require("point_of_sale.models");
const Registries = require("point_of_sale.Registries");

const PosBypassDiscountOrderline = (Orderline) =>
class PosBypassDiscountOrderline extends Orderline {
isGlobalDiscountApplicable() {
const res = super.isGlobalDiscountApplicable();
return !this.product.bypass_global_discount && res;
}
};
Registries.Model.extend(Orderline, PosBypassDiscountOrderline);
});
Empty file.

0 comments on commit bc72487

Please sign in to comment.