diff --git a/pos_access_right/README.rst b/pos_access_right/README.rst index c92fcdab..de30561d 100644 --- a/pos_access_right/README.rst +++ b/pos_access_right/README.rst @@ -6,6 +6,12 @@ Point of Sale - Extra Access Right for Certain Actions ====================================================== +This module extends Odoo Point Of Sale features, restricting possibility +to cashier to make some actions in the Point of Sale (set discount, change +unit prices, etc...) + +this module can be usefull to limit errors and / or fraud. + This module will add the following groups to Odoo: * PoS - Negative Quantity: The cashier can sell negative quantity in Point Of @@ -16,6 +22,12 @@ This module will add the following groups to Odoo: * PoS - Change Unit Price: The cashier can change the unit price of a product in Point Of Sale; +* PoS - Many Orders: The cashier can many orders at the same time; + +* PoS - Delete Order: The cashier can not delete a full order; + +* PoS - Delete Order Line: The cashier can not delete an order line; + .. image:: /pos_access_right/static/description/new_groups.png If a user doesn't belong to a group, he can not use the according feature. diff --git a/pos_access_right/demo/res_groups.yml b/pos_access_right/demo/res_groups.yml index d79411cb..a0efa203 100644 --- a/pos_access_right/demo/res_groups.yml +++ b/pos_access_right/demo/res_groups.yml @@ -16,3 +16,16 @@ - !record {model: res.groups, id: group_pos_change_unit_price}: users: - base.user_root + +- !record {model: res.groups, id: group_pos_multi_order}: + users: + - base.user_root + +- !record {model: res.groups, id: group_pos_delete_order}: + users: + - base.user_root + +- !record {model: res.groups, id: group_pos_delete_order_line}: + users: + - base.user_root + - base.user_demo diff --git a/pos_access_right/models/pos_config.py b/pos_access_right/models/pos_config.py index 19e5fb01..380b6dc0 100644 --- a/pos_access_right/models/pos_config.py +++ b/pos_access_right/models/pos_config.py @@ -30,23 +30,59 @@ class PosConfig(models.Model): help="This field is there to pass the id of the 'PoS - Allow Unit" " Price Change' Group to the Point of Sale Frontend.") + group_pos_multi_order = fields.Many2one( + comodel_name='res.groups', + compute='_compute_group_pos_multi_order', + string='Point of Sale - Many Orders', + help="This field is there to pass the id of the 'PoS - Many Orders" + " Group to the Point of Sale Frontend.") + + group_pos_delete_order = fields.Many2one( + comodel_name='res.groups', + compute='_compute_group_pos_delete_order', + string='Point of Sale - Delete Order', + help="This field is there to pass the id of the 'PoS - Delete Order'" + " Group to the Point of Sale Frontend.") + + group_pos_delete_order_line = fields.Many2one( + comodel_name='res.groups', + compute='_compute_group_pos_delete_order_line', + string='Point of Sale - Delete Order Line', + help="This field is there to pass the id of the 'PoS - Delete Order" + " Line' Group to the Point of Sale Frontend.") + @api.multi def _compute_group_pos_negative_qty(self): - print self.env.ref('pos_access_right.group_pos_negative_qty') for config in self: self.group_pos_negative_qty = \ self.env.ref('pos_access_right.group_pos_negative_qty') @api.multi def _compute_group_pos_discount(self): - print self.env.ref('pos_access_right.group_pos_discount') for config in self: self.group_pos_discount = \ self.env.ref('pos_access_right.group_pos_discount') @api.multi def _compute_group_pos_change_unit_price(self): - print self.env.ref('pos_access_right.group_pos_change_unit_price') for config in self: self.group_pos_change_unit_price = \ self.env.ref('pos_access_right.group_pos_change_unit_price') + + @api.multi + def _compute_group_pos_multi_order(self): + for config in self: + self.group_pos_discount = \ + self.env.ref('pos_access_right.group_pos_multi_order') + + @api.multi + def _compute_group_pos_delete_order(self): + for config in self: + self.group_pos_discount = \ + self.env.ref('pos_access_right.group_pos_delete_order') + + @api.multi + def _compute_group_pos_delete_order_line(self): + for config in self: + self.group_pos_discount = \ + self.env.ref('pos_access_right.group_pos_delete_order_line') diff --git a/pos_access_right/security/res_groups.yml b/pos_access_right/security/res_groups.yml index 96acd08d..d4b4e589 100644 --- a/pos_access_right/security/res_groups.yml +++ b/pos_access_right/security/res_groups.yml @@ -5,13 +5,25 @@ - !record {model: res.groups, id: group_pos_negative_qty}: - name: Point of Sale - Allow Negative Quantity + name: Point of Sale - Negative Quantity category_id: base.module_category_usability - !record {model: res.groups, id: group_pos_discount}: - name: Point of Sale - Allow Discount + name: Point of Sale - Discount category_id: base.module_category_usability - !record {model: res.groups, id: group_pos_change_unit_price}: - name: Point of Sale - Allow Unit Price Change + name: Point of Sale - Unit Price Change + category_id: base.module_category_usability + +- !record {model: res.groups, id: group_pos_multi_order}: + name: Point of Sale - Many Orders + category_id: base.module_category_usability + +- !record {model: res.groups, id: group_pos_delete_order}: + name: Point of Sale - Delete Order + category_id: base.module_category_usability + +- !record {model: res.groups, id: group_pos_delete_order_line}: + name: Point of Sale - Delete Order Line category_id: base.module_category_usability diff --git a/pos_access_right/static/description/new_groups.png b/pos_access_right/static/description/new_groups.png index 11a1c616..43ce34c8 100644 Binary files a/pos_access_right/static/description/new_groups.png and b/pos_access_right/static/description/new_groups.png differ diff --git a/pos_access_right/static/src/css/pos_access_right.css b/pos_access_right/static/src/css/pos_access_right.css index 00bc938a..e10fe1d7 100644 --- a/pos_access_right/static/src/css/pos_access_right.css +++ b/pos_access_right/static/src/css/pos_access_right.css @@ -6,6 +6,7 @@ .pos-disabled-mode { color: #bbb !important; + background-color: #d3d3d3 !important; } .pos-disabled-mode:hover { background: #e2e2e2 !important; diff --git a/pos_access_right/static/src/js/pos_access_right.js b/pos_access_right/static/src/js/pos_access_right.js index 4013d204..cf22dd31 100644 --- a/pos_access_right/static/src/js/pos_access_right.js +++ b/pos_access_right/static/src/js/pos_access_right.js @@ -9,6 +9,7 @@ odoo.define('pos_access_right.pos_access_right', function (require) { "use strict"; var screens = require('point_of_sale.screens'); + var chrome = require('point_of_sale.chrome'); var models = require('point_of_sale.models'); var gui = require('point_of_sale.gui'); var core = require('web.core'); @@ -38,6 +39,12 @@ point_of_sale.gui else{ $(".mode-button[data-mode='price']").addClass('pos-disabled-mode'); } + if (user.groups_id.indexOf(this.pos.config.group_pos_multi_order[0]) != -1){ + $('.neworder-button').removeClass('pos-disabled-mode'); + } + else{ + $('.neworder-button').addClass('pos-disabled-mode'); + } }; @@ -49,6 +56,9 @@ point_of_sale.models models.load_fields("pos.config", "group_pos_negative_qty"); models.load_fields("pos.config", "group_pos_discount"); models.load_fields("pos.config", "group_pos_change_unit_price"); + models.load_fields("pos.config", "group_pos_multi_order"); + models.load_fields("pos.config", "group_pos_delete_order"); + models.load_fields("pos.config", "group_pos_delete_order_line"); // Overload 'set_cashier' function to display correctly // unauthorized function after cashier changed @@ -58,6 +68,35 @@ point_of_sale.models _set_cashier_.call(this, user); }; +/* ******************************************************** +chrome.OrderSelectorWidget +******************************************************** */ + chrome.OrderSelectorWidget.include({ + + neworder_click_handler: function(event, $el) { + if (this.pos.get_cashier().groups_id.indexOf(this.pos.config.group_pos_multi_order[0]) == -1) { + this.gui.show_popup('error',{ + 'title': _t('Negative Quantity - Unauthorized function'), + 'body': _t('Please ask your manager to do it.'), + }); + } + else { + return this._super(); + } + }, + deleteorder_click_handler: function(event, $el) { + if (this.pos.get_cashier().groups_id.indexOf(this.pos.config.group_pos_delete_order[0]) == -1) { + this.gui.show_popup('error',{ + 'title': _t('Delete Order - Unauthorized function'), + 'body': _t('Please ask your manager to do it.'), + }); + } + else { + return this._super(); + } + }, + }); + /* ******************************************************** screens.NumpadWidget @@ -84,6 +123,19 @@ screens.NumpadWidget } }, + // block '+/-' button if user doesn't belong to the correct group + clickDeleteLastChar: function() { + if (this.pos.get_cashier().groups_id.indexOf(this.pos.config.group_pos_delete_order_line[0]) == -1) { + this.gui.show_popup('error',{ + 'title': _t('Delete Order Line - Unauthorized function'), + 'body': _t('Please ask your manager to do it.'), + }); + } + else { + return this._super(); + } + }, + // block 'discount' or 'price' button if user doesn't belong to the correct group clickChangeMode: function(event) { if (event.currentTarget.attributes['data-mode'].nodeValue == 'discount' &&