Browse Source

[12.0][IMP] new features for cashier

[IMP] return objects

rename field
pull/304/head
GabbasovDinar 6 years ago
parent
commit
e0190ec0bf
No known key found for this signature in database GPG Key ID: 25B2C246DE78199C
  1. 2
      pos_access_right/README.rst
  2. 2
      pos_access_right/__manifest__.py
  3. 24
      pos_access_right/demo/res_groups.xml
  4. 6
      pos_access_right/i18n/ca.po
  5. 6
      pos_access_right/i18n/fr.po
  6. 6
      pos_access_right/i18n/pos_access_right.pot
  7. 82
      pos_access_right/models/pos_config.py
  8. 1
      pos_access_right/readme/CONTRIBUTORS.rst
  9. 7
      pos_access_right/readme/DESCRIPTION.rst
  10. 32
      pos_access_right/security/res_groups.xml
  11. 2
      pos_access_right/static/description/index.html
  12. 12
      pos_access_right/static/src/css/pos_access_right.css
  13. 357
      pos_access_right/static/src/js/pos_access_right.js

2
pos_access_right/README.rst

@ -30,7 +30,7 @@ This module extends Odoo Point Of Sale features, restricting possibility to cash
* **PoS - Negative Quantity**: The cashier can sell negative quantity in Point Of Sale (ie, can return products);
* **PoS - Discount**: The cashier can set Discount in Point Of Sale;
* **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 - Create Orders**: The cashier can create orders at the same time;
* **PoS - Delete Order**: The cashier can not delete a full order;
**Table of contents**

2
pos_access_right/__manifest__.py

@ -4,7 +4,7 @@
{
'name': 'Point of Sale - Extra Access Right',
'version': '12.0.1.0.0',
'version': '12.0.1.1.0',
'category': 'Point Of Sale',
'summary': 'Point of Sale - Extra Access Right for certain actions',
'author': 'La Louve, GRAP, Odoo Community Association (OCA)',

24
pos_access_right/demo/res_groups.xml

@ -26,4 +26,28 @@
<field name="users" eval="[(4, ref('base.user_root')), (4, ref('base.user_admin'))]"/>
</record>
<record id="group_payment_order" model="res.groups">
<field name="users" eval="[(4, ref('base.user_root')), (4, ref('base.user_admin')), (4, ref('base.user_demo'))]"/>
</record>
<record id="group_change_qty" model="res.groups">
<field name="users" eval="[(4, ref('base.user_root')), (4, ref('base.user_admin'))]"/>
</record>
<record id="group_delete_order_line" model="res.groups">
<field name="users" eval="[(4, ref('base.user_root')), (4, ref('base.user_admin'))]"/>
</record>
<record id="group_create_order_line" model="res.groups">
<field name="users" eval="[(4, ref('base.user_root')), (4, ref('base.user_admin')), (4, ref('base.user_demo'))]"/>
</record>
<record id="group_change_cashier" model="res.groups">
<field name="users" eval="[(4, ref('base.user_root')), (4, ref('base.user_admin'))]"/>
</record>
<record id="group_change_customer" model="res.groups">
<field name="users" eval="[(4, ref('base.user_root')), (4, ref('base.user_admin'))]"/>
</record>
</odoo>

6
pos_access_right/i18n/ca.po

@ -43,7 +43,7 @@ msgstr "Descomptes - Funció no autoritzada "
#. openerp-web
#: code:addons/pos_access_right/static/src/js/pos_access_right.js:72
#, python-format
msgid "Many Orders - Unauthorized function"
msgid "Create Orders - Unauthorized function"
msgstr "Múltiples Comandes - Funció no autoritzada"
#. module: pos_access_right
@ -93,7 +93,7 @@ msgstr "Punt de Venda - Descomptes "
#. module: pos_access_right
#: model:ir.model.fields,field_description:pos_access_right.field_pos_config_group_multi_order_id
#: model:res.groups,name:pos_access_right.group_multi_order
msgid "Point of Sale - Many Orders"
msgid "Point of Sale - Create Orders"
msgstr "Punt de Venda - Múltiples Comandes "
#. module: pos_access_right
@ -145,7 +145,7 @@ msgstr ""
#. module: pos_access_right
#: model:ir.model.fields,help:pos_access_right.field_pos_config_group_multi_order_id
msgid ""
"This field is there to pass the id of the 'PoS - Many Orders Group to the "
"This field is there to pass the id of the 'PoS - Create Orders Group to the "
"Point of Sale Frontend."
msgstr ""
"Aquest camp està aquí per passar el ID del grup 'TPV - Múltiples Comandes' "

6
pos_access_right/i18n/fr.po

@ -41,7 +41,7 @@ msgstr "Remise - Fonctionnalité non autorisée"
#. openerp-web
#: code:addons/pos_access_right/static/src/js/pos_access_right.js:72
#, python-format
msgid "Many Orders - Unauthorized function"
msgid "Create Orders - Unauthorized function"
msgstr "Plusieurs Commandes simultanées - Fonctionnalité non autorisée"
#. module: pos_access_right
@ -91,7 +91,7 @@ msgstr "Point de Vente - Remise"
#. module: pos_access_right
#: model:ir.model.fields,field_description:pos_access_right.field_pos_config_group_multi_order_id
#: model:res.groups,name:pos_access_right.group_multi_order
msgid "Point of Sale - Many Orders"
msgid "Point of Sale - Create Orders"
msgstr "Point de Vente - Plusieurs commandes simultanées"
#. module: pos_access_right
@ -143,7 +143,7 @@ msgstr ""
#. module: pos_access_right
#: model:ir.model.fields,help:pos_access_right.field_pos_config_group_multi_order_id
msgid ""
"This field is there to pass the id of the 'PoS - Many Orders Group to the "
"This field is there to pass the id of the 'PoS - Create Orders Group to the "
"Point of Sale Frontend."
msgstr ""
"Ce champs existe pour passer l'ID du groupe 'PdV - Plusieurs commandes' au "

6
pos_access_right/i18n/pos_access_right.pot

@ -38,7 +38,7 @@ msgstr ""
#. openerp-web
#: code:addons/pos_access_right/static/src/js/pos_access_right.js:57
#, python-format
msgid "Many Orders - Unauthorized function"
msgid "Create Orders - Unauthorized function"
msgstr ""
#. module: pos_access_right
@ -88,7 +88,7 @@ msgstr ""
#. module: pos_access_right
#: model:ir.model.fields,field_description:pos_access_right.field_pos_config__group_multi_order_id
#: model:res.groups,name:pos_access_right.group_multi_order
msgid "Point of Sale - Many Orders"
msgid "Point of Sale - Create Orders"
msgstr ""
#. module: pos_access_right
@ -128,6 +128,6 @@ msgstr ""
#. module: pos_access_right
#: model:ir.model.fields,help:pos_access_right.field_pos_config__group_multi_order_id
msgid "This field is there to pass the id of the 'PoS - Many Orders Group to the Point of Sale Frontend."
msgid "This field is there to pass the id of the 'PoS - Create Orders Group to the Point of Sale Frontend."
msgstr ""

82
pos_access_right/models/pos_config.py

@ -32,8 +32,8 @@ class PosConfig(models.Model):
group_multi_order_id = fields.Many2one(
comodel_name='res.groups',
compute='_compute_group_multi_order_id',
string='Point of Sale - Many Orders',
help="This field is there to pass the id of the 'PoS - Many Orders"
string='Point of Sale - Create Orders',
help="This field is there to pass the id of the 'PoS - Create Orders"
" Group to the Point of Sale Frontend.")
group_delete_order_id = fields.Many2one(
@ -43,6 +43,48 @@ 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_order_id = fields.Many2one(
comodel_name='res.groups',
compute='_compute_group_payment_order_id',
string='Point of Sale - Payment Order',
help="This field is there to pass the id of the 'PoS - Payment"
" Quantity' Group to the Point of Sale Frontend.")
group_change_qty_id = fields.Many2one(
comodel_name='res.groups',
compute='_compute_group_change_qty_id',
string='Point of Sale - Change Quantity',
help="This field is there to pass the id of the 'PoS - Change"
" Quantity' Group to the Point of Sale Frontend.")
group_delete_order_line_id = fields.Many2one(
comodel_name='res.groups',
compute='_compute_group_delete_order_line_id',
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.")
group_create_order_line_id = fields.Many2one(
comodel_name='res.groups',
compute='_compute_group_create_order_line_id',
string='Point of Sale - Create Order Line',
help="This field is there to pass the id of the 'PoS - Create"
" Order Line' Group to the Point of Sale Frontend.")
group_change_cashier_id = fields.Many2one(
comodel_name='res.groups',
compute='_compute_group_change_cashier_id',
string='Point of Sale - Change Cashier',
help="This field is there to pass the id of the 'PoS - Change"
" Cashier' Group to the Point of Sale Frontend.")
group_change_customer_id = fields.Many2one(
comodel_name='res.groups',
compute='_compute_group_change_customer_id',
string='Point of Sale - Change Customer',
help="This field is there to pass the id of the 'PoS - Change"
" Customer' Group to the Point of Sale Frontend.")
@api.multi
def _compute_group_negative_qty_id(self):
for config in self:
@ -72,3 +114,39 @@ 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_order_id(self):
for config in self:
self.group_payment_order_id = \
self.env.ref('pos_access_right.group_payment_order')
@api.multi
def _compute_group_change_qty_id(self):
for config in self:
self.group_change_qty_id = \
self.env.ref('pos_access_right.group_change_qty')
@api.multi
def _compute_group_delete_order_line_id(self):
for config in self:
self.group_delete_order_line_id = \
self.env.ref('pos_access_right.group_delete_order_line')
@api.multi
def _compute_group_create_order_line_id(self):
for config in self:
self.group_create_order_line_id = \
self.env.ref('pos_access_right.group_create_order_line')
@api.multi
def _compute_group_change_cashier_id(self):
for config in self:
self.group_change_cashier_id = \
self.env.ref('pos_access_right.group_change_cashier')
@api.multi
def _compute_group_change_customer_id(self):
for config in self:
self.group_change_customer_id = \
self.env.ref('pos_access_right.group_change_customer')

1
pos_access_right/readme/CONTRIBUTORS.rst

@ -1 +1,2 @@
* Sylvain LE GAL <https://twitter.com/legalsylvain>
* Dinar Gabbasov <https://it-projects.info/team/GabbasovDinar>

7
pos_access_right/readme/DESCRIPTION.rst

@ -3,5 +3,10 @@ This module extends Odoo Point Of Sale features, restricting possibility to cash
* **PoS - Negative Quantity**: The cashier can sell negative quantity in Point Of Sale (ie, can return products);
* **PoS - Discount**: The cashier can set Discount in Point Of Sale;
* **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 - Create Orders**: The cashier can create orders at the same time;
* **PoS - Delete Order**: The cashier can not delete a full order;
* **PoS - Change Quantity**: The cashier can change the quantity of a product in Point Of Sale;
* **PoS - Delete Order Line**: The cashier can delete the order line in Point Of Sale;
* **PoS - Create Order Line**: The cashier can create the order line of a product in Point Of Sale;
* **PoS - Change Cashier**: The cashier can select another cashier in Point Of Sale;
* **PoS - Change Customer**: The cashier can select a customer in Point Of Sale;

32
pos_access_right/security/res_groups.xml

@ -22,7 +22,7 @@
</record>
<record id="group_multi_order" model="res.groups">
<field name="name">Point of Sale - Many Orders</field>
<field name="name">Point of Sale - Create Orders</field>
<field name="category_id" ref="base.module_category_usability"/>
</record>
@ -31,4 +31,34 @@
<field name="category_id" ref="base.module_category_usability"/>
</record>
<record id="group_payment_order" model="res.groups">
<field name="name">Point of Sale - Payment Order</field>
<field name="category_id" ref="base.module_category_usability"/>
</record>
<record id="group_change_qty" model="res.groups">
<field name="name">Point of Sale - Change Quantity</field>
<field name="category_id" ref="base.module_category_usability"/>
</record>
<record id="group_delete_order_line" model="res.groups">
<field name="name">Point of Sale - Delete Order Line</field>
<field name="category_id" ref="base.module_category_usability"/>
</record>
<record id="group_create_order_line" model="res.groups">
<field name="name">Point of Sale - Create Order Line</field>
<field name="category_id" ref="base.module_category_usability"/>
</record>
<record id="group_change_cashier" model="res.groups">
<field name="name">Point of Sale - Change Cashier</field>
<field name="category_id" ref="base.module_category_usability"/>
</record>
<record id="group_change_customer" model="res.groups">
<field name="name">Point of Sale - Change Customer</field>
<field name="category_id" ref="base.module_category_usability"/>
</record>
</odoo>

2
pos_access_right/static/description/index.html

@ -373,7 +373,7 @@ ul.auto-toc {
<li><strong>PoS - Negative Quantity</strong>: The cashier can sell negative quantity in Point Of Sale (ie, can return products);</li>
<li><strong>PoS - Discount</strong>: The cashier can set Discount in Point Of Sale;</li>
<li><strong>PoS - Change Unit Price</strong>: The cashier can change the unit price of a product in Point Of Sale;</li>
<li><strong>PoS - Many Orders</strong>: The cashier can many orders at the same time;</li>
<li><strong>PoS - Create Orders</strong>: The cashier can create orders at the same time;</li>
<li><strong>PoS - Delete Order</strong>: The cashier can not delete a full order;</li>
</ul>
<p><strong>Table of contents</strong></p>

12
pos_access_right/static/src/css/pos_access_right.css

@ -11,3 +11,15 @@
.pos-disabled-mode:hover {
background: #e2e2e2 !important;
}
/* Payment button circle */
.pos-disabled-mode .pay-circle {
background: #a7a7a7 !important;
}
/* Product list */
.rightpane.pos-disabled-mode {
opacity: 0.4;
background: #d3d3d3 !important;
}
.rightpane.pos-disabled-mode:hover {
background: #d3d3d3 !important;
}

357
pos_access_right/static/src/js/pos_access_right.js

@ -11,39 +11,9 @@ odoo.define('pos_access_right.pos_access_right', function (require) {
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');
var _t = core._t;
// New function 'display_access_right' to display disabled functions
gui.Gui.prototype.display_access_right = function (user) {
if (user.groups_id.indexOf(this.pos.config.group_negative_qty_id[0]) === -1) {
$('.numpad-minus').addClass('pos-disabled-mode');
} else {
$('.numpad-minus').removeClass('pos-disabled-mode');
}
if (user.groups_id.indexOf(this.pos.config.group_discount_id[0]) === -1) {
$(".mode-button[data-mode='discount']").addClass('pos-disabled-mode');
} else {
$(".mode-button[data-mode='discount']").removeClass('pos-disabled-mode');
}
if (user.groups_id.indexOf(this.pos.config.group_change_unit_price_id[0]) === -1) {
$(".mode-button[data-mode='price']").addClass('pos-disabled-mode');
} else {
$(".mode-button[data-mode='price']").removeClass('pos-disabled-mode');
}
};
// Overload 'set_cashier' function to display correctly
// unauthorized function after cashier changed
var _set_cashier_ = models.PosModel.prototype.set_cashier;
models.PosModel.prototype.set_cashier = function (user) {
if (user.groups_id) {
this.gui.display_access_right(user);
}
_set_cashier_.call(this, user);
};
chrome.OrderSelectorWidget.include({
/**
@ -54,7 +24,7 @@ odoo.define('pos_access_right.pos_access_right', function (require) {
neworder_click_handler: function (event, $el) {
if (this.pos.get_cashier().groups_id.indexOf(this.pos.config.group_multi_order_id[0]) === -1) {
this.gui.show_popup('error', {
'title': _t('Many Orders - Unauthorized function'),
'title': _t('Create Orders - Unauthorized function'),
'body': _t('Please ask your manager to do it.'),
});
} else {
@ -77,16 +47,123 @@ odoo.define('pos_access_right.pos_access_right', function (require) {
this._super(event, $el);
}
},
/**
* Render order selector
*/
renderElement: function () {
this._super();
if (this.pos.get_cashier().groups_id.indexOf(this.pos.config.group_multi_order_id[0]) === -1) {
this.$('.neworder-button').addClass('pos-disabled-mode');
} else {
this.$('.neworder-button').removeClass('pos-disabled-mode');
}
if (this.pos.get_cashier().groups_id.indexOf(this.pos.config.group_delete_order_id[0]) === -1) {
this.$('.deleteorder-button').addClass('pos-disabled-mode');
} else {
this.$('.deleteorder-button').removeClass('pos-disabled-mode');
}
},
});
chrome.UsernameWidget.include({
/**
* Change cashier
*/
click_username: function () {
var user = this.pos.get_cashier();
if (user.groups_id.indexOf(this.pos.config.group_change_cashier_id[0]) === -1) {
this.gui.show_popup('error', {
'title': _t('Change Cashier - Unauthorized function'),
'body': _t('Please ask your manager to do it.'),
});
} else {
this._super();
}
},
});
var _super_numpad = models.NumpadState.prototype;
models.NumpadState = models.NumpadState.extend({
/**
* Reset current mode and clear buffer
*/
reset: function () {
var pos = window.posmodel;
var user = pos.get('cashier') || pos.get_cashier();
if (user.groups_id.indexOf(pos.config.group_change_qty_id[0]) === -1) {
// We cannot set the 'quantity' mode if this mode is disabled
this.set({buffer:'0'});
} else {
_super_numpad.reset.apply(this, arguments);
}
},
});
var _super_order = models.Order.prototype;
models.Order = models.Order.extend({
/**
* Add product
* @param {Object} product
* @param {Object} options
*/
add_product: function (product, options) {
var user = this.pos.get('cashier') || this.pos.get_cashier();
if (user.groups_id.indexOf(this.pos.config.group_create_order_line_id[0]) === -1) {
this.pos.gui.show_popup('error', {
'title': _t('Create Order Line - Unauthorized function'),
'body': _t('Please ask your manager to do it.'),
});
} else {
_super_order.add_product.apply(this, arguments);
}
},
});
screens.NumpadWidget.include({
/**
* To display correctly unauthorized function at the beginning of the session, based on current user
* Block mods/numpad if a user doesn't belong to the correct group
*/
start: function () {
applyAccessRights: function () {
this._super();
this.gui.display_access_right(this.pos.get_cashier());
var user = this.pos.get('cashier') || this.pos.get_cashier();
// Numpad access
if (user.groups_id.indexOf(this.pos.config.group_negative_qty_id[0]) === -1) {
this.$('.numpad-minus').addClass('pos-disabled-mode');
} else {
this.$('.numpad-minus').removeClass('pos-disabled-mode');
}
if (user.groups_id.indexOf(this.pos.config.group_change_qty_id[0]) === -1) {
this.$(".mode-button[data-mode='quantity']").addClass('pos-disabled-mode');
this.state.changeMode('discount');
} else {
this.$(".mode-button[data-mode='quantity']").removeClass('pos-disabled-mode');
}
if (user.groups_id.indexOf(this.pos.config.group_discount_id[0]) === -1) {
this.$(".mode-button[data-mode='discount']").addClass('pos-disabled-mode');
this.state.changeMode('price');
} else {
this.$(".mode-button[data-mode='discount']").removeClass('pos-disabled-mode');
}
if (user.groups_id.indexOf(this.pos.config.group_change_unit_price_id[0]) === -1) {
this.$(".mode-button[data-mode='price']").addClass('pos-disabled-mode');
} else {
this.$(".mode-button[data-mode='price']").removeClass('pos-disabled-mode');
}
// Disable numpad if all mods are not active
if (user.groups_id.indexOf(this.pos.config.group_change_qty_id[0]) === -1 &&
user.groups_id.indexOf(this.pos.config.group_discount_id[0]) === -1 &&
user.groups_id.indexOf(this.pos.config.group_change_unit_price_id[0]) === -1) {
this.$('.input-button').addClass('pos-disabled-mode');
this.disable_numpad = true;
} else {
this.$('.input-button').removeClass('pos-disabled-mode');
this.disable_numpad = false;
}
},
/**
@ -110,6 +187,13 @@ odoo.define('pos_access_right.pos_access_right', function (require) {
* @returns {Object}
*/
clickChangeMode: function (event) {
var line = this.pos.get_order().get_selected_orderline();
if (event.currentTarget.attributes['data-mode'].nodeValue === "quantity" && line && line.quantity <= 0 &&
this.pos.get_cashier().groups_id.indexOf(this.pos.config.group_delete_order_line_id[0]) === -1) {
this.$('.numpad-backspace').addClass('pos-disabled-mode');
} else {
this.$('.numpad-backspace').removeClass('pos-disabled-mode');
}
if (event.currentTarget.attributes['data-mode'].nodeValue === 'discount' &&
this.pos.get_cashier().groups_id.indexOf(this.pos.config.group_discount_id[0]) === -1) {
this.gui.show_popup('error', {
@ -122,9 +206,214 @@ odoo.define('pos_access_right.pos_access_right', function (require) {
'title': _t('Change Unit Price - Unauthorized function'),
'body': _t('Please ask your manager to do it.'),
});
} else if (event.currentTarget.attributes['data-mode'].nodeValue === 'quantity' &&
this.pos.get_cashier().groups_id.indexOf(this.pos.config.group_change_qty_id[0]) === -1) {
this.gui.show_popup('error', {
'title': _t('Change Quantity - Unauthorized function'),
'body': _t('Please ask your manager to do it.'),
});
} else {
return this._super(event);
}
},
/**
* Append new char
* @param {MouseEvent} event
* @returns {Object}
*/
clickAppendNewChar: function (event) {
if (this.disable_numpad) {
// Show popup if disabled all mods
this.gui.show_popup('error', {
'title': _t('Cannot use the numpad - All modes disabled'),
'body': _t('Please ask your manager to do it.'),
});
} else {
return this._super(event);
}
},
/**
* Block 'backspace' button if user doesn't belong to the correct group
* @returns {Object}
*/
clickDeleteLastChar: function () {
var order = this.pos.get_order();
if (this.state.get('mode') === "quantity" &&
order.get_selected_orderline() &&
order.get_selected_orderline().quantity <= 0 &&
this.pos.get_cashier().groups_id.indexOf(this.pos.config.group_delete_order_line_id[0]) === -1) {
this.gui.show_popup('error', {
'title': _t('Cannot remove orderline - Unauthorized function'),
'body': _t('Please ask your manager to do it.'),
});
} else {
return this._super();
}
},
});
screens.ActionpadWidget.include({
/**
* Start check access rights
*/
start: function () {
// New function - check actions access
this.applyAccessRights();
this.pos.bind('change:cashier', this.applyAccessRights, this);
this._super();
},
/**
* Check and apply access rights
*/
applyAccessRights: function () {
// Action pad access
var user = this.pos.get('cashier') || this.pos.get_cashier();
if (user.groups_id.indexOf(this.pos.config.group_payment_order_id[0]) === -1) {
this.$(".pay").addClass('pos-disabled-mode');
} else {
this.$(".pay").removeClass('pos-disabled-mode');
}
if (user.groups_id.indexOf(this.pos.config.group_change_customer_id[0]) === -1) {
this.$(".set-customer").addClass('pos-disabled-mode');
} else {
this.$(".set-customer").removeClass('pos-disabled-mode');
}
},
/**
* Render action pad and set a new event handler
*/
renderElement: function () {
this._super();
this.$('.pay').unbind();
this.$('.pay').click(this.clickPayment.bind(this));
this.$('.set-customer').unbind();
this.$('.set-customer').click(this.clickSetCustomer.bind(this));
},
/**
* Event handler after clicking on the payment button
*/
clickPayment: function () {
var self = this;
var user = this.pos.get('cashier') || this.pos.get_cashier();
if (user.groups_id.indexOf(this.pos.config.group_payment_order_id[0]) === -1) {
this.gui.show_popup('error', {
'title': _t('Payment - Unauthorized function'),
'body': _t('Please ask your manager to do it.'),
});
} else {
// Copy past from /point_of_sale/static/src/js/screens.js#L447
var order = self.pos.get_order();
var has_valid_product_lot = _.every(order.orderlines.models, function (line) {
return line.has_valid_product_lot();
});
if (has_valid_product_lot) {
this.gui.show_screen('payment');
} else {
this.gui.show_popup('confirm', {
'title': _t('Empty Serial/Lot Number'),
'body': _t('One or more product(s) required serial/lot number.'),
confirm: function () {
self.gui.show_screen('payment');
},
});
}
}
},
/**
* Event handler after clicking on the customer button
*/
clickSetCustomer: function () {
var user = this.pos.get('cashier') || this.pos.get_cashier();
if (user.groups_id.indexOf(this.pos.config.group_change_customer_id[0]) === -1) {
this.gui.show_popup('error', {
'title': _t('Change Customer - Unauthorized function'),
'body': _t('Please ask your manager to do it.'),
});
} else {
// Copy past from /point_of_sale/static/src/js/screens.js#L465
this.gui.show_screen('clientlist');
}
},
});
screens.ProductScreenWidget.include({
/**
* Start check access to create order line
*/
start: function () {
this._super();
this.checkCreateOrderLine();
},
/**
* Render Products list
*/
renderElement: function () {
this._super();
this.pos.bind('change:cashier', this.checkCreateOrderLine, this);
},
/**
* Block product list if user doesn't belong to the correct group
*/
checkCreateOrderLine: function () {
var user = this.pos.get('cashier') || this.pos.get_cashier();
if (user.groups_id.indexOf(this.pos.config.group_create_order_line_id[0]) === -1) {
$('.rightpane').addClass('pos-disabled-mode');
} else {
$('.rightpane').removeClass('pos-disabled-mode');
}
},
});
screens.OrderWidget.include({
/**
* Change current orderline
* @param {Object} line
*/
orderline_change: function (line) {
var user = this.pos.get('cashier') || this.pos.get_cashier();
var numpad = this.getParent().numpad;
if (numpad.disable_numpad || (line && line.quantity <= 0 && user.groups_id.indexOf(this.pos.config.group_delete_order_line_id[0]) === -1 && numpad.state.get('mode') === "quantity")) {
$('.numpad-backspace').addClass('pos-disabled-mode');
} else {
$('.numpad-backspace').removeClass('pos-disabled-mode');
}
this._super(line);
},
/**
* Block 'backspace' button if user doesn't belong to the correct group
* @param {Boolean} scrollbottom
*/
renderElement: function (scrollbottom) {
this._super(scrollbottom);
var order = this.pos.get_order();
if (order) {
var line = order.get_selected_orderline();
var user = this.pos.get('cashier') || this.pos.get_cashier();
var numpad = this.getParent().numpad;
if (numpad.disable_numpad || (line && line.quantity <= 0 && user.groups_id.indexOf(this.pos.config.group_delete_order_line_id[0]) === -1 && numpad.state.get('mode') === "quantity")) {
$('.numpad-backspace').addClass('pos-disabled-mode');
} else {
$('.numpad-backspace').removeClass('pos-disabled-mode');
}
}
},
});
return {
'models': models,
'chrome': chrome,
'screens': screens,
};
});
Loading…
Cancel
Save