diff --git a/addons/point_of_sale/static/src/js/chrome.js b/addons/point_of_sale/static/src/js/chrome.js index 96f0e8df585..150a6930835 100644 --- a/addons/point_of_sale/static/src/js/chrome.js +++ b/addons/point_of_sale/static/src/js/chrome.js @@ -103,12 +103,11 @@ var UsernameWidget = PosBaseWidget.extend({ 'title': _t('Change Cashier'), }).then(function(user){ self.pos.set_cashier(user); - self.pos.gui.screen_instances.products.numpad.check_price_control_rights(); self.renderElement(); }); }, get_name: function(){ - var user = this.pos.cashier || this.pos.user; + var user = this.pos.get_cashier(); if(user){ return user.name; }else{ diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index ff336551bab..74ca9c38766 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -56,7 +56,6 @@ exports.PosModel = Backbone.Model.extend({ this.user = null; this.users = []; this.partners = []; - this.cashier = null; this.cashregisters = []; this.taxes = []; this.pos_session = null; @@ -73,6 +72,7 @@ exports.PosModel = Backbone.Model.extend({ 'orders': new OrderCollection(), 'selectedOrder': null, 'selectedClient': null, + 'cashier': null, }); this.get('orders').bind('remove', function(order,_unused_,options){ @@ -584,11 +584,11 @@ exports.PosModel = Backbone.Model.extend({ // returns the user who is currently the cashier for this point of sale get_cashier: function(){ - return this.cashier || this.user; + return this.get('cashier') || this.user; }, // changes the current cashier set_cashier: function(user){ - this.cashier = user; + this.set('cashier', user); }, //creates a new empty order and sets it as the current order add_new_order: function(){ @@ -1429,9 +1429,6 @@ exports.Orderline = Backbone.Model.extend({ }, // changes the base price of the product for this orderline set_unit_price: function(price){ - if (!this.pos.config.restrict_price_control || this.pos.get_cashier().role == 'manager') { - return; - } this.order.assert_editable(); this.price = round_di(parseFloat(price) || 0, this.pos.dp['Product Price']); this.trigger('change',this); @@ -1891,7 +1888,7 @@ exports.Order = Backbone.Model.extend({ statement_ids: paymentLines, pos_session_id: this.pos_session_id, partner_id: this.get_client() ? this.get_client().id : false, - user_id: this.pos.cashier ? this.pos.cashier.id : this.pos.user.id, + user_id: this.pos.get_cashier().id, uid: this.uid, sequence_number: this.sequence_number, creation_date: this.validation_date || this.creation_date, // todo: rename creation_date in master @@ -1911,7 +1908,7 @@ exports.Order = Backbone.Model.extend({ paymentlines.push(paymentline.export_for_printing()); }); var client = this.get('client'); - var cashier = this.pos.cashier || this.pos.user; + var cashier = this.pos.get_cashier(); var company = this.pos.company; var shop = this.pos.shop; var date = new Date(); diff --git a/addons/point_of_sale/static/src/js/screens.js b/addons/point_of_sale/static/src/js/screens.js index e053264277b..78b150b6844 100644 --- a/addons/point_of_sale/static/src/js/screens.js +++ b/addons/point_of_sale/static/src/js/screens.js @@ -364,17 +364,20 @@ var NumpadWidget = PosBaseWidget.extend({ this.state = new models.NumpadState(); }, start: function() { - this.check_price_control_rights(); + this.applyAccessRights(); this.state.bind('change:mode', this.changedMode, this); + this.pos.bind('change:cashier', this.applyAccessRights, this); this.changedMode(); this.$el.find('.numpad-backspace').click(_.bind(this.clickDeleteLastChar, this)); this.$el.find('.numpad-minus').click(_.bind(this.clickSwitchSign, this)); this.$el.find('.number-char').click(_.bind(this.clickAppendNewChar, this)); this.$el.find('.mode-button').click(_.bind(this.clickChangeMode, this)); }, - check_price_control_rights: function() { - var has_rights = !this.pos.config.restrict_price_control || this.pos.get_cashier().role == 'manager'; - this.$el.find('.mode-button[data-mode="price"]').toggleClass('disabled-mode', !has_rights).prop('disabled', !has_rights); + applyAccessRights: function() { + var has_price_control_rights = !this.pos.config.restrict_price_control || this.pos.get_cashier().role == 'manager'; + this.$el.find('.mode-button[data-mode="price"]') + .toggleClass('disabled-mode', !has_price_control_rights) + .prop('disabled', !has_price_control_rights); }, clickDeleteLastChar: function() { return this.state.deleteLastChar(); diff --git a/addons/point_of_sale/static/src/xml/pos.xml b/addons/point_of_sale/static/src/xml/pos.xml index 71e4ca2c1c8..e746a6f66f0 100644 --- a/addons/point_of_sale/static/src/xml/pos.xml +++ b/addons/point_of_sale/static/src/xml/pos.xml @@ -1422,7 +1422,7 @@

Phone:
- User:
+ User: