diff --git a/discount_limit/README.rst b/discount_limit/README.rst new file mode 100644 index 000000000..b3f95cbd6 --- /dev/null +++ b/discount_limit/README.rst @@ -0,0 +1,51 @@ +.. image:: https://img.shields.io/badge/license-AGPL--3-blue.svg + :target: https://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +POS Discount Limit & Restrict Global Discount +============================================= +This module adds an option to Limit the Discount for POS Product Categories and Restrict the Global Discount for POS Cashiers. + +Configuration +============= +* No additional configurations needed + +Company +------- +* `Cybrosys Techno Solutions `__ + +License +======= +General Public License, version 3 (AGPL v3). +("https://www.odoo.com/documentation/18.0/legal/licenses.html") + + +Credits +------- +Developer : (V16) Bhagyadev KP + (V17) Farhana Jahan PT, Contact: odoo@cybrosys.com + (V18) Sruthi Renjith, Contact: odoo@cybrosys.com + + +Contacts +-------- +* Mail Contact : odoo@cybrosys.com +* Website : https://cybrosys.com + +Bug Tracker +----------- +Bugs are tracked on GitHub Issues. In case of trouble, please check there if your +issue has already been reported. + +Maintainer +========== +.. image:: https://cybrosys.com/images/logo.png + :target: https://cybrosys.com + +This module is maintained by Cybrosys Technologies. + +For support and more information, please visit `Our Website `__ + +Further information +=================== +HTML Description: ``__ diff --git a/discount_limit/__init__.py b/discount_limit/__init__.py new file mode 100644 index 000000000..531636dc3 --- /dev/null +++ b/discount_limit/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2025-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################### +from . import models diff --git a/discount_limit/__manifest__.py b/discount_limit/__manifest__.py new file mode 100644 index 000000000..e75e5634c --- /dev/null +++ b/discount_limit/__manifest__.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2025-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################### +{ + 'name': "POS Discount Limit & Restrict Global Discount", + 'version': '18.0.1.0.0', + 'category': 'Point of Sale', + 'summary': "This module is used to limit the discount " + "on pos product category.", + 'description': "This module is used to limit the discount on " + "pos product category and also restrict " + "the global discount for selected cashiers.", + 'author': "Cybrosys Techno Solutions", + 'company': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'website': "https://www.cybrosys.com", + 'depends': ['point_of_sale', 'hr','web', 'pos_hr', 'pos_discount', + 'account_invoice_extract'], + 'data': [ + 'views/res_config_settings_views.xml', + 'views/product_template_views.xml', + 'views/pos_category_views.xml', + 'views/hr_employee_views.xml', + ], + 'assets': { + 'point_of_sale._assets_pos': [ + 'discount_limit/static/src/js/Orderline.js', + 'discount_limit/static/src/js/DiscountButton.js', + 'discount_limit/static/src/js/pos_store.js' + ], + }, + 'images': ['static/description/banner.jpg'], + 'license': 'AGPL-3', + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/discount_limit/doc/RELEASE_NOTES.md b/discount_limit/doc/RELEASE_NOTES.md new file mode 100644 index 000000000..1ddb2b62a --- /dev/null +++ b/discount_limit/doc/RELEASE_NOTES.md @@ -0,0 +1,5 @@ +## Module +#### 11.08.2025 +#### Version 18.0.1.0.0 +##### ADD +- Initial Commit for POS Discount Limit & Restrict Global Discount diff --git a/discount_limit/models/__init__.py b/discount_limit/models/__init__.py new file mode 100644 index 000000000..3be28d49b --- /dev/null +++ b/discount_limit/models/__init__.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2025-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################### +from . import hr_employee +from . import pos_category +from . import pos_config +from . import pos_session +from . import product_product +from . import res_config_settings diff --git a/discount_limit/models/hr_employee.py b/discount_limit/models/hr_employee.py new file mode 100644 index 000000000..42406a133 --- /dev/null +++ b/discount_limit/models/hr_employee.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2025-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################### +from odoo import api, fields, models + + +class HrEmployee(models.Model): + """ + Inheriting the 'hr.employee' model to include a boolean field + indicating whether an employee has discount control permissions. + """ + _inherit = 'hr.employee' + + has_pos_discount_control = fields.Boolean(string="Discount Control", + help="Enable to control the" + " discount") + + @api.model + def _load_pos_data_fields(self, config_id): + data = super()._load_pos_data_fields(config_id) + data += ['has_pos_discount_control'] + return data diff --git a/discount_limit/models/pos_category.py b/discount_limit/models/pos_category.py new file mode 100644 index 000000000..cc5b5cdbc --- /dev/null +++ b/discount_limit/models/pos_category.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2025-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################### +from odoo import api, fields, models + + +class PosCategory(models.Model): + """ + Inheriting pos_category to include discount limit settings. + """ + _inherit = 'pos.category' + + discount_limit = fields.Char(string="Discount Limit(%)", + help="Discount Limit") + apply_limit = fields.Boolean(string="Apply Limit", help="Apply Limit") + + @api.model + def _load_pos_data_fields(self, config_id): + data = super()._load_pos_data_fields(config_id) + data += ['discount_limit'] + return data diff --git a/discount_limit/models/pos_config.py b/discount_limit/models/pos_config.py new file mode 100644 index 000000000..885a893f5 --- /dev/null +++ b/discount_limit/models/pos_config.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2025-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################### +from odoo import fields, models + + +class PosConfig(models.Model): + """ + Inheriting pos_config model to set discount limit for product/product + categories. + """ + _inherit = 'pos.config' + + apply_discount_limit = fields.Selection([ + ('product', 'Product'), + ('product_category', 'Product Category')], + string="Apply Discount Limit", + help="Select product or product category option to apply discount") diff --git a/discount_limit/models/pos_session.py b/discount_limit/models/pos_session.py new file mode 100644 index 000000000..d9fe7de81 --- /dev/null +++ b/discount_limit/models/pos_session.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2025-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################### +from odoo import api, models + + +class PosSession(models.Model): + """ + Inheriting pos_session module to load fields in pos session + """ + _inherit = 'pos.session' + + @api.model + def _load_pos_data_models(self, config_id): + """load the data to the pos.config.models""" + data = super()._load_pos_data_models(config_id) + data += ['hr.employee', 'product.product'] + return data + + def _loader_params_hr_employee(self): + """Load the field birthdate to pos.session""" + result = super()._loader_params_hr_employee() + result['search_params']['fields'].append('has_pos_discount_control') + return result diff --git a/discount_limit/models/product_product.py b/discount_limit/models/product_product.py new file mode 100644 index 000000000..c3ba02fda --- /dev/null +++ b/discount_limit/models/product_product.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2025-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################### +from odoo import api, models, fields + + +class ProductProduct(models.Model): + """Inheriting product_product model for adding Fields to + describe Discount Limit for POS""" + _inherit = 'product.product' + + pd_apply_limit = fields.Boolean(string="Apply limit", + help="Whether to apply") + product_discount_limit = fields.Float(string="Discount Limit(%)", + help="Product discount limit") + + @api.model + def _load_pos_data_fields(self, config_id): + data = super()._load_pos_data_fields(config_id) + data += ['product_discount_limit'] + return data diff --git a/discount_limit/models/res_config_settings.py b/discount_limit/models/res_config_settings.py new file mode 100644 index 000000000..a65a97724 --- /dev/null +++ b/discount_limit/models/res_config_settings.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2025-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################### +from odoo import api, fields, models + + +class ResConfigSettings(models.TransientModel): + """Inheriting res_config_settings model to set discount limit for + product/product categories""" + _inherit = 'res.config.settings' + + limit_discount = fields.Boolean(string="Discount Limit", + help="Enable to apply limit" + "on discount limit", + config_parameter='discount_limit.' + 'limit_discount') + apply_discount_limit = fields.Selection([ + ('product', 'Product'), + ('product_category', 'Product Category')], + string="Apply Discount Limit", + related="pos_config_id.apply_discount_limit", + readonly=False, help="Select product or product category option" + " to apply discount") + + @api.onchange('apply_discount_limit') + def _onchange_apply_discount_limit(self): + """ + setting the discount_limit for product or product categories field + based on the apply_discount_limit option. + """ + products = self.env['product.product'].search( + [('available_in_pos', '=', True)]) + categories = self.env['pos.category'].search([]) + if self.apply_discount_limit == 'product': + for product in products: + product.pd_apply_limit = True + for category in categories: + category.apply_limit = False + else: + for category in categories: + category.apply_limit = True + for product in products: + product.pd_apply_limit = False diff --git a/discount_limit/static/description/assets/icons/arrows-repeat.svg b/discount_limit/static/description/assets/icons/arrows-repeat.svg new file mode 100755 index 000000000..1d7efabc5 --- /dev/null +++ b/discount_limit/static/description/assets/icons/arrows-repeat.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/discount_limit/static/description/assets/icons/banner-1.png b/discount_limit/static/description/assets/icons/banner-1.png new file mode 100755 index 000000000..c180db172 Binary files /dev/null and b/discount_limit/static/description/assets/icons/banner-1.png differ diff --git a/discount_limit/static/description/assets/icons/banner-2.svg b/discount_limit/static/description/assets/icons/banner-2.svg new file mode 100755 index 000000000..e606d97d9 --- /dev/null +++ b/discount_limit/static/description/assets/icons/banner-2.svg @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/discount_limit/static/description/assets/icons/banner-bg.png b/discount_limit/static/description/assets/icons/banner-bg.png new file mode 100755 index 000000000..a8238d3c0 Binary files /dev/null and b/discount_limit/static/description/assets/icons/banner-bg.png differ diff --git a/discount_limit/static/description/assets/icons/banner-bg.svg b/discount_limit/static/description/assets/icons/banner-bg.svg new file mode 100755 index 000000000..b1378103e --- /dev/null +++ b/discount_limit/static/description/assets/icons/banner-bg.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/discount_limit/static/description/assets/icons/banner-call.svg b/discount_limit/static/description/assets/icons/banner-call.svg new file mode 100755 index 000000000..96c687e81 --- /dev/null +++ b/discount_limit/static/description/assets/icons/banner-call.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/discount_limit/static/description/assets/icons/banner-mail.svg b/discount_limit/static/description/assets/icons/banner-mail.svg new file mode 100755 index 000000000..cbf0d158d --- /dev/null +++ b/discount_limit/static/description/assets/icons/banner-mail.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/discount_limit/static/description/assets/icons/banner-pattern.svg b/discount_limit/static/description/assets/icons/banner-pattern.svg new file mode 100755 index 000000000..9c1c7e101 --- /dev/null +++ b/discount_limit/static/description/assets/icons/banner-pattern.svg @@ -0,0 +1,343 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/discount_limit/static/description/assets/icons/banner-promo.svg b/discount_limit/static/description/assets/icons/banner-promo.svg new file mode 100755 index 000000000..d52791b11 --- /dev/null +++ b/discount_limit/static/description/assets/icons/banner-promo.svg @@ -0,0 +1,147 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/discount_limit/static/description/assets/icons/brand-pair.svg b/discount_limit/static/description/assets/icons/brand-pair.svg new file mode 100755 index 000000000..d8db7fc1e --- /dev/null +++ b/discount_limit/static/description/assets/icons/brand-pair.svg @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/discount_limit/static/description/assets/icons/check.png b/discount_limit/static/description/assets/icons/check.png new file mode 100755 index 000000000..c8e85f51d Binary files /dev/null and b/discount_limit/static/description/assets/icons/check.png differ diff --git a/discount_limit/static/description/assets/icons/chevron.png b/discount_limit/static/description/assets/icons/chevron.png new file mode 100755 index 000000000..2089293d6 Binary files /dev/null and b/discount_limit/static/description/assets/icons/chevron.png differ diff --git a/discount_limit/static/description/assets/icons/close-icon.svg b/discount_limit/static/description/assets/icons/close-icon.svg new file mode 100755 index 000000000..df8cce37a --- /dev/null +++ b/discount_limit/static/description/assets/icons/close-icon.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/discount_limit/static/description/assets/icons/cogs.png b/discount_limit/static/description/assets/icons/cogs.png new file mode 100755 index 000000000..95d0bad62 Binary files /dev/null and b/discount_limit/static/description/assets/icons/cogs.png differ diff --git a/discount_limit/static/description/assets/icons/collabarate-icon.svg b/discount_limit/static/description/assets/icons/collabarate-icon.svg new file mode 100755 index 000000000..dd4e10518 --- /dev/null +++ b/discount_limit/static/description/assets/icons/collabarate-icon.svg @@ -0,0 +1,3 @@ + + + diff --git a/discount_limit/static/description/assets/icons/consultation.png b/discount_limit/static/description/assets/icons/consultation.png new file mode 100755 index 000000000..8319d4baa Binary files /dev/null and b/discount_limit/static/description/assets/icons/consultation.png differ diff --git a/discount_limit/static/description/assets/icons/cybro-logo.png b/discount_limit/static/description/assets/icons/cybro-logo.png new file mode 100755 index 000000000..ff4b78220 Binary files /dev/null and b/discount_limit/static/description/assets/icons/cybro-logo.png differ diff --git a/discount_limit/static/description/assets/icons/down.svg b/discount_limit/static/description/assets/icons/down.svg new file mode 100755 index 000000000..f21c36271 --- /dev/null +++ b/discount_limit/static/description/assets/icons/down.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/discount_limit/static/description/assets/icons/ecom-black.png b/discount_limit/static/description/assets/icons/ecom-black.png new file mode 100755 index 000000000..a9385ff13 Binary files /dev/null and b/discount_limit/static/description/assets/icons/ecom-black.png differ diff --git a/discount_limit/static/description/assets/icons/education-black.png b/discount_limit/static/description/assets/icons/education-black.png new file mode 100755 index 000000000..3eb09b27b Binary files /dev/null and b/discount_limit/static/description/assets/icons/education-black.png differ diff --git a/discount_limit/static/description/assets/icons/faq.png b/discount_limit/static/description/assets/icons/faq.png new file mode 100755 index 000000000..4250b5b81 Binary files /dev/null and b/discount_limit/static/description/assets/icons/faq.png differ diff --git a/discount_limit/static/description/assets/icons/feature-icon.svg b/discount_limit/static/description/assets/icons/feature-icon.svg new file mode 100755 index 000000000..fa0ea6850 --- /dev/null +++ b/discount_limit/static/description/assets/icons/feature-icon.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/discount_limit/static/description/assets/icons/feature.png b/discount_limit/static/description/assets/icons/feature.png new file mode 100755 index 000000000..ac7a785c0 Binary files /dev/null and b/discount_limit/static/description/assets/icons/feature.png differ diff --git a/discount_limit/static/description/assets/icons/gear.svg b/discount_limit/static/description/assets/icons/gear.svg new file mode 100755 index 000000000..0cc66b6ea --- /dev/null +++ b/discount_limit/static/description/assets/icons/gear.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/discount_limit/static/description/assets/icons/hero.gif b/discount_limit/static/description/assets/icons/hero.gif new file mode 100755 index 000000000..380654dfe Binary files /dev/null and b/discount_limit/static/description/assets/icons/hero.gif differ diff --git a/discount_limit/static/description/assets/icons/hire-odoo.svg b/discount_limit/static/description/assets/icons/hire-odoo.svg new file mode 100755 index 000000000..e1ac089b0 --- /dev/null +++ b/discount_limit/static/description/assets/icons/hire-odoo.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/discount_limit/static/description/assets/icons/hotel-black.png b/discount_limit/static/description/assets/icons/hotel-black.png new file mode 100755 index 000000000..130f613be Binary files /dev/null and b/discount_limit/static/description/assets/icons/hotel-black.png differ diff --git a/discount_limit/static/description/assets/icons/license.png b/discount_limit/static/description/assets/icons/license.png new file mode 100755 index 000000000..a5869797e Binary files /dev/null and b/discount_limit/static/description/assets/icons/license.png differ diff --git a/discount_limit/static/description/assets/icons/life-ring-icon.svg b/discount_limit/static/description/assets/icons/life-ring-icon.svg new file mode 100755 index 000000000..3ae6e1d89 --- /dev/null +++ b/discount_limit/static/description/assets/icons/life-ring-icon.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/discount_limit/static/description/assets/icons/lifebuoy.png b/discount_limit/static/description/assets/icons/lifebuoy.png new file mode 100755 index 000000000..658d56ccc Binary files /dev/null and b/discount_limit/static/description/assets/icons/lifebuoy.png differ diff --git a/discount_limit/static/description/assets/icons/mail.svg b/discount_limit/static/description/assets/icons/mail.svg new file mode 100755 index 000000000..1eedde695 --- /dev/null +++ b/discount_limit/static/description/assets/icons/mail.svg @@ -0,0 +1,3 @@ + + + diff --git a/discount_limit/static/description/assets/icons/manufacturing-black.png b/discount_limit/static/description/assets/icons/manufacturing-black.png new file mode 100755 index 000000000..697eb0e9f Binary files /dev/null and b/discount_limit/static/description/assets/icons/manufacturing-black.png differ diff --git a/discount_limit/static/description/assets/icons/notes.png b/discount_limit/static/description/assets/icons/notes.png new file mode 100755 index 000000000..ee5e95404 Binary files /dev/null and b/discount_limit/static/description/assets/icons/notes.png differ diff --git a/discount_limit/static/description/assets/icons/notification icon.svg b/discount_limit/static/description/assets/icons/notification icon.svg new file mode 100755 index 000000000..053189973 --- /dev/null +++ b/discount_limit/static/description/assets/icons/notification icon.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/discount_limit/static/description/assets/icons/odoo-consultancy.svg b/discount_limit/static/description/assets/icons/odoo-consultancy.svg new file mode 100755 index 000000000..e05f65bde --- /dev/null +++ b/discount_limit/static/description/assets/icons/odoo-consultancy.svg @@ -0,0 +1,4 @@ + + + + diff --git a/discount_limit/static/description/assets/icons/odoo-licencing.svg b/discount_limit/static/description/assets/icons/odoo-licencing.svg new file mode 100755 index 000000000..2606c88b0 --- /dev/null +++ b/discount_limit/static/description/assets/icons/odoo-licencing.svg @@ -0,0 +1,3 @@ + + + diff --git a/discount_limit/static/description/assets/icons/odoo-logo.png b/discount_limit/static/description/assets/icons/odoo-logo.png new file mode 100755 index 000000000..0e4d0eb5a Binary files /dev/null and b/discount_limit/static/description/assets/icons/odoo-logo.png differ diff --git a/discount_limit/static/description/assets/icons/patter.svg b/discount_limit/static/description/assets/icons/patter.svg new file mode 100755 index 000000000..25c9c0a8f --- /dev/null +++ b/discount_limit/static/description/assets/icons/patter.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/discount_limit/static/description/assets/icons/pattern1.png b/discount_limit/static/description/assets/icons/pattern1.png new file mode 100755 index 000000000..09ab0fb2d Binary files /dev/null and b/discount_limit/static/description/assets/icons/pattern1.png differ diff --git a/discount_limit/static/description/assets/icons/pos-black.png b/discount_limit/static/description/assets/icons/pos-black.png new file mode 100755 index 000000000..97c0f90c1 Binary files /dev/null and b/discount_limit/static/description/assets/icons/pos-black.png differ diff --git a/discount_limit/static/description/assets/icons/puzzle-piece-icon.svg b/discount_limit/static/description/assets/icons/puzzle-piece-icon.svg new file mode 100755 index 000000000..3e9ad9373 --- /dev/null +++ b/discount_limit/static/description/assets/icons/puzzle-piece-icon.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/discount_limit/static/description/assets/icons/puzzle.png b/discount_limit/static/description/assets/icons/puzzle.png new file mode 100755 index 000000000..65cf854e7 Binary files /dev/null and b/discount_limit/static/description/assets/icons/puzzle.png differ diff --git a/discount_limit/static/description/assets/icons/replace-icon.svg b/discount_limit/static/description/assets/icons/replace-icon.svg new file mode 100755 index 000000000..d0e3a7af1 --- /dev/null +++ b/discount_limit/static/description/assets/icons/replace-icon.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/discount_limit/static/description/assets/icons/restaurant-black.png b/discount_limit/static/description/assets/icons/restaurant-black.png new file mode 100755 index 000000000..4a35eb939 Binary files /dev/null and b/discount_limit/static/description/assets/icons/restaurant-black.png differ diff --git a/discount_limit/static/description/assets/icons/screenshot-main.png b/discount_limit/static/description/assets/icons/screenshot-main.png new file mode 100755 index 000000000..575f8e676 Binary files /dev/null and b/discount_limit/static/description/assets/icons/screenshot-main.png differ diff --git a/discount_limit/static/description/assets/icons/screenshot.png b/discount_limit/static/description/assets/icons/screenshot.png new file mode 100755 index 000000000..cef272529 Binary files /dev/null and b/discount_limit/static/description/assets/icons/screenshot.png differ diff --git a/discount_limit/static/description/assets/icons/service-black.png b/discount_limit/static/description/assets/icons/service-black.png new file mode 100755 index 000000000..301ab51cb Binary files /dev/null and b/discount_limit/static/description/assets/icons/service-black.png differ diff --git a/discount_limit/static/description/assets/icons/skype-fill.svg b/discount_limit/static/description/assets/icons/skype-fill.svg new file mode 100755 index 000000000..c17423639 --- /dev/null +++ b/discount_limit/static/description/assets/icons/skype-fill.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/discount_limit/static/description/assets/icons/skype.png b/discount_limit/static/description/assets/icons/skype.png new file mode 100755 index 000000000..51b409fb3 Binary files /dev/null and b/discount_limit/static/description/assets/icons/skype.png differ diff --git a/discount_limit/static/description/assets/icons/skype.svg b/discount_limit/static/description/assets/icons/skype.svg new file mode 100755 index 000000000..df3dad39b --- /dev/null +++ b/discount_limit/static/description/assets/icons/skype.svg @@ -0,0 +1,3 @@ + + + diff --git a/discount_limit/static/description/assets/icons/star-1.svg b/discount_limit/static/description/assets/icons/star-1.svg new file mode 100755 index 000000000..7e55ab162 --- /dev/null +++ b/discount_limit/static/description/assets/icons/star-1.svg @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/discount_limit/static/description/assets/icons/star-2.svg b/discount_limit/static/description/assets/icons/star-2.svg new file mode 100755 index 000000000..5ae9f507a --- /dev/null +++ b/discount_limit/static/description/assets/icons/star-2.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/discount_limit/static/description/assets/icons/support.png b/discount_limit/static/description/assets/icons/support.png new file mode 100755 index 000000000..4f18b8b82 Binary files /dev/null and b/discount_limit/static/description/assets/icons/support.png differ diff --git a/discount_limit/static/description/assets/icons/test-1 - Copy.png b/discount_limit/static/description/assets/icons/test-1 - Copy.png new file mode 100755 index 000000000..f6a902663 Binary files /dev/null and b/discount_limit/static/description/assets/icons/test-1 - Copy.png differ diff --git a/discount_limit/static/description/assets/icons/test-1.png b/discount_limit/static/description/assets/icons/test-1.png new file mode 100755 index 000000000..0908add2b Binary files /dev/null and b/discount_limit/static/description/assets/icons/test-1.png differ diff --git a/discount_limit/static/description/assets/icons/test-2.png b/discount_limit/static/description/assets/icons/test-2.png new file mode 100755 index 000000000..4671fe91e Binary files /dev/null and b/discount_limit/static/description/assets/icons/test-2.png differ diff --git a/discount_limit/static/description/assets/icons/trading-black.png b/discount_limit/static/description/assets/icons/trading-black.png new file mode 100755 index 000000000..9398ba2f1 Binary files /dev/null and b/discount_limit/static/description/assets/icons/trading-black.png differ diff --git a/discount_limit/static/description/assets/icons/training.png b/discount_limit/static/description/assets/icons/training.png new file mode 100755 index 000000000..884ca024d Binary files /dev/null and b/discount_limit/static/description/assets/icons/training.png differ diff --git a/discount_limit/static/description/assets/icons/translate.svg b/discount_limit/static/description/assets/icons/translate.svg new file mode 100755 index 000000000..af9c8a1aa --- /dev/null +++ b/discount_limit/static/description/assets/icons/translate.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/discount_limit/static/description/assets/icons/update.png b/discount_limit/static/description/assets/icons/update.png new file mode 100755 index 000000000..ecbc5a01a Binary files /dev/null and b/discount_limit/static/description/assets/icons/update.png differ diff --git a/discount_limit/static/description/assets/icons/user.png b/discount_limit/static/description/assets/icons/user.png new file mode 100755 index 000000000..6ffb23d9f Binary files /dev/null and b/discount_limit/static/description/assets/icons/user.png differ diff --git a/discount_limit/static/description/assets/icons/video.png b/discount_limit/static/description/assets/icons/video.png new file mode 100755 index 000000000..576705b17 Binary files /dev/null and b/discount_limit/static/description/assets/icons/video.png differ diff --git a/discount_limit/static/description/assets/icons/whatsapp.png b/discount_limit/static/description/assets/icons/whatsapp.png new file mode 100755 index 000000000..d513a5356 Binary files /dev/null and b/discount_limit/static/description/assets/icons/whatsapp.png differ diff --git a/discount_limit/static/description/assets/icons/wrench-icon.svg b/discount_limit/static/description/assets/icons/wrench-icon.svg new file mode 100755 index 000000000..174b5a465 --- /dev/null +++ b/discount_limit/static/description/assets/icons/wrench-icon.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/discount_limit/static/description/assets/icons/wrench.png b/discount_limit/static/description/assets/icons/wrench.png new file mode 100755 index 000000000..6c04dea0f Binary files /dev/null and b/discount_limit/static/description/assets/icons/wrench.png differ diff --git a/discount_limit/static/description/assets/misc/Cybrosys R.png b/discount_limit/static/description/assets/misc/Cybrosys R.png new file mode 100644 index 000000000..da4058087 Binary files /dev/null and b/discount_limit/static/description/assets/misc/Cybrosys R.png differ diff --git a/discount_limit/static/description/assets/misc/email.svg b/discount_limit/static/description/assets/misc/email.svg new file mode 100644 index 000000000..15291cdc3 --- /dev/null +++ b/discount_limit/static/description/assets/misc/email.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/discount_limit/static/description/assets/misc/phone.svg b/discount_limit/static/description/assets/misc/phone.svg new file mode 100644 index 000000000..b7bd7f251 --- /dev/null +++ b/discount_limit/static/description/assets/misc/phone.svg @@ -0,0 +1,3 @@ + + + diff --git a/discount_limit/static/description/assets/misc/star (1) 2.svg b/discount_limit/static/description/assets/misc/star (1) 2.svg new file mode 100644 index 000000000..5ae9f507a --- /dev/null +++ b/discount_limit/static/description/assets/misc/star (1) 2.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/discount_limit/static/description/assets/misc/support (1) 1.svg b/discount_limit/static/description/assets/misc/support (1) 1.svg new file mode 100644 index 000000000..7d37a8f30 --- /dev/null +++ b/discount_limit/static/description/assets/misc/support (1) 1.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/discount_limit/static/description/assets/misc/support-email.svg b/discount_limit/static/description/assets/misc/support-email.svg new file mode 100644 index 000000000..eb70370d6 --- /dev/null +++ b/discount_limit/static/description/assets/misc/support-email.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/discount_limit/static/description/assets/misc/tick-mark.svg b/discount_limit/static/description/assets/misc/tick-mark.svg new file mode 100644 index 000000000..2dbb40187 --- /dev/null +++ b/discount_limit/static/description/assets/misc/tick-mark.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/discount_limit/static/description/assets/misc/whatsapp 1.svg b/discount_limit/static/description/assets/misc/whatsapp 1.svg new file mode 100644 index 000000000..0bfaf8fc6 --- /dev/null +++ b/discount_limit/static/description/assets/misc/whatsapp 1.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/discount_limit/static/description/assets/misc/whatsapp.svg b/discount_limit/static/description/assets/misc/whatsapp.svg new file mode 100644 index 000000000..b618aea1d --- /dev/null +++ b/discount_limit/static/description/assets/misc/whatsapp.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/discount_limit/static/description/assets/modules/1.jpg b/discount_limit/static/description/assets/modules/1.jpg new file mode 100644 index 000000000..3cb15fe01 Binary files /dev/null and b/discount_limit/static/description/assets/modules/1.jpg differ diff --git a/discount_limit/static/description/assets/modules/2.jpg b/discount_limit/static/description/assets/modules/2.jpg new file mode 100644 index 000000000..662cadcc3 Binary files /dev/null and b/discount_limit/static/description/assets/modules/2.jpg differ diff --git a/discount_limit/static/description/assets/modules/3.jpg b/discount_limit/static/description/assets/modules/3.jpg new file mode 100644 index 000000000..717a00443 Binary files /dev/null and b/discount_limit/static/description/assets/modules/3.jpg differ diff --git a/discount_limit/static/description/assets/modules/4.png b/discount_limit/static/description/assets/modules/4.png new file mode 100644 index 000000000..00ebf54ad Binary files /dev/null and b/discount_limit/static/description/assets/modules/4.png differ diff --git a/discount_limit/static/description/assets/modules/5.jpg b/discount_limit/static/description/assets/modules/5.jpg new file mode 100644 index 000000000..7c67e2eec Binary files /dev/null and b/discount_limit/static/description/assets/modules/5.jpg differ diff --git a/discount_limit/static/description/assets/modules/6.gif b/discount_limit/static/description/assets/modules/6.gif new file mode 100644 index 000000000..a35ece8df Binary files /dev/null and b/discount_limit/static/description/assets/modules/6.gif differ diff --git a/discount_limit/static/description/assets/screenshots/1.png b/discount_limit/static/description/assets/screenshots/1.png new file mode 100644 index 000000000..490d8f2a4 Binary files /dev/null and b/discount_limit/static/description/assets/screenshots/1.png differ diff --git a/discount_limit/static/description/assets/screenshots/2.png b/discount_limit/static/description/assets/screenshots/2.png new file mode 100644 index 000000000..2daa210f8 Binary files /dev/null and b/discount_limit/static/description/assets/screenshots/2.png differ diff --git a/discount_limit/static/description/assets/screenshots/3.png b/discount_limit/static/description/assets/screenshots/3.png new file mode 100644 index 000000000..29af65d31 Binary files /dev/null and b/discount_limit/static/description/assets/screenshots/3.png differ diff --git a/discount_limit/static/description/assets/screenshots/4.png b/discount_limit/static/description/assets/screenshots/4.png new file mode 100644 index 000000000..cadaf61a9 Binary files /dev/null and b/discount_limit/static/description/assets/screenshots/4.png differ diff --git a/discount_limit/static/description/assets/screenshots/5.png b/discount_limit/static/description/assets/screenshots/5.png new file mode 100644 index 000000000..7b4120a22 Binary files /dev/null and b/discount_limit/static/description/assets/screenshots/5.png differ diff --git a/discount_limit/static/description/assets/screenshots/6.png b/discount_limit/static/description/assets/screenshots/6.png new file mode 100644 index 000000000..da6f20422 Binary files /dev/null and b/discount_limit/static/description/assets/screenshots/6.png differ diff --git a/discount_limit/static/description/assets/screenshots/7.png b/discount_limit/static/description/assets/screenshots/7.png new file mode 100644 index 000000000..d60467200 Binary files /dev/null and b/discount_limit/static/description/assets/screenshots/7.png differ diff --git a/discount_limit/static/description/assets/screenshots/8.png b/discount_limit/static/description/assets/screenshots/8.png new file mode 100644 index 000000000..dc6f69115 Binary files /dev/null and b/discount_limit/static/description/assets/screenshots/8.png differ diff --git a/discount_limit/static/description/assets/screenshots/hero.gif b/discount_limit/static/description/assets/screenshots/hero.gif new file mode 100644 index 000000000..8a88e0c3c Binary files /dev/null and b/discount_limit/static/description/assets/screenshots/hero.gif differ diff --git a/discount_limit/static/description/banner.jpg b/discount_limit/static/description/banner.jpg new file mode 100644 index 000000000..1483792db Binary files /dev/null and b/discount_limit/static/description/banner.jpg differ diff --git a/discount_limit/static/description/icon.png b/discount_limit/static/description/icon.png new file mode 100644 index 000000000..ff1e7ba74 Binary files /dev/null and b/discount_limit/static/description/icon.png differ diff --git a/discount_limit/static/description/index.html b/discount_limit/static/description/index.html new file mode 100644 index 000000000..e67e7c055 --- /dev/null +++ b/discount_limit/static/description/index.html @@ -0,0 +1,1126 @@ + + + + + + POS Discount Limit + + + + + + + + + + +
+
+ + + +
+
+ Community +
+
+ Enterprise +
+
+ Odoo.sh +
+
+
+ +
+
+
+
+

+ Limit the Discount on POS. +

+

POS Discount Limit & Restrict Global Discount +

+
+
+ +
+ +
+ +
+
+
+ +
+
+ +
+
+ + +
+
+
+

Key + Highlights

+
+
+
+
+ +
+
+ Limit the discount for Products +
+

+ When apply + discount limit for Product Can't give the + discount greater than the specified limit.

+
+
+
+
+
+ +
+
+ Limit the discount for product categories +
+

+ When apply + discount limit for product categories Can't give + the discount greater than the specified limit. +

+
+
+
+
+
+ +
+
+ Restrict global discount for selected POS + cashiers +
+

+ Cannot Apply + Global Discount if Cashier has no Discount + Control. +

+
+
+ +
+
+ +
+
+
+ POS Discount Limit & Restrict Global Discount +

+ Are you ready to make your business more + organized? +
Improve now! +

+ +
+
+ +
+
+
+ + + + +
+
+ +
+
+
+
+ acc_bg +
+ +
+
+
+
+

+ Configuration + + Menu +

+
+
+

+ Choose Product on Limit the Discount Field + in POS Configuration Settings. +

+
+
+
+ +
+
+
+
+
+
+
+
+
+

+ Product + + Configuration. +

+
+
+

+ Discount Limit Field in POS Product. +

+
+
+
+ +
+
+
+
+
+
+
+
+
+

+ Restriction + on Discount +

+
+
+

+ Can't give the discount greater than the + specified limit. +

+
+
+
+ +
+
+
+
+
+
+
+
+
+

+ Choose + + Product category +

+
+
+

+ Choose Product category on Limit the + Discount Field in POS Configuration + Settings. +

+
+
+
+ +
+
+
+
+
+
+
+
+
+

+ Discount + + + Limit +

+
+
+

+ Discount Limit Field in POS Product + category. +

+
+
+
+ +
+
+
+
+
+
+
+
+
+

+ Discount + + + Control +

+
+
+

+ Discount Control check box in HR settings. +

+
+
+
+ +
+
+
+

+ Add employees who have restrictions on + discounts. +

+
+
+
+ +
+
+
+

+ Enable Global Discount in POS settings. +

+
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+

+ Limit the discount for Products.

+
+ +
+
+
+
+
+
+ +
+

+ Limit the discount for product categories.

+
+
+
+
+
+
+
+ +
+

+ Restrict global discount for selected POS cashiers.

+
+ +
+
+ +
+
+
+
+
+
+
+ +
+ +
+ +
+

+ On the product form page, an additional field is added, storing the maximum allowed discount for that product. The value is saved directly in the product.product model. +

+
+
+ +
+ +
+

+ A similar field for discount limits is available on the product category form. +

+
+
+ +
+ +
+

+ Inside the employee form, there is a boolean field that determines whether the employee can apply discounts in POS. +

+
+
+ +
+ +
+

+ There will appear a popup informing the user that the discount exceeds the allowed limit or that they are not permitted to give discounts. +

+
+
+
+ +
+
+
+
+
+
+ +
+
+

+ Latest Release 18.0.1.0.0 +

+ + 26th September, 2024 + +
+
+
+
+
+ Add +
+
+
+
    +
  • + Initial Commit +
  • + +
+
+
+
+
+
+
+
+
+
+ + + +
+

+ Related Products +

+ +
+ + +
+

+ Our Services

+ +
+ +
+
+ .... +
+
+ +
+ + +
+
+ + + + + + diff --git a/discount_limit/static/src/js/DiscountButton.js b/discount_limit/static/src/js/DiscountButton.js new file mode 100644 index 000000000..3a7d3bc71 --- /dev/null +++ b/discount_limit/static/src/js/DiscountButton.js @@ -0,0 +1,33 @@ +/** @odoo-module */ + +import { _t } from "@web/core/l10n/translation"; +import { ControlButtons } from "@point_of_sale/app/screens/product_screen/control_buttons/control_buttons"; +import { patch } from "@web/core/utils/patch"; +import { NumberPopup } from "@point_of_sale/app/utils/input_popups/number_popup"; + +patch(ControlButtons.prototype, { + async clickDiscount() { + /**Add Popup error when Cashier is not allowed for apply Discount Limit**/ + var self=this; + if (this.pos.cashier.has_pos_discount_control===true){ + return this.notification.add(_t("You must be granted access to apply discount."), { + title: _t("Discount Restricted"), + type: "danger", + }); + } + else + { + this.dialog.add(NumberPopup, { + title: _t("Discount Percentage"), + startingValue: this.pos.config.discount_pc, + getPayload: (num) => { + const val = Math.max( + 0, + Math.min(100, this.env.utils.parseValidFloat(num.toString())) + ); + this.apply_discount(val); + }, + }); + } + }, +}); diff --git a/discount_limit/static/src/js/Orderline.js b/discount_limit/static/src/js/Orderline.js new file mode 100644 index 000000000..6acc4d4b1 --- /dev/null +++ b/discount_limit/static/src/js/Orderline.js @@ -0,0 +1,100 @@ +/** @odoo-module */ +import { PosOrderline } from "@point_of_sale/app/models/pos_order_line"; +import { patch } from "@web/core/utils/patch"; +import { parseFloat as oParseFloat } from "@web/views/fields/parsers"; +import { _t } from "@web/core/l10n/translation"; +import { useService } from "@web/core/utils/hooks"; +import { usePos } from "@point_of_sale/app/store/pos_hook"; + + +patch(PosOrderline.prototype, { + setup() { + super.setup(...arguments); + }, + set_discount(discount) { + /**Add Popup error when Discount Limit is applied for POS Orderline**/ + var order = this.order_id; + if (order) { + var pos_prod_id = order.get_selected_orderline().product_id.pos_categ_ids[0] + if (order.config.apply_discount_limit == false) { + var parsed_discount = + typeof discount === "number" ? + discount : + isNaN(parseFloat(discount)) ? + 0 : + oParseFloat("" + discount); + var disc = Math.min(Math.max(parsed_discount || 0, 0), 100); + this.discount = disc; + this.discountStr = "" + disc; + } else if (order.config.apply_discount_limit == 'product_category') { + var rounded = Math.round(discount); + if (Number.isInteger(pos_prod_id.id)) { + if (this.get_product().pos_categ_ids[0].discount_limit) { + if (rounded > this.get_product().pos_categ_ids[0].discount_limit) { + return { + title: _t("Discount Not Possible"), + body: _t( + "You cannot apply discount above the discount limit." + ), + }; + } else { + var parsed_discount = + typeof discount === "number" ? + discount : + isNaN(parseFloat(discount)) ? + 0 : + oParseFloat("" + discount); + var disc = Math.min(Math.max(parsed_discount || 0, 0), 100); + this.discount = disc; + this.discountStr = "" + disc; + } + } else { + var parsed_discount = + typeof discount === "number" ? + discount : + isNaN(parseFloat(discount)) ? + 0 : + oParseFloat("" + discount); + var disc = Math.min(Math.max(parsed_discount || 0, 0), 100); + this.discount = disc; + this.discountStr = "" + disc; + } + } + } else if (order.config.apply_discount_limit == 'product') { + var rounded = Math.round(discount); + if (Number.isInteger(pos_prod_id.id)) { + if (this.get_product().product_discount_limit) { + if (rounded > this.get_product().product_discount_limit) { + return { + title: _t("Discount Not Possible"), + body: _t( + "You cannot apply discount above the discount limit." + ), + }; + } else { + var parsed_discount = + typeof discount === "number" ? + discount : + isNaN(parseFloat(discount)) ? + 0 : + oParseFloat("" + discount); + var disc = Math.min(Math.max(parsed_discount || 0, 0), 100); + this.discount = disc; + this.discountStr = "" + disc; + } + } else { + var parsed_discount = + typeof discount === "number" ? + discount : + isNaN(parseFloat(discount)) ? + 0 : + oParseFloat("" + discount); + var disc = Math.min(Math.max(parsed_discount || 0, 0), 100); + this.discount = disc; + this.discountStr = "" + disc; + } + } + } + } + }, +}); diff --git a/discount_limit/static/src/js/pos_store.js b/discount_limit/static/src/js/pos_store.js new file mode 100644 index 000000000..15a9e11ed --- /dev/null +++ b/discount_limit/static/src/js/pos_store.js @@ -0,0 +1,18 @@ +/** @odoo-module */ +import { patch } from "@web/core/utils/patch"; +import { _t } from "@web/core/l10n/translation"; +import { PosStore } from "@point_of_sale/app/store/pos_store"; +import { AlertDialog } from "@web/core/confirmation_dialog/confirmation_dialog"; + + +patch(PosStore.prototype, { + async setDiscountFromUI(line, val) { + var a = line.set_discount(val) || ''; + if (a && a.title == "Discount Not Possible"){ + this.dialog.add(AlertDialog, { + title: _t("Discount Not Possible"), + body: _t("You cannot apply discount above the discount limit."), + }); + } + } +}) diff --git a/discount_limit/views/hr_employee_views.xml b/discount_limit/views/hr_employee_views.xml new file mode 100644 index 000000000..27d014844 --- /dev/null +++ b/discount_limit/views/hr_employee_views.xml @@ -0,0 +1,18 @@ + + + + + hr.employee.view.form.inherit.discount.limit + hr.employee + + + + + + + + + + diff --git a/discount_limit/views/pos_category_views.xml b/discount_limit/views/pos_category_views.xml new file mode 100644 index 000000000..7012eeec5 --- /dev/null +++ b/discount_limit/views/pos_category_views.xml @@ -0,0 +1,15 @@ + + + + + pos.category.view.form.inherit.discount.limit + pos.category + + + + + + + + + diff --git a/discount_limit/views/product_template_views.xml b/discount_limit/views/product_template_views.xml new file mode 100644 index 000000000..3039ec0fa --- /dev/null +++ b/discount_limit/views/product_template_views.xml @@ -0,0 +1,17 @@ + + + + + product.product.view.form.inherit.discount.limit + + product.product + + + + + + + + + diff --git a/discount_limit/views/res_config_settings_views.xml b/discount_limit/views/res_config_settings_views.xml new file mode 100644 index 000000000..d735b5cd0 --- /dev/null +++ b/discount_limit/views/res_config_settings_views.xml @@ -0,0 +1,32 @@ + + + + + + res.config.settings.view.form.inherit.discount.limit + + res.config.settings + + + +
+
+ +
+
+
+
+
+
+
+