diff --git a/pos_discount_manager/README.rst b/pos_discount_manager/README.rst new file mode 100755 index 000000000..f052e7db6 --- /dev/null +++ b/pos_discount_manager/README.rst @@ -0,0 +1,37 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +POS Discount Manager Approval +============================= +This module helps to provide Discount limit for each employee in every pos + +Configuration +============= +* No additional configurations needed + +Company +------- +* `Cybrosys Techno Solutions `__ + +Credits +------- +* Developers: Cybrosys Techno Solutions odoo@cybrosys.com + Author : Sruthi Pavithran + +Contacts +-------- +* Mail Contact : odoo@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 `__ \ No newline at end of file diff --git a/pos_discount_manager/__init__.py b/pos_discount_manager/__init__.py new file mode 100755 index 000000000..5e685ca20 --- /dev/null +++ b/pos_discount_manager/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-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/pos_discount_manager/__manifest__.py b/pos_discount_manager/__manifest__.py new file mode 100755 index 000000000..8b4972a78 --- /dev/null +++ b/pos_discount_manager/__manifest__.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-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 Manager Approval", + 'version': '16.0.1.0.0', + 'summary': "Discount limit for each employee in every point of sale""", + 'description': """"This module helps you to set a discount limit for each + employee in every point of sale.It facilitate the manager + approval when discount over the limit of employee""", + 'category': 'Point of Sale', + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'maintainer': "Cybrosys Techno Solutions", + 'website': "http://www.cybrosys.com", + 'depends': ['point_of_sale', 'pos_discount', 'hr'], + 'data': [ + 'views/hr_employee_views.xml', + ], + 'assets': { + 'point_of_sale.assets': [ + 'pos_discount_manager/static/src/css/popup_size.css', + 'pos_discount_manager/static/src/js/PosSession.js', + 'pos_discount_manager/static/src/js/ValidateManager.js', + 'pos_discount_manager/static/src/xml/NumberPopup.xml' + ] + }, + 'images': ['static/description/banner.png'], + 'license': 'AGPL-3', + 'installable': True, + 'application': False, + 'auto_install': False, +} diff --git a/pos_discount_manager/doc/RELEASE_NOTES.md b/pos_discount_manager/doc/RELEASE_NOTES.md new file mode 100755 index 000000000..8d6051853 --- /dev/null +++ b/pos_discount_manager/doc/RELEASE_NOTES.md @@ -0,0 +1,6 @@ +## Module + +#### 12.05.2023 +#### Version 16.0.1.0.0 +#### ADD +Initial Commit for POS Discount Manager Approval \ No newline at end of file diff --git a/pos_discount_manager/models/__init__.py b/pos_discount_manager/models/__init__.py new file mode 100755 index 000000000..02ee3581e --- /dev/null +++ b/pos_discount_manager/models/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-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_session diff --git a/pos_discount_manager/models/hr_employee.py b/pos_discount_manager/models/hr_employee.py new file mode 100755 index 000000000..cc12a2576 --- /dev/null +++ b/pos_discount_manager/models/hr_employee.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-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 HrEmployee(models.Model): + """Add field into hr employee""" + _inherit = 'hr.employee' + + limited_discount = fields.Integer(string="Discount Limit", + help="Provide discount limit to each " + "employee") diff --git a/pos_discount_manager/models/pos_session.py b/pos_discount_manager/models/pos_session.py new file mode 100755 index 000000000..55c601961 --- /dev/null +++ b/pos_discount_manager/models/pos_session.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-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 models + + +class PosSession(models.Model): + """Inherited model POS Session for loading field in hr.employee into + pos session. + + Methods: + _pos_ui_models_to_load(self): + to load model hr employee to pos session. + + _loader_params_hr_employee(self): + loads field limited_discount to pos session. + + """ + _inherit = "pos.session" + + def _pos_ui_models_to_load(self): + """Load hr.employee model into pos session""" + result = super()._pos_ui_models_to_load() + result += ['hr.employee'] + return result + + def _loader_params_hr_employee(self): + """load hr.employee parameters""" + result = super()._loader_params_hr_employee() + result['search_params']['fields'].extend( + ['limited_discount']) + return result diff --git a/pos_discount_manager/static/description/assets/icons/check.png b/pos_discount_manager/static/description/assets/icons/check.png new file mode 100755 index 000000000..c8e85f51d Binary files /dev/null and b/pos_discount_manager/static/description/assets/icons/check.png differ diff --git a/pos_discount_manager/static/description/assets/icons/chevron.png b/pos_discount_manager/static/description/assets/icons/chevron.png new file mode 100755 index 000000000..2089293d6 Binary files /dev/null and b/pos_discount_manager/static/description/assets/icons/chevron.png differ diff --git a/pos_discount_manager/static/description/assets/icons/cogs.png b/pos_discount_manager/static/description/assets/icons/cogs.png new file mode 100755 index 000000000..95d0bad62 Binary files /dev/null and b/pos_discount_manager/static/description/assets/icons/cogs.png differ diff --git a/pos_discount_manager/static/description/assets/icons/consultation.png b/pos_discount_manager/static/description/assets/icons/consultation.png new file mode 100755 index 000000000..8319d4baa Binary files /dev/null and b/pos_discount_manager/static/description/assets/icons/consultation.png differ diff --git a/pos_discount_manager/static/description/assets/icons/ecom-black.png b/pos_discount_manager/static/description/assets/icons/ecom-black.png new file mode 100755 index 000000000..a9385ff13 Binary files /dev/null and b/pos_discount_manager/static/description/assets/icons/ecom-black.png differ diff --git a/pos_discount_manager/static/description/assets/icons/education-black.png b/pos_discount_manager/static/description/assets/icons/education-black.png new file mode 100755 index 000000000..3eb09b27b Binary files /dev/null and b/pos_discount_manager/static/description/assets/icons/education-black.png differ diff --git a/pos_discount_manager/static/description/assets/icons/hotel-black.png b/pos_discount_manager/static/description/assets/icons/hotel-black.png new file mode 100755 index 000000000..130f613be Binary files /dev/null and b/pos_discount_manager/static/description/assets/icons/hotel-black.png differ diff --git a/pos_discount_manager/static/description/assets/icons/license.png b/pos_discount_manager/static/description/assets/icons/license.png new file mode 100755 index 000000000..a5869797e Binary files /dev/null and b/pos_discount_manager/static/description/assets/icons/license.png differ diff --git a/pos_discount_manager/static/description/assets/icons/lifebuoy.png b/pos_discount_manager/static/description/assets/icons/lifebuoy.png new file mode 100755 index 000000000..658d56ccc Binary files /dev/null and b/pos_discount_manager/static/description/assets/icons/lifebuoy.png differ diff --git a/pos_discount_manager/static/description/assets/icons/logo.png b/pos_discount_manager/static/description/assets/icons/logo.png new file mode 100755 index 000000000..478462d3e Binary files /dev/null and b/pos_discount_manager/static/description/assets/icons/logo.png differ diff --git a/pos_discount_manager/static/description/assets/icons/manufacturing-black.png b/pos_discount_manager/static/description/assets/icons/manufacturing-black.png new file mode 100755 index 000000000..697eb0e9f Binary files /dev/null and b/pos_discount_manager/static/description/assets/icons/manufacturing-black.png differ diff --git a/pos_discount_manager/static/description/assets/icons/pos-black.png b/pos_discount_manager/static/description/assets/icons/pos-black.png new file mode 100755 index 000000000..97c0f90c1 Binary files /dev/null and b/pos_discount_manager/static/description/assets/icons/pos-black.png differ diff --git a/pos_discount_manager/static/description/assets/icons/puzzle.png b/pos_discount_manager/static/description/assets/icons/puzzle.png new file mode 100755 index 000000000..65cf854e7 Binary files /dev/null and b/pos_discount_manager/static/description/assets/icons/puzzle.png differ diff --git a/pos_discount_manager/static/description/assets/icons/restaurant-black.png b/pos_discount_manager/static/description/assets/icons/restaurant-black.png new file mode 100755 index 000000000..4a35eb939 Binary files /dev/null and b/pos_discount_manager/static/description/assets/icons/restaurant-black.png differ diff --git a/pos_discount_manager/static/description/assets/icons/service-black.png b/pos_discount_manager/static/description/assets/icons/service-black.png new file mode 100755 index 000000000..301ab51cb Binary files /dev/null and b/pos_discount_manager/static/description/assets/icons/service-black.png differ diff --git a/pos_discount_manager/static/description/assets/icons/trading-black.png b/pos_discount_manager/static/description/assets/icons/trading-black.png new file mode 100755 index 000000000..9398ba2f1 Binary files /dev/null and b/pos_discount_manager/static/description/assets/icons/trading-black.png differ diff --git a/pos_discount_manager/static/description/assets/icons/training.png b/pos_discount_manager/static/description/assets/icons/training.png new file mode 100755 index 000000000..884ca024d Binary files /dev/null and b/pos_discount_manager/static/description/assets/icons/training.png differ diff --git a/pos_discount_manager/static/description/assets/icons/update.png b/pos_discount_manager/static/description/assets/icons/update.png new file mode 100755 index 000000000..ecbc5a01a Binary files /dev/null and b/pos_discount_manager/static/description/assets/icons/update.png differ diff --git a/pos_discount_manager/static/description/assets/icons/user.png b/pos_discount_manager/static/description/assets/icons/user.png new file mode 100755 index 000000000..6ffb23d9f Binary files /dev/null and b/pos_discount_manager/static/description/assets/icons/user.png differ diff --git a/pos_discount_manager/static/description/assets/icons/wrench.png b/pos_discount_manager/static/description/assets/icons/wrench.png new file mode 100755 index 000000000..6c04dea0f Binary files /dev/null and b/pos_discount_manager/static/description/assets/icons/wrench.png differ diff --git a/pos_discount_manager/static/description/assets/modules/module01.png b/pos_discount_manager/static/description/assets/modules/module01.png new file mode 100755 index 000000000..a9936f593 Binary files /dev/null and b/pos_discount_manager/static/description/assets/modules/module01.png differ diff --git a/pos_discount_manager/static/description/assets/modules/module02.png b/pos_discount_manager/static/description/assets/modules/module02.png new file mode 100755 index 000000000..1a9e2cbd7 Binary files /dev/null and b/pos_discount_manager/static/description/assets/modules/module02.png differ diff --git a/pos_discount_manager/static/description/assets/modules/module03.png b/pos_discount_manager/static/description/assets/modules/module03.png new file mode 100755 index 000000000..d3d28e08b Binary files /dev/null and b/pos_discount_manager/static/description/assets/modules/module03.png differ diff --git a/pos_discount_manager/static/description/assets/modules/module04.png b/pos_discount_manager/static/description/assets/modules/module04.png new file mode 100755 index 000000000..5297b364a Binary files /dev/null and b/pos_discount_manager/static/description/assets/modules/module04.png differ diff --git a/pos_discount_manager/static/description/assets/modules/module05.png b/pos_discount_manager/static/description/assets/modules/module05.png new file mode 100755 index 000000000..2263f673e Binary files /dev/null and b/pos_discount_manager/static/description/assets/modules/module05.png differ diff --git a/pos_discount_manager/static/description/assets/modules/module06.png b/pos_discount_manager/static/description/assets/modules/module06.png new file mode 100755 index 000000000..0b8c68699 Binary files /dev/null and b/pos_discount_manager/static/description/assets/modules/module06.png differ diff --git a/pos_discount_manager/static/description/assets/screenshots/hero.gif b/pos_discount_manager/static/description/assets/screenshots/hero.gif new file mode 100644 index 000000000..5631fcbd5 Binary files /dev/null and b/pos_discount_manager/static/description/assets/screenshots/hero.gif differ diff --git a/pos_discount_manager/static/description/assets/screenshots/pos0000.png b/pos_discount_manager/static/description/assets/screenshots/pos0000.png new file mode 100644 index 000000000..d7aad2543 Binary files /dev/null and b/pos_discount_manager/static/description/assets/screenshots/pos0000.png differ diff --git a/pos_discount_manager/static/description/assets/screenshots/pos1111.png b/pos_discount_manager/static/description/assets/screenshots/pos1111.png new file mode 100644 index 000000000..52801dd6e Binary files /dev/null and b/pos_discount_manager/static/description/assets/screenshots/pos1111.png differ diff --git a/pos_discount_manager/static/description/assets/screenshots/pos2222.png b/pos_discount_manager/static/description/assets/screenshots/pos2222.png new file mode 100644 index 000000000..e8bdaaf3c Binary files /dev/null and b/pos_discount_manager/static/description/assets/screenshots/pos2222.png differ diff --git a/pos_discount_manager/static/description/assets/screenshots/pos3333.png b/pos_discount_manager/static/description/assets/screenshots/pos3333.png new file mode 100644 index 000000000..dc595cb95 Binary files /dev/null and b/pos_discount_manager/static/description/assets/screenshots/pos3333.png differ diff --git a/pos_discount_manager/static/description/assets/screenshots/pos4444.png b/pos_discount_manager/static/description/assets/screenshots/pos4444.png new file mode 100644 index 000000000..562578719 Binary files /dev/null and b/pos_discount_manager/static/description/assets/screenshots/pos4444.png differ diff --git a/pos_discount_manager/static/description/assets/screenshots/pos5555.png b/pos_discount_manager/static/description/assets/screenshots/pos5555.png new file mode 100644 index 000000000..593d2416e Binary files /dev/null and b/pos_discount_manager/static/description/assets/screenshots/pos5555.png differ diff --git a/pos_discount_manager/static/description/assets/screenshots/pos6666.png b/pos_discount_manager/static/description/assets/screenshots/pos6666.png new file mode 100644 index 000000000..d67bc7081 Binary files /dev/null and b/pos_discount_manager/static/description/assets/screenshots/pos6666.png differ diff --git a/pos_discount_manager/static/description/assets/screenshots/pos7777.png b/pos_discount_manager/static/description/assets/screenshots/pos7777.png new file mode 100644 index 000000000..1dc22adeb Binary files /dev/null and b/pos_discount_manager/static/description/assets/screenshots/pos7777.png differ diff --git a/pos_discount_manager/static/description/banner.png b/pos_discount_manager/static/description/banner.png new file mode 100755 index 000000000..db6fc1ced Binary files /dev/null and b/pos_discount_manager/static/description/banner.png differ diff --git a/pos_discount_manager/static/description/icon.png b/pos_discount_manager/static/description/icon.png new file mode 100755 index 000000000..7d4137658 Binary files /dev/null and b/pos_discount_manager/static/description/icon.png differ diff --git a/pos_discount_manager/static/description/index.html b/pos_discount_manager/static/description/index.html new file mode 100755 index 000000000..2ce9b3e18 --- /dev/null +++ b/pos_discount_manager/static/description/index.html @@ -0,0 +1,685 @@ +
+ + +
+
+
+ +
+
+
+ Community +
+
+ Enterprise +
+
+ +
+
+
+ + + +
+
+
+

+ POS Discount Manager Approval

+

+ POS Discount Manager Approval +

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

+ Overview +

+
+ +
+

+ This module helps you to set a discount limit for each employee in every point of sale. + It facilitates the manager approval when discount over the limit of employee +

+ +
+
+ + + +
+
+

+ Configuration +

+
+ +
+

+ No additional configuration required

+ +
+
+ + +
+
+

+ Features +

+
+ +
+
+ +
+
+

+ Community Support

+

+ Available in Odoo 16.0 Community

+
+
+
+
+ +
+
+

+ Enterprise Support

+

+ Available in Odoo 16.0 Enterprise

+
+
+ +
+
+ +
+
+

+ Discount Limit

+

+ Sets discount limit for each employee.

+
+
+
+
+ +
+
+

+ Set the PIN

+

+ Manager Can Set the PIN

+
+
+
+
+ +
+
+

+ Approving the Discount

+

+ Manager pin needed for approving the discount given by the employee.

+
+
+ +
+ + + +
+
+

+ Screenshots +

+
+
+

+ We can set discount limit for each employee.

+ +
+ +
+

+ Manager can set the pin for approving the discount

+ +
+ +
+

+ Set multiple employees per session in POS. Select the employee to whom we are giving the discount limit.

+ +
+
+

+ Add a discount greater than the limit we are giving the employee.

+ +
+
+

+ We have to enter the manager's pin to approve the discount limit.

+ +
+
+

+ If we are entering the correct pin, we can successfully validate the payment.

+ +
+
+

+ If we are entering the wrong pin, it will show an error popup.

+ +
+
+ + + +
+
+

Suggested Products

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

Our Services

+
+
+ +
+
+ +
+
+ Odoo + Customization
+
+ +
+
+ +
+
+ Odoo + Implementation
+
+ +
+
+ +
+
+ Odoo + Support
+
+ + +
+
+ +
+
+ Hire + Odoo + Developer
+
+ +
+
+ +
+
+ Odoo + Integration
+
+ +
+
+ +
+
+ Odoo + Migration
+
+ + +
+
+ +
+
+ Odoo + Consultancy
+
+ +
+
+ +
+
+ Odoo + Implementation
+
+ +
+
+ +
+
+ Odoo + Licensing Consultancy
+
+
+
+ + + +
+
+
+

Our Industries

+
+
+ +
+
+ +
+ Trading +
+

+ Easily procure + and + sell your products

+
+
+ +
+
+ +
+ POS +
+

+ Easy + configuration + and convivial experience

+
+
+ +
+
+ +
+ Education +
+

+ A platform for + educational management

+
+
+ +
+
+ +
+ Manufacturing +
+

+ Plan, track and + schedule your operations

+
+
+ +
+
+ +
+ E-commerce & Website +
+

+ Mobile + friendly, + awe-inspiring product pages

+
+
+ +
+
+ +
+ Service Management +
+

+ Keep track of + services and invoice

+
+
+ +
+
+ +
+ Restaurant +
+

+ Run your bar or + restaurant methodically

+
+
+ +
+
+ +
+ Hotel Management +
+

+ An + all-inclusive + hotel management application

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

Need Help?

+
+
+
+ + +
+ +
+ + +
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+
+
+ + +
\ No newline at end of file diff --git a/pos_discount_manager/static/src/css/popup_size.css b/pos_discount_manager/static/src/css/popup_size.css new file mode 100755 index 000000000..8c2a00d8b --- /dev/null +++ b/pos_discount_manager/static/src/css/popup_size.css @@ -0,0 +1,6 @@ +.pos .popup.popup-number +{ +height:500px; +width:500px + +} \ No newline at end of file diff --git a/pos_discount_manager/static/src/js/NumberPopup.js b/pos_discount_manager/static/src/js/NumberPopup.js new file mode 100755 index 000000000..e79872129 --- /dev/null +++ b/pos_discount_manager/static/src/js/NumberPopup.js @@ -0,0 +1,13 @@ +odoo.define('pos_discount_manager.NumberPopup', function(require) { + 'use strict'; + + const Registries = require('point_of_sale.Registries'); + const NumberPopup = require('point_of_sale.NumberPopup'); + + const Managers = (NumberPopup) => + class extends NumberPopup { + } + NumberPopup.template = 'NumberPopupNumber'; + Registries.Component.extend(NumberPopup, Managers); + return Managers; +}); diff --git a/pos_discount_manager/static/src/js/PosSession.js b/pos_discount_manager/static/src/js/PosSession.js new file mode 100755 index 000000000..e05962c78 --- /dev/null +++ b/pos_discount_manager/static/src/js/PosSession.js @@ -0,0 +1,16 @@ +odoo.define('pos_discount_manager.PosSession', function(require) { + 'use strict'; + + var {PosGlobalState} = require('point_of_sale.models'); + const Registries = require('point_of_sale.Registries'); + const NewPosGlobalState = (PosGlobalState) => class NewPosGlobalState extends PosGlobalState { + /** + *Override PosGlobalState to load fields in pos session + */ + async _processData(loadedData) { + await super._processData(...arguments); + this.hr_employee = loadedData['hr.employee']; + } + } + Registries.Model.extend(PosGlobalState,NewPosGlobalState) + }); \ No newline at end of file diff --git a/pos_discount_manager/static/src/js/ValidateManager.js b/pos_discount_manager/static/src/js/ValidateManager.js new file mode 100755 index 000000000..80005b3bf --- /dev/null +++ b/pos_discount_manager/static/src/js/ValidateManager.js @@ -0,0 +1,102 @@ +odoo.define('pos_discount_manager.ValidateManager', function(require) { + 'use strict'; + + const Registries = require('point_of_sale.Registries'); + const PaymentScreen = require('point_of_sale.PaymentScreen'); + + const ValidateManagers = (PaymentScreen) => + class extends PaymentScreen { + /** + *Override the validate button to approve discount limit + */ + async _finalizeValidation() { + if ((this.currentOrder.is_paid_with_cash() || this.currentOrder.get_change()) && this.env.pos.config.iface_cashdrawer) { + this.env.pos.proxy.printer.open_cashbox(); + } + + this.currentOrder.initialize_validation_date(); + let syncedOrderBackendIds = []; + try { + if (this.currentOrder.is_to_invoice()) { + syncedOrderBackendIds = await this.env.pos.push_and_invoice_order( + this.currentOrder + ); + } else { + syncedOrderBackendIds = await this.env.pos.push_single_order(this.currentOrder); + } + } catch (error) { + if (error instanceof Error) { + throw error; + } else { + await this._handlePushOrderError(error); + } + } + if (syncedOrderBackendIds.length && this.currentOrder.wait_for_push_order()) { + const result = await this._postPushOrderResolve( + this.currentOrder, + syncedOrderBackendIds + ); + if (!result) { + await this.showPopup('ErrorPopup', { + title: 'Error: no internet connection.', + body: error, + }); + } + } + + var order = this.env.pos.get_order(); + var orderlines = this.currentOrder.get_orderlines() + var employee_dis = this.env.pos.get_cashier()['limited_discount']; + var employee_name = this.env.pos.get_cashier()['name'] + var flag = 1; + orderlines.forEach((order) => { + if(order.discount > employee_dis) + flag = 0; + }); + if (flag != 1) { + const {confirmed,payload} = await this.showPopup('NumberPopup', { + title: this.env._t(employee_name + ', your discount is over the limit. \n Manager pin for Approval'), + }); + if(confirmed){ + var output = this.env.pos.employees.filter((obj) => obj.role == 'manager'); + var pin = output[0].pin + if (Sha1.hash(payload) == pin) { + this.showScreen(this.nextScreen); + } + else { + this.showPopup('ErrorPopup', { + title: this.env._t(" Manager Restricted your discount"), + body: this.env._t(employee_name + ", Your Manager pin is incorrect."), + + }); + return false; + } + } + else { + return false; + } + } + this.currentOrder.finalized = true; + this.showScreen(this.nextScreen); + // If we succeeded in syncing the current order, and + // there are still other orders that are left unsynced, + // we ask the user if he is willing to wait and sync them. + if (syncedOrderBackendIds.length && this.env.pos.db.get_orders().length) { + const { + confirmed + } = await this.showPopup('ConfirmPopup', { + title: this.env._t('Remaining unsynced orders'), + body: this.env._t( + 'There are unsynced orders. Do you want to sync these orders?' + ), + }); + if (confirmed) { + // Not yet sure if this should be awaited or not. + this.env.pos.push_orders(); + } + } + } + } + Registries.Component.extend(PaymentScreen, ValidateManagers); + return ValidateManagers; +}); \ No newline at end of file diff --git a/pos_discount_manager/static/src/xml/NumberPopup.xml b/pos_discount_manager/static/src/xml/NumberPopup.xml new file mode 100755 index 000000000..515b1de53 --- /dev/null +++ b/pos_discount_manager/static/src/xml/NumberPopup.xml @@ -0,0 +1,75 @@ + + + + + + + + + \ No newline at end of file diff --git a/pos_discount_manager/views/hr_employee_views.xml b/pos_discount_manager/views/hr_employee_views.xml new file mode 100755 index 000000000..e5db454f7 --- /dev/null +++ b/pos_discount_manager/views/hr_employee_views.xml @@ -0,0 +1,15 @@ + + + + + hr.employee.view.form.inherit.pos.discount.manager + + hr.employee + + + + + + + + \ No newline at end of file