Browse Source

[ADD] new blockage;

pull/304/head
Sylvain LE GAL 8 years ago
parent
commit
89b2da6c49
  1. 12
      pos_access_right/README.rst
  2. 13
      pos_access_right/demo/res_groups.yml
  3. 42
      pos_access_right/models/pos_config.py
  4. 18
      pos_access_right/security/res_groups.yml
  5. BIN
      pos_access_right/static/description/new_groups.png
  6. 1
      pos_access_right/static/src/css/pos_access_right.css
  7. 52
      pos_access_right/static/src/js/pos_access_right.js

12
pos_access_right/README.rst

@ -6,6 +6,12 @@
Point of Sale - Extra Access Right for Certain Actions 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: This module will add the following groups to Odoo:
* PoS - Negative Quantity: The cashier can sell negative quantity in Point Of * 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 * PoS - Change Unit Price: The cashier can change the unit price of a product
in Point Of Sale; 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 .. 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. If a user doesn't belong to a group, he can not use the according feature.

13
pos_access_right/demo/res_groups.yml

@ -16,3 +16,16 @@
- !record {model: res.groups, id: group_pos_change_unit_price}: - !record {model: res.groups, id: group_pos_change_unit_price}:
users: users:
- base.user_root - 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

42
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" help="This field is there to pass the id of the 'PoS - Allow Unit"
" Price Change' Group to the Point of Sale Frontend.") " 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 @api.multi
def _compute_group_pos_negative_qty(self): def _compute_group_pos_negative_qty(self):
print self.env.ref('pos_access_right.group_pos_negative_qty')
for config in self: for config in self:
self.group_pos_negative_qty = \ self.group_pos_negative_qty = \
self.env.ref('pos_access_right.group_pos_negative_qty') self.env.ref('pos_access_right.group_pos_negative_qty')
@api.multi @api.multi
def _compute_group_pos_discount(self): def _compute_group_pos_discount(self):
print self.env.ref('pos_access_right.group_pos_discount')
for config in self: for config in self:
self.group_pos_discount = \ self.group_pos_discount = \
self.env.ref('pos_access_right.group_pos_discount') self.env.ref('pos_access_right.group_pos_discount')
@api.multi @api.multi
def _compute_group_pos_change_unit_price(self): def _compute_group_pos_change_unit_price(self):
print self.env.ref('pos_access_right.group_pos_change_unit_price')
for config in self: for config in self:
self.group_pos_change_unit_price = \ self.group_pos_change_unit_price = \
self.env.ref('pos_access_right.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')

18
pos_access_right/security/res_groups.yml

@ -5,13 +5,25 @@
- !record {model: res.groups, id: group_pos_negative_qty}: - !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 category_id: base.module_category_usability
- !record {model: res.groups, id: group_pos_discount}: - !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 category_id: base.module_category_usability
- !record {model: res.groups, id: group_pos_change_unit_price}: - !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 category_id: base.module_category_usability

BIN
pos_access_right/static/description/new_groups.png

Before

Width: 827  |  Height: 89  |  Size: 12 KiB

After

Width: 678  |  Height: 141  |  Size: 15 KiB

1
pos_access_right/static/src/css/pos_access_right.css

@ -6,6 +6,7 @@
.pos-disabled-mode { .pos-disabled-mode {
color: #bbb !important; color: #bbb !important;
background-color: #d3d3d3 !important;
} }
.pos-disabled-mode:hover { .pos-disabled-mode:hover {
background: #e2e2e2 !important; background: #e2e2e2 !important;

52
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"; "use strict";
var screens = require('point_of_sale.screens'); var screens = require('point_of_sale.screens');
var chrome = require('point_of_sale.chrome');
var models = require('point_of_sale.models'); var models = require('point_of_sale.models');
var gui = require('point_of_sale.gui'); var gui = require('point_of_sale.gui');
var core = require('web.core'); var core = require('web.core');
@ -38,6 +39,12 @@ point_of_sale.gui
else{ else{
$(".mode-button[data-mode='price']").addClass('pos-disabled-mode'); $(".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_negative_qty");
models.load_fields("pos.config", "group_pos_discount"); 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_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 // Overload 'set_cashier' function to display correctly
// unauthorized function after cashier changed // unauthorized function after cashier changed
@ -58,6 +68,35 @@ point_of_sale.models
_set_cashier_.call(this, user); _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 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 // block 'discount' or 'price' button if user doesn't belong to the correct group
clickChangeMode: function(event) { clickChangeMode: function(event) {
if (event.currentTarget.attributes['data-mode'].nodeValue == 'discount' && if (event.currentTarget.attributes['data-mode'].nodeValue == 'discount' &&

Loading…
Cancel
Save