diff --git a/pos_access_right/demo/res_groups.xml b/pos_access_right/demo/res_groups.xml
index bc7eef33..13b84b4b 100644
--- a/pos_access_right/demo/res_groups.xml
+++ b/pos_access_right/demo/res_groups.xml
@@ -26,4 +26,8 @@
+
+
+
+
diff --git a/pos_access_right/models/pos_config.py b/pos_access_right/models/pos_config.py
index df19a678..33d828cd 100644
--- a/pos_access_right/models/pos_config.py
+++ b/pos_access_right/models/pos_config.py
@@ -43,6 +43,13 @@ class PosConfig(models.Model):
help="This field is there to pass the id of the 'PoS - Delete Order'"
" Group to the Point of Sale Frontend.")
+ group_payment_id = fields.Many2one(
+ comodel_name='res.groups',
+ compute='_compute_group_payment_id',
+ string='Point of Sale - Payment',
+ help="This field is there to pass the id of the 'PoS - Payment'"
+ " Group to the Point of Sale Frontend.")
+
@api.multi
def _compute_group_negative_qty_id(self):
for config in self:
@@ -72,3 +79,9 @@ class PosConfig(models.Model):
for config in self:
self.group_delete_order_id = \
self.env.ref('pos_access_right.group_delete_order')
+
+ @api.multi
+ def _compute_group_payment_id(self):
+ for config in self:
+ self.group_payment_id = \
+ self.env.ref('pos_access_right.group_payment')
diff --git a/pos_access_right/security/res_groups.xml b/pos_access_right/security/res_groups.xml
index b9e71749..865070f9 100644
--- a/pos_access_right/security/res_groups.xml
+++ b/pos_access_right/security/res_groups.xml
@@ -31,4 +31,9 @@
+
+ Point of Sale - Payment
+
+
+
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 5995d94b..4e4dfd24 100644
--- a/pos_access_right/static/src/js/pos_access_right.js
+++ b/pos_access_right/static/src/js/pos_access_right.js
@@ -32,6 +32,11 @@ odoo.define('pos_access_right.pos_access_right', function (require) {
} else {
$(".mode-button[data-mode='price']").removeClass('pos-disabled-mode');
}
+ if (user.groups_id.indexOf(this.pos.config.group_payment_id[0]) === -1) {
+ $(".button.pay").addClass('pos-disabled-mode');
+ } else {
+ $(".button.pay").removeClass('pos-disabled-mode');
+ }
};
// Overload 'set_cashier' function to display correctly
@@ -127,4 +132,28 @@ odoo.define('pos_access_right.pos_access_right', function (require) {
}
},
});
+
+ screens.ActionpadWidget.include({
+
+ /**
+ * Block 'Payment' button if user doesn't belong to the correct group
+ */
+ renderElement: function() {
+ var self = this;
+ this._super();
+ this.gui.display_access_right(this.pos.get_cashier());
+ var button_pay_click_handler = $._data(this.$el.find(".button.pay")[0],"events").click[0].handler;
+ this.$('.pay').off('click').click(function(){
+ if (self.pos.get_cashier().groups_id.indexOf(self.pos.config.group_payment_id[0]) === -1) {
+ self.gui.show_popup('error', {
+ 'title': _t('Payment - Unauthorized function'),
+ 'body': _t('Please ask your manager to do it.'),
+ });
+ } else {
+ button_pay_click_handler();
+ }
+ });
+ }
+ });
+
});