From 4e715dae94dc956dbfacfe3974f42ade86ad2c2a Mon Sep 17 00:00:00 2001 From: Kishan Gajjar Date: Mon, 20 Feb 2017 11:45:08 +0530 Subject: [PATCH] [IMP] point_of_sale(_restaurant): Add some small UX improvements [IMP] point_of_sale: Improve `New Session` button label if already opened When another user has a POS session open. Do not show the New Sesson button on the dashboard. Hide it and replace it by the string 'A session is already opened' [IMP] pos_restaurant: Move some technical fields in debug mode [IMP] point_of_sale: Remove tooltip for barcode [IMP] point_of_sale: All to restict product price control to managers Either: - Everybody - Only managers should be able to modify the product price on orders for a given point of sale [IMP] pos_restaurant: Exit table edit mode via 'ESC' button of keyboard --- addons/point_of_sale/models/pos_config.py | 2 ++ addons/point_of_sale/models/pos_session.py | 2 +- addons/point_of_sale/models/res_partner.py | 2 +- addons/point_of_sale/static/src/css/pos.css | 5 +++++ addons/point_of_sale/static/src/js/chrome.js | 1 + addons/point_of_sale/static/src/js/models.js | 3 +++ addons/point_of_sale/static/src/js/screens.js | 5 +++++ addons/point_of_sale/views/point_of_sale_dashboard.xml | 5 ++++- addons/point_of_sale/views/pos_config_view.xml | 1 + addons/pos_restaurant/static/src/js/floors.js | 8 ++++++++ addons/pos_restaurant/views/pos_restaurant_views.xml | 4 ++-- 11 files changed, 33 insertions(+), 5 deletions(-) diff --git a/addons/point_of_sale/models/pos_config.py b/addons/point_of_sale/models/pos_config.py index 355c35d6ca5..05259bd89a3 100644 --- a/addons/point_of_sale/models/pos_config.py +++ b/addons/point_of_sale/models/pos_config.py @@ -98,6 +98,8 @@ class PosConfig(models.Model): help='The point of sale will display this product category by default. If no category is specified, all available products will be shown') iface_display_categ_images = fields.Boolean(string='Display Category Pictures', help="The product categories will be displayed with pictures.") + restrict_price_control = fields.Boolean(string='Restrict Price Modifications to Managers', + help="Check to box to restrict the price control to managers only on point of sale orders.") cash_control = fields.Boolean(string='Cash Control', help="Check the amount of the cashbox at opening and closing.") receipt_header = fields.Text(string='Receipt Header', help="A short text that will be inserted as a header in the printed receipt") receipt_footer = fields.Text(string='Receipt Footer', help="A short text that will be inserted as a footer in the printed receipt") diff --git a/addons/point_of_sale/models/pos_session.py b/addons/point_of_sale/models/pos_session.py index 34f57c0998f..09400db3f46 100644 --- a/addons/point_of_sale/models/pos_session.py +++ b/addons/point_of_sale/models/pos_session.py @@ -155,7 +155,7 @@ class PosSession(models.Model): ('config_id', '=', self.config_id.id), ('rescue', '=', False) ]) > 1: - raise ValidationError(_("You cannot create two active sessions related to the same point of sale!")) + raise ValidationError(_("Another session is already opened for this point of sale.")) @api.model def create(self, values): diff --git a/addons/point_of_sale/models/res_partner.py b/addons/point_of_sale/models/res_partner.py index 238fdbdeb8e..8ac23e6bf1a 100644 --- a/addons/point_of_sale/models/res_partner.py +++ b/addons/point_of_sale/models/res_partner.py @@ -6,7 +6,7 @@ from odoo import api, fields, models class ResPartner(models.Model): _inherit = 'res.partner' - barcode = fields.Char(string='Barcode', help="BarCode", oldname='ean13') + barcode = fields.Char(string='Barcode', oldname='ean13') pos_order_count = fields.Integer( compute='_compute_pos_order', help="The number of point of sales orders related to this customer", diff --git a/addons/point_of_sale/static/src/css/pos.css b/addons/point_of_sale/static/src/css/pos.css index 5076972a3e5..a07f7eb85e0 100644 --- a/addons/point_of_sale/static/src/css/pos.css +++ b/addons/point_of_sale/static/src/css/pos.css @@ -771,6 +771,11 @@ td { color: white; border-color: transparent; } +.pos .numpad .disabled-mode, .pos .numpad .disabled-mode:hover { + background: #c7c7c7; + color: #a5a1a1; + cursor: not-allowed; +} /* ********* The right pane contains the screens and headers ********* */ diff --git a/addons/point_of_sale/static/src/js/chrome.js b/addons/point_of_sale/static/src/js/chrome.js index fe16f0bfa48..96f0e8df585 100644 --- a/addons/point_of_sale/static/src/js/chrome.js +++ b/addons/point_of_sale/static/src/js/chrome.js @@ -103,6 +103,7 @@ 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(); }); }, diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index 846f1af339e..ff336551bab 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -1429,6 +1429,9 @@ 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); diff --git a/addons/point_of_sale/static/src/js/screens.js b/addons/point_of_sale/static/src/js/screens.js index cc7b9f7506d..e053264277b 100644 --- a/addons/point_of_sale/static/src/js/screens.js +++ b/addons/point_of_sale/static/src/js/screens.js @@ -364,6 +364,7 @@ var NumpadWidget = PosBaseWidget.extend({ this.state = new models.NumpadState(); }, start: function() { + this.check_price_control_rights(); this.state.bind('change:mode', this.changedMode, this); this.changedMode(); this.$el.find('.numpad-backspace').click(_.bind(this.clickDeleteLastChar, this)); @@ -371,6 +372,10 @@ var NumpadWidget = PosBaseWidget.extend({ 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); + }, clickDeleteLastChar: function() { return this.state.deleteLastChar(); }, diff --git a/addons/point_of_sale/views/point_of_sale_dashboard.xml b/addons/point_of_sale/views/point_of_sale_dashboard.xml index 496f1d15ac7..740262212f5 100644 --- a/addons/point_of_sale/views/point_of_sale_dashboard.xml +++ b/addons/point_of_sale/views/point_of_sale_dashboard.xml @@ -73,7 +73,10 @@ - + + + +
diff --git a/addons/point_of_sale/views/pos_config_view.xml b/addons/point_of_sale/views/pos_config_view.xml index 77df7026c8c..31c7e0526dc 100644 --- a/addons/point_of_sale/views/pos_config_view.xml +++ b/addons/point_of_sale/views/pos_config_view.xml @@ -39,6 +39,7 @@ + diff --git a/addons/pos_restaurant/static/src/js/floors.js b/addons/pos_restaurant/static/src/js/floors.js index 2494401ff00..e22cb8e3bde 100644 --- a/addons/pos_restaurant/static/src/js/floors.js +++ b/addons/pos_restaurant/static/src/js/floors.js @@ -640,6 +640,14 @@ var FloorScreenWidget = screens.ScreenWidget.extend({ this.table_widgets.push(tw); } + $('body').on('keyup', function (event) { + if (event.which === $.ui.keyCode.ESCAPE) { + if(self.editing) { + self.toggle_editing(); + } + } + }); + this.$('.floor-selector .button').click(function(event){ self.click_floor_button(event,$(this)); }); diff --git a/addons/pos_restaurant/views/pos_restaurant_views.xml b/addons/pos_restaurant/views/pos_restaurant_views.xml index 390417a019d..7f2719f3234 100644 --- a/addons/pos_restaurant/views/pos_restaurant_views.xml +++ b/addons/pos_restaurant/views/pos_restaurant_views.xml @@ -11,7 +11,7 @@ - + @@ -81,7 +81,7 @@ - +