From 0e9bf254b250cacf70858d73794f607cb3d23c67 Mon Sep 17 00:00:00 2001 From: Gabriela Rivero Date: Fri, 25 Jan 2019 15:48:53 -0300 Subject: [PATCH 1/7] [FIX] Bug on pos_access_right: black screen when opening POS --- .../static/src/js/pos_access_right.js | 170 ++++++++++++------ 1 file changed, 113 insertions(+), 57 deletions(-) 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 2781c888..57e3ac5c 100644 --- a/pos_access_right/static/src/js/pos_access_right.js +++ b/pos_access_right/static/src/js/pos_access_right.js @@ -11,6 +11,7 @@ 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 Model = require('web.DataModel'); var gui = require('point_of_sale.gui'); var core = require('web.core'); var _t = core._t; @@ -21,24 +22,37 @@ point_of_sale.gui // 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').removeClass('pos-disabled-mode'); - } - else{ - $('.numpad-minus').addClass('pos-disabled-mode'); - } - if (user.groups_id.indexOf(this.pos.config.group_discount_id[0]) != -1){ - $(".mode-button[data-mode='discount']").removeClass('pos-disabled-mode'); - } - else{ - $(".mode-button[data-mode='discount']").addClass('pos-disabled-mode'); - } - if (user.groups_id.indexOf(this.pos.config.group_change_unit_price_id[0]) != -1){ - $(".mode-button[data-mode='price']").removeClass('pos-disabled-mode'); - } - else{ - $(".mode-button[data-mode='price']").addClass('pos-disabled-mode'); + var records = new Model('res.users') + .query(['groups_id']) + .filter([['id', '=', user['id']]]) + .all() + var groups_id = []; + var group_negative_qty_id = this.pos.config.group_negative_qty_id[0]; + var group_discount_id = this.pos.config.group_discount_id[0]; + var group_change_unit_price_id = this.pos.config.group_change_unit_price_id[0]; + records.then(function(result){ + groups_id = result[0]['groups_id']; + if (groups_id.indexOf(group_negative_qty_id) != -1){ + $('.numpad-minus').removeClass('pos-disabled-mode'); + } + else{ + $('.numpad-minus').addClass('pos-disabled-mode'); + } + if (groups_id.indexOf(group_discount_id) != -1){ + $(".mode-button[data-mode='discount']").removeClass('pos-disabled-mode'); + } + else{ + $(".mode-button[data-mode='discount']").addClass('pos-disabled-mode'); + } + if (groups_id.indexOf(group_change_unit_price_id) != -1){ + $(".mode-button[data-mode='price']").removeClass('pos-disabled-mode'); + } + else{ + $(".mode-button[data-mode='price']").addClass('pos-disabled-mode'); + } } + ); + }; @@ -67,26 +81,46 @@ chrome.OrderSelectorWidget chrome.OrderSelectorWidget.include({ 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'), - 'body': _t('Please ask your manager to do it.'), - }); - } - else { - return this._super(); + var user = this.pos.get_cashier() + var records = new Model('res.users') + .query(['groups_id']) + .filter([['id', '=', user['id']]]) + .all() + var groups_id = []; + var group_multi_order_id = this.pos.config.group_multi_order_id[0]; + var gui = this.gui; + records.then(function(result){ + groups_id = result[0]['groups_id']; + if (groups_id.indexOf(group_multi_order_id) == -1) { + gui.show_popup('error',{ + 'title': _t('Many Orders - Unauthorized function'), + 'body': _t('Please ask your manager to do it.'), + }); + } } + ); + return this._super(); }, deleteorder_click_handler: function(event, $el) { - if (this.pos.get_cashier().groups_id.indexOf(this.pos.config.group_delete_order_id[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(); + var user = this.pos.get_cashier() + var records = new Model('res.users') + .query(['groups_id']) + .filter([['id', '=', user['id']]]) + .all() + var groups_id = []; + var group_delete_order_id = this.pos.config.group_delete_order_id[0]; + var gui = this.gui; + records.then(function(result){ + groups_id = result[0]['groups_id']; + if (groups_id.indexOf(group_delete_order_id) == -1) { + gui.show_popup('error',{ + 'title': _t('Delete Order - Unauthorized function'), + 'body': _t('Please ask your manager to do it.'), + }); + } } + ); + return this._super(); }, }); @@ -105,36 +139,58 @@ screens.NumpadWidget // block '+/-' button if user doesn't belong to the correct group clickSwitchSign: function() { - if (this.pos.get_cashier().groups_id.indexOf(this.pos.config.group_negative_qty_id[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(); + var user = this.pos.get_cashier() + var records = new Model('res.users') + .query(['groups_id']) + .filter([['id', '=', user['id']]]) + .all() + var groups_id = []; + var group_negative_qty_id = this.pos.config.group_negative_qty_id[0]; + var gui = this.gui; + records.then(function(result){ + groups_id = result[0]['groups_id']; + if (groups_id.indexOf(group_negative_qty_id) == -1) { + gui.show_popup('error',{ + 'title': _t('Negative Quantity - Unauthorized function'), + 'body': _t('Please ask your manager to do it.'), + }); + } } + ); + 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' && - this.pos.get_cashier().groups_id.indexOf(this.pos.config.group_discount_id[0]) == -1) { - this.gui.show_popup('error',{ - 'title': _t('Discount - Unauthorized function'), - 'body': _t('Please ask your manager to do it.'), - }); - } - else if (event.currentTarget.attributes['data-mode'].nodeValue == 'price' && - this.pos.get_cashier().groups_id.indexOf(this.pos.config.group_change_unit_price_id[0]) == -1) { - this.gui.show_popup('error',{ - 'title': _t('Change Unit Price - Unauthorized function'), - 'body': _t('Please ask your manager to do it.'), - }); - } - else { - return this._super(event); + var user = this.pos.get_cashier() + var records = new Model('res.users') + .query(['groups_id']) + .filter([['id', '=', user['id']]]) + .all() + var groups_id = []; + var group_discount_id = this.pos.config.group_discount_id[0]; + var group_change_unit_price_id = this.pos.config.group_change_unit_price_id[0]; + var gui = this.gui; + records.then(function(result){ + groups_id = result[0]['groups_id']; + if (event.currentTarget.attributes['data-mode'].nodeValue == 'discount' && + groups_id.indexOf(group_discount_id) == -1) { + gui.show_popup('error',{ + 'title': _t('Discount - Unauthorized function'), + 'body': _t('Please ask your manager to do it.'), + }); + } + else if (event.currentTarget.attributes['data-mode'].nodeValue == 'price' && + groups_id.indexOf(group_change_unit_price_id) == -1) { + gui.show_popup('error',{ + 'title': _t('Change Unit Price - Unauthorized function'), + 'body': _t('Please ask your manager to do it.'), + }); + } } + ); + return this._super(event); + }, }); }); From a13ae8e9c13a0b9b4d7ee2c972fec50532dad432 Mon Sep 17 00:00:00 2001 From: Gabriela Rivero Date: Sat, 26 Jan 2019 12:47:24 -0300 Subject: [PATCH 2/7] [IMP] pos_access_right: lint improvements --- .../static/src/js/pos_access_right.js | 171 +++++++++--------- 1 file changed, 88 insertions(+), 83 deletions(-) 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 57e3ac5c..e2d202db 100644 --- a/pos_access_right/static/src/js/pos_access_right.js +++ b/pos_access_right/static/src/js/pos_access_right.js @@ -16,39 +16,40 @@ odoo.define('pos_access_right.pos_access_right', function (require) { var core = require('web.core'); var _t = core._t; -/* ******************************************************** -point_of_sale.gui -******************************************************** */ + /* ******************************************************** + Point_of_sale.gui + ******************************************************** */ // New function 'display_access_right' to display disabled functions - gui.Gui.prototype.display_access_right = function(user){ + gui.Gui.prototype.display_access_right = function (user) { var records = new Model('res.users') - .query(['groups_id']) - .filter([['id', '=', user['id']]]) - .all() + .query(['groups_id']) + .filter([['id', '=', user.id]]) + .all(); var groups_id = []; var group_negative_qty_id = this.pos.config.group_negative_qty_id[0]; var group_discount_id = this.pos.config.group_discount_id[0]; - var group_change_unit_price_id = this.pos.config.group_change_unit_price_id[0]; - records.then(function(result){ - groups_id = result[0]['groups_id']; - if (groups_id.indexOf(group_negative_qty_id) != -1){ - $('.numpad-minus').removeClass('pos-disabled-mode'); - } - else{ + var group_price_id = this.pos.config.group_change_unit_price_id[0]; + records.then (function(result) { + groups_id = result[0].groups_id; + if (groups_id.indexOf(group_negative_qty_id) === -1) { $('.numpad-minus').addClass('pos-disabled-mode'); + } else { + $('.numpad-minus').removeClass('pos-disabled-mode'); } - if (groups_id.indexOf(group_discount_id) != -1){ - $(".mode-button[data-mode='discount']").removeClass('pos-disabled-mode'); - } - else{ - $(".mode-button[data-mode='discount']").addClass('pos-disabled-mode'); - } - if (groups_id.indexOf(group_change_unit_price_id) != -1){ - $(".mode-button[data-mode='price']").removeClass('pos-disabled-mode'); + if (groups_id.indexOf(group_discount_id) === -1) { + $(".mode-button[data-mode='discount']"). + addClass('pos-disabled-mode'); + } else { + $(".mode-button[data-mode='discount']"). + removeClass('pos-disabled-mode'); } - else{ - $(".mode-button[data-mode='price']").addClass('pos-disabled-mode'); + if (groups_id.indexOf(group_price_id) === -1) { + $(".mode-button[data-mode='price']"). + addClass('pos-disabled-mode'); + } else { + $(".mode-button[data-mode='price']"). + removeClass('pos-disabled-mode'); } } ); @@ -56,9 +57,9 @@ point_of_sale.gui }; -/* ******************************************************** -point_of_sale.models -******************************************************** */ + /* ******************************************************** + Point_of_sale.models + ******************************************************** */ // load extra data from 'pos_config' (ids of new groups) models.load_fields("pos.config", "group_negative_qty_id"); @@ -70,29 +71,29 @@ point_of_sale.models // 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){ + models.PosModel.prototype.set_cashier = function (user) { this.gui.display_access_right(user); _set_cashier_.call(this, user); }; -/* ******************************************************** -chrome.OrderSelectorWidget -******************************************************** */ + /* ******************************************************** + Chrome.OrderSelectorWidget + ******************************************************** */ chrome.OrderSelectorWidget.include({ - neworder_click_handler: function(event, $el) { - var user = this.pos.get_cashier() + neworder_click_handler: function (event, $el) { + var user = this.pos.get_cashier(); var records = new Model('res.users') - .query(['groups_id']) - .filter([['id', '=', user['id']]]) - .all() + .query(['groups_id']) + .filter([['id', '=', user.id]]) + .all(); var groups_id = []; var group_multi_order_id = this.pos.config.group_multi_order_id[0]; var gui = this.gui; - records.then(function(result){ - groups_id = result[0]['groups_id']; - if (groups_id.indexOf(group_multi_order_id) == -1) { - gui.show_popup('error',{ + records.then (function(result) { + groups_id = result[0].groups_id; + if (groups_id.indexOf(group_multi_order_id) === -1) { + gui.show_popup('error', { 'title': _t('Many Orders - Unauthorized function'), 'body': _t('Please ask your manager to do it.'), }); @@ -101,19 +102,19 @@ chrome.OrderSelectorWidget ); return this._super(); }, - deleteorder_click_handler: function(event, $el) { - var user = this.pos.get_cashier() + deleteorder_click_handler: function (event, $el) { + var user = this.pos.get_cashier(); var records = new Model('res.users') - .query(['groups_id']) - .filter([['id', '=', user['id']]]) - .all() + .query(['groups_id']) + .filter([['id', '=', user.id]]) + .all(); var groups_id = []; - var group_delete_order_id = this.pos.config.group_delete_order_id[0]; + var group_del_order_id = this.pos.config.group_delete_order_id[0]; var gui = this.gui; - records.then(function(result){ - groups_id = result[0]['groups_id']; - if (groups_id.indexOf(group_delete_order_id) == -1) { - gui.show_popup('error',{ + records.then (function(result) { + groups_id = result[0].groups_id; + if (groups_id.indexOf(group_del_order_id) === -1) { + gui.show_popup('error', { 'title': _t('Delete Order - Unauthorized function'), 'body': _t('Please ask your manager to do it.'), }); @@ -125,33 +126,34 @@ chrome.OrderSelectorWidget }); -/* ******************************************************** -screens.NumpadWidget -******************************************************** */ + /* ******************************************************** + Screens.NumpadWidget + ******************************************************** */ screens.NumpadWidget.include({ // Overload 'start' function to display correctly unauthorized function // at the beginning of the session, based on current user - start: function() { + start: function () { this._super(); this.gui.display_access_right(this.pos.get_cashier()); }, - // block '+/-' button if user doesn't belong to the correct group - clickSwitchSign: function() { - var user = this.pos.get_cashier() + // Block '+/-' button if user doesn't belong to the correct group + clickSwitchSign: function () { + var user = this.pos.get_cashier(); var records = new Model('res.users') - .query(['groups_id']) - .filter([['id', '=', user['id']]]) - .all() + .query(['groups_id']) + .filter([['id', '=', user.id]]) + .all(); var groups_id = []; - var group_negative_qty_id = this.pos.config.group_negative_qty_id[0]; + var group_neg_qty_id = this.pos.config.group_negative_qty_id[0]; var gui = this.gui; - records.then(function(result){ - groups_id = result[0]['groups_id']; - if (groups_id.indexOf(group_negative_qty_id) == -1) { - gui.show_popup('error',{ - 'title': _t('Negative Quantity - Unauthorized function'), + records.then (function(result) { + groups_id = result[0].groups_id; + if (groups_id.indexOf(group_neg_qty_id) === -1) { + gui.show_popup('error', { + 'title': + _t('Negative Quantity - \Unauthorized function'), 'body': _t('Please ask your manager to do it.'), }); } @@ -160,30 +162,33 @@ screens.NumpadWidget return this._super(); }, - // block 'discount' or 'price' button if user doesn't belong to the correct group - clickChangeMode: function(event) { - var user = this.pos.get_cashier() + // Block 'discount' or 'price' button if user doesn't belong to the + //correct group + clickChangeMode: function (event) { + var user = this.pos.get_cashier(); var records = new Model('res.users') - .query(['groups_id']) - .filter([['id', '=', user['id']]]) - .all() + .query(['groups_id']) + .filter([['id', '=', user.id]]) + .all(); var groups_id = []; var group_discount_id = this.pos.config.group_discount_id[0]; - var group_change_unit_price_id = this.pos.config.group_change_unit_price_id[0]; + var group_price_id = this.pos.config.group_change_unit_price_id[0]; var gui = this.gui; - records.then(function(result){ - groups_id = result[0]['groups_id']; - if (event.currentTarget.attributes['data-mode'].nodeValue == 'discount' && - groups_id.indexOf(group_discount_id) == -1) { - gui.show_popup('error',{ + records.then (function(result) { + groups_id = result[0].groups_id; + if (event.currentTarget.attributes['data-mode'].nodeValue === + 'discount' && + groups_id.indexOf(group_discount_id) === -1) { + gui.show_popup('error', { 'title': _t('Discount - Unauthorized function'), 'body': _t('Please ask your manager to do it.'), }); - } - else if (event.currentTarget.attributes['data-mode'].nodeValue == 'price' && - groups_id.indexOf(group_change_unit_price_id) == -1) { - gui.show_popup('error',{ - 'title': _t('Change Unit Price - Unauthorized function'), + } else if (event.currentTarget.attributes['data-mode'].nodeValue + === 'price' && + groups_id.indexOf(group_price_id) === -1) { + gui.show_popup('error', { + 'title': + _t('Change Unit Price - Unauthorized function'), 'body': _t('Please ask your manager to do it.'), }); } From 7db7bf90fa9e79ded58c83b793c09a5eeba090d8 Mon Sep 17 00:00:00 2001 From: Gabriela Rivero Date: Sat, 26 Jan 2019 13:02:50 -0300 Subject: [PATCH 3/7] [IMP] pos_access_right: lint improvements --- .../static/src/js/pos_access_right.js | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) 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 e2d202db..49d6d446 100644 --- a/pos_access_right/static/src/js/pos_access_right.js +++ b/pos_access_right/static/src/js/pos_access_right.js @@ -30,7 +30,7 @@ odoo.define('pos_access_right.pos_access_right', function (require) { var group_negative_qty_id = this.pos.config.group_negative_qty_id[0]; var group_discount_id = this.pos.config.group_discount_id[0]; var group_price_id = this.pos.config.group_change_unit_price_id[0]; - records.then (function(result) { + records.then(function (result) { groups_id = result[0].groups_id; if (groups_id.indexOf(group_negative_qty_id) === -1) { $('.numpad-minus').addClass('pos-disabled-mode'); @@ -38,18 +38,14 @@ odoo.define('pos_access_right.pos_access_right', function (require) { $('.numpad-minus').removeClass('pos-disabled-mode'); } if (groups_id.indexOf(group_discount_id) === -1) { - $(".mode-button[data-mode='discount']"). - addClass('pos-disabled-mode'); + $(".mode-button[data-mode='discount']").addClass('pos-disabled-mode'); } else { - $(".mode-button[data-mode='discount']"). - removeClass('pos-disabled-mode'); + $(".mode-button[data-mode='discount']").removeClass('pos-disabled-mode'); } if (groups_id.indexOf(group_price_id) === -1) { - $(".mode-button[data-mode='price']"). - addClass('pos-disabled-mode'); + $(".mode-button[data-mode='price']").addClass('pos-disabled-mode'); } else { - $(".mode-button[data-mode='price']"). - removeClass('pos-disabled-mode'); + $(".mode-button[data-mode='price']").removeClass('pos-disabled-mode'); } } ); @@ -90,7 +86,7 @@ odoo.define('pos_access_right.pos_access_right', function (require) { var groups_id = []; var group_multi_order_id = this.pos.config.group_multi_order_id[0]; var gui = this.gui; - records.then (function(result) { + records.then(function (result) { groups_id = result[0].groups_id; if (groups_id.indexOf(group_multi_order_id) === -1) { gui.show_popup('error', { @@ -111,7 +107,7 @@ odoo.define('pos_access_right.pos_access_right', function (require) { var groups_id = []; var group_del_order_id = this.pos.config.group_delete_order_id[0]; var gui = this.gui; - records.then (function(result) { + records.then(function (result) { groups_id = result[0].groups_id; if (groups_id.indexOf(group_del_order_id) === -1) { gui.show_popup('error', { @@ -148,12 +144,12 @@ odoo.define('pos_access_right.pos_access_right', function (require) { var groups_id = []; var group_neg_qty_id = this.pos.config.group_negative_qty_id[0]; var gui = this.gui; - records.then (function(result) { + records.then(function (result) { groups_id = result[0].groups_id; if (groups_id.indexOf(group_neg_qty_id) === -1) { gui.show_popup('error', { 'title': - _t('Negative Quantity - \Unauthorized function'), + _t('Negative Quantity - Unauthorized function'), 'body': _t('Please ask your manager to do it.'), }); } @@ -163,7 +159,7 @@ odoo.define('pos_access_right.pos_access_right', function (require) { }, // Block 'discount' or 'price' button if user doesn't belong to the - //correct group + // Correct group clickChangeMode: function (event) { var user = this.pos.get_cashier(); var records = new Model('res.users') @@ -174,7 +170,7 @@ odoo.define('pos_access_right.pos_access_right', function (require) { var group_discount_id = this.pos.config.group_discount_id[0]; var group_price_id = this.pos.config.group_change_unit_price_id[0]; var gui = this.gui; - records.then (function(result) { + records.then(function (result) { groups_id = result[0].groups_id; if (event.currentTarget.attributes['data-mode'].nodeValue === 'discount' && @@ -183,8 +179,7 @@ odoo.define('pos_access_right.pos_access_right', function (require) { 'title': _t('Discount - Unauthorized function'), 'body': _t('Please ask your manager to do it.'), }); - } else if (event.currentTarget.attributes['data-mode'].nodeValue - === 'price' && + } else if (event.currentTarget.attributes['data-mode'].nodeValue === 'price' && groups_id.indexOf(group_price_id) === -1) { gui.show_popup('error', { 'title': From ae440cceb2120c0ca3cb3562ab3ce1f3c69a238b Mon Sep 17 00:00:00 2001 From: Gabriela Rivero Date: Sat, 26 Jan 2019 13:13:12 -0300 Subject: [PATCH 4/7] [IMP] pos_access_right: lint improvements. Gui redefinition. --- .../static/src/js/pos_access_right.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) 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 49d6d446..4ab7ec68 100644 --- a/pos_access_right/static/src/js/pos_access_right.js +++ b/pos_access_right/static/src/js/pos_access_right.js @@ -85,11 +85,11 @@ odoo.define('pos_access_right.pos_access_right', function (require) { .all(); var groups_id = []; var group_multi_order_id = this.pos.config.group_multi_order_id[0]; - var gui = this.gui; + var v_gui = this.gui; records.then(function (result) { groups_id = result[0].groups_id; if (groups_id.indexOf(group_multi_order_id) === -1) { - gui.show_popup('error', { + v_gui.show_popup('error', { 'title': _t('Many Orders - Unauthorized function'), 'body': _t('Please ask your manager to do it.'), }); @@ -106,11 +106,11 @@ odoo.define('pos_access_right.pos_access_right', function (require) { .all(); var groups_id = []; var group_del_order_id = this.pos.config.group_delete_order_id[0]; - var gui = this.gui; + var v_gui = this.gui; records.then(function (result) { groups_id = result[0].groups_id; if (groups_id.indexOf(group_del_order_id) === -1) { - gui.show_popup('error', { + v_gui.show_popup('error', { 'title': _t('Delete Order - Unauthorized function'), 'body': _t('Please ask your manager to do it.'), }); @@ -143,11 +143,11 @@ odoo.define('pos_access_right.pos_access_right', function (require) { .all(); var groups_id = []; var group_neg_qty_id = this.pos.config.group_negative_qty_id[0]; - var gui = this.gui; + var v_gui = this.gui; records.then(function (result) { groups_id = result[0].groups_id; if (groups_id.indexOf(group_neg_qty_id) === -1) { - gui.show_popup('error', { + v_gui.show_popup('error', { 'title': _t('Negative Quantity - Unauthorized function'), 'body': _t('Please ask your manager to do it.'), @@ -169,19 +169,19 @@ odoo.define('pos_access_right.pos_access_right', function (require) { var groups_id = []; var group_discount_id = this.pos.config.group_discount_id[0]; var group_price_id = this.pos.config.group_change_unit_price_id[0]; - var gui = this.gui; + var v_gui = this.gui; records.then(function (result) { groups_id = result[0].groups_id; if (event.currentTarget.attributes['data-mode'].nodeValue === 'discount' && groups_id.indexOf(group_discount_id) === -1) { - gui.show_popup('error', { + v_gui.show_popup('error', { 'title': _t('Discount - Unauthorized function'), 'body': _t('Please ask your manager to do it.'), }); } else if (event.currentTarget.attributes['data-mode'].nodeValue === 'price' && groups_id.indexOf(group_price_id) === -1) { - gui.show_popup('error', { + v_gui.show_popup('error', { 'title': _t('Change Unit Price - Unauthorized function'), 'body': _t('Please ask your manager to do it.'), From 092664543ff71a4876edfb616ed7792686c4ebfe Mon Sep 17 00:00:00 2001 From: Gabriela Rivero Date: Sat, 26 Jan 2019 13:19:38 -0300 Subject: [PATCH 5/7] [IMP] pos_access_right: lint improvements --- pos_access_right/static/src/js/pos_access_right.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 4ab7ec68..5d30d144 100644 --- a/pos_access_right/static/src/js/pos_access_right.js +++ b/pos_access_right/static/src/js/pos_access_right.js @@ -96,7 +96,7 @@ odoo.define('pos_access_right.pos_access_right', function (require) { } } ); - return this._super(); + return this._super(event, $el); }, deleteorder_click_handler: function (event, $el) { var user = this.pos.get_cashier(); @@ -117,7 +117,7 @@ odoo.define('pos_access_right.pos_access_right', function (require) { } } ); - return this._super(); + return this._super(event, $el); }, }); From 4be865337c61c67cb5d133a5073f9a5a9b064a1e Mon Sep 17 00:00:00 2001 From: Gabriela Rivero Date: Sat, 26 Jan 2019 13:26:41 -0300 Subject: [PATCH 6/7] [IMP] pos_access_right: lint lines length improvement --- .../static/src/js/pos_access_right.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) 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 5d30d144..3a06c256 100644 --- a/pos_access_right/static/src/js/pos_access_right.js +++ b/pos_access_right/static/src/js/pos_access_right.js @@ -30,22 +30,23 @@ odoo.define('pos_access_right.pos_access_right', function (require) { var group_negative_qty_id = this.pos.config.group_negative_qty_id[0]; var group_discount_id = this.pos.config.group_discount_id[0]; var group_price_id = this.pos.config.group_change_unit_price_id[0]; + var dis_mode = 'pos-disabled-mode'; records.then(function (result) { groups_id = result[0].groups_id; if (groups_id.indexOf(group_negative_qty_id) === -1) { - $('.numpad-minus').addClass('pos-disabled-mode'); + $('.numpad-minus').addClass(dis_mode); } else { - $('.numpad-minus').removeClass('pos-disabled-mode'); + $('.numpad-minus').removeClass(dis_mode); } if (groups_id.indexOf(group_discount_id) === -1) { - $(".mode-button[data-mode='discount']").addClass('pos-disabled-mode'); + $(".mode-button[data-mode='discount']").addClass(dis_mode); } else { - $(".mode-button[data-mode='discount']").removeClass('pos-disabled-mode'); + $(".mode-button[data-mode='discount']").removeClass(dis_mode); } if (groups_id.indexOf(group_price_id) === -1) { - $(".mode-button[data-mode='price']").addClass('pos-disabled-mode'); + $(".mode-button[data-mode='price']").addClass(dis_mode); } else { - $(".mode-button[data-mode='price']").removeClass('pos-disabled-mode'); + $(".mode-button[data-mode='price']").removeClass(dis_mode); } } ); @@ -170,6 +171,7 @@ odoo.define('pos_access_right.pos_access_right', function (require) { var group_discount_id = this.pos.config.group_discount_id[0]; var group_price_id = this.pos.config.group_change_unit_price_id[0]; var v_gui = this.gui; + var data_mode= event.currentTarget.attributes['data-mode'] records.then(function (result) { groups_id = result[0].groups_id; if (event.currentTarget.attributes['data-mode'].nodeValue === @@ -179,7 +181,7 @@ odoo.define('pos_access_right.pos_access_right', function (require) { 'title': _t('Discount - Unauthorized function'), 'body': _t('Please ask your manager to do it.'), }); - } else if (event.currentTarget.attributes['data-mode'].nodeValue === 'price' && + } else if (data_mode.nodeValue === 'price' && groups_id.indexOf(group_price_id) === -1) { v_gui.show_popup('error', { 'title': From 3431c7785bc68dc436b3afb3b605dd0ff8dfbb46 Mon Sep 17 00:00:00 2001 From: Gabriela Rivero Date: Sat, 26 Jan 2019 13:31:48 -0300 Subject: [PATCH 7/7] [IMP] pos_access_right: lint semicolon missed improvement --- pos_access_right/static/src/js/pos_access_right.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 3a06c256..458e273e 100644 --- a/pos_access_right/static/src/js/pos_access_right.js +++ b/pos_access_right/static/src/js/pos_access_right.js @@ -171,7 +171,7 @@ odoo.define('pos_access_right.pos_access_right', function (require) { var group_discount_id = this.pos.config.group_discount_id[0]; var group_price_id = this.pos.config.group_change_unit_price_id[0]; var v_gui = this.gui; - var data_mode= event.currentTarget.attributes['data-mode'] + var data_mode= event.currentTarget.attributes['data-mode']; records.then(function (result) { groups_id = result[0].groups_id; if (event.currentTarget.attributes['data-mode'].nodeValue ===