diff --git a/static/src/css/style.css b/static/src/css/style.css index 3457f53..30365f3 100644 --- a/static/src/css/style.css +++ b/static/src/css/style.css @@ -14,12 +14,12 @@ display: flex; align-items: center; background-color: #f1eeef; - margin-top: 65px; + margin-top: 48px; } -.pos .presentation-screen .pos-topheader, -.pos .product-balance-screen .pos-topheader, -.pos .confirmation-screen .pos-topheader{ +.pos .presentation-screen .pos-topheader-bal, +.pos .product-balance-screen .pos-topheader-bal, +.pos .confirmation-screen .pos-topheader-bal{ height: auto !important; background-color: #f1eeef; z-index: 100; @@ -32,7 +32,7 @@ align-items: center; justify-content: center; text-transform: uppercase; - height: 65px; + height: 48px; position: relative; } @@ -40,7 +40,7 @@ margin: 0; } -.pos .pos-topheader-title, .pos .pos-topheader{ +.pos .pos-topheader-title{ position: relative; } @@ -48,17 +48,24 @@ width: 100%; } +.pos .pos-topheader-bal { + position: absolute; + left: 0; + top: 0; + width: 100%; + height: 48px; + margin: 0; + padding: 0; + color: gray; +} + .pos .pos-text { text-align: center; height: 45px; font-size: 30px; } -.pos .pos-content{ - top: 65px; -} - -.pos .pos-logo { +.pos .pos-logo-balance { position: absolute; float: right; right: 10px; @@ -382,4 +389,8 @@ h1.product-name { }*/ .pos .product-balance-screen .product-list-scroller{ padding-bottom: 200px; +} + +.pos .product-balance-screen .categories { + border-bottom: solid 0px rgb(110, 200, 155); } \ No newline at end of file diff --git a/static/src/js/container.js b/static/src/js/container.js index c559813..b3ec9a9 100644 --- a/static/src/js/container.js +++ b/static/src/js/container.js @@ -48,6 +48,7 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require) } }); }, {duration: 500, repeat: true}); + // } } this._super(); @@ -61,61 +62,48 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require) }, set_weight: function(weight){ - if (this.pos.config.balance_id) { - var scale_screen = this.gui.screen_instances['balancescale']; - scale_screen.weight = weight; - scale_screen.$('.weight').text(scale_screen.get_product_weight_string()); - scale_screen.$('.computed-price').text(scale_screen.format_currency(scale_screen.get_product_price() * 0)); - scale_screen.$('.weight-brut').text('0.000 kg'); + var scale_screen = this.gui.screen_instances['balancescale']; + scale_screen.weight = weight; + scale_screen.$('.weight').text(scale_screen.get_product_weight_string()); + scale_screen.$('.computed-price').text(scale_screen.format_currency(scale_screen.get_product_price() * 0)); + scale_screen.$('.weight-brut').text('0.000 kg'); - var container_text = '0.000 kg' - scale_screen.$('.tare-container').text(container_text); - } - else { - this._super(); - } + var container_text = '0.000 kg' + scale_screen.$('.tare-container').text(container_text); }, set_price: function (price) { - if (this.pos.config.balance_id) { - var scale_screen = this.gui.screen_instances['balancescale']; - scale_screen.price = price; - scale_screen.$('.computed-price').text(scale_screen.format_currency(0)); - } - else { - this._super(); - } + var scale_screen = this.gui.screen_instances['balancescale']; + scale_screen.price = price; + scale_screen.$('.computed-price').text(scale_screen.format_currency(0)); }, barcode_container_action: function(code){ var self = this; - if (this.pos.config.balance_id) { - if (self.pos.scan_container(code)) { - var order = this.pos.get_order(); - var selected_orderline = order.get_selected_orderline(); - var container = selected_orderline.get_container(); - // Vérfification: est-ce qu'un container vient d'être utilisé dans l'heure - if (self.pos.scan_container_check(code)){ - var transaction = self.pos.scan_container_check(code); - this.gui.show_popup('doublon-barcode',{ - title: _t('Contenu déjà enregistré récemment:'), - transaction: transaction, - confirm: function(){ - var transaction = self.pos.scan_container_check(code) - self.delete_selected_transaction(transaction, code); - self.gui.show_screen('products-balance', {container: container}); - }, - }); - } else { - self.gui.show_screen('products-balance', {container: container}); - } + if (self.pos.scan_container(code)) { + var order = this.pos.get_order(); + var selected_orderline = order.get_selected_orderline(); + var container = selected_orderline.get_container(); + // Vérfification: est-ce qu'un container vient d'être utilisé dans l'heure + if (self.pos.scan_container_check(code)){ + var transaction = self.pos.scan_container_check(code); + this.gui.show_popup('doublon-barcode',{ + title: _t('Contenu déjà enregistré récemment:'), + transaction: transaction, + confirm: function(){ + var transaction = self.pos.scan_container_check(code) + self.delete_selected_transaction(transaction, code); + self.gui.show_screen('products-balance', {container: container}); + }, + }); } else { - self.gui.show_screen('balancecontainerscale', {barcode: code.base_code}); + self.gui.show_screen('products-balance', {container: container}); } + } else { - this._super(); + self.gui.show_screen('balancecontainerscale', {barcode: code.base_code}); } }, @@ -185,66 +173,61 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require) show: function(){ var self = this; - if (this.pos.config.balance_id) { - var queue = this.pos.proxy_queue; - - this.set_weight(0); - this.renderElement(); - - var container = this.gui.get_current_screen_param('container'); + var queue = this.pos.proxy_queue; - queue.schedule(function () { - return self.pos.proxy.reset_weight().then(function () { - self.set_weight(0); - self.set_price(0); - }); - }, {duration: 500}); + this.set_weight(0); + this.renderElement(); - // format price - var price = this.format_price(this.get_product_price()); - - if (container) { - // format tare - var tare = this.format_tare(container); - queue.schedule(function () { - return self.pos.proxy.scale_read_data_price_tare(price, tare).then(function (scale_answer) { - self.set_weight(scale_answer.weight); - self.set_price(scale_answer.price); - if ((scale_answer.error === '30' || scale_answer.error === '31') && scale_answer.weight !== 0) { - self.gui.show_screen(self.next_screen); - // add product *after* switching screen to scroll properly - self.order_product(); - self.pos.proxy.reset_tare(); - } - }); - }, {duration: 500, repeat: true}); + var container = this.gui.get_current_screen_param('container'); - } else { - queue.schedule(function () { - return self.pos.proxy.scale_read_data_price(price).then(function (scale_answer) { - self.set_weight(scale_answer.weight); - self.set_price(scale_answer.price); - if ((scale_answer.error === '30' || scale_answer.error === '31') && scale_answer.weight !== 0) { - self.gui.show_screen(self.next_screen); - self.create_transaction(); - self.order_product(); - } - }); - }, {duration: 500, repeat: true}); - } - // this._super(); + queue.schedule(function () { + return self.pos.proxy.reset_weight().then(function () { + self.set_weight(0); + self.set_price(0); + }); + }, {duration: 500}); - var self = this; + // format price + var price = this.format_price(this.get_product_price()); - this.$('.next,.add-transaction').click(function(){ - self.create_transaction(); - }); + if (container) { + // format tare + var tare = this.format_tare(container); + queue.schedule(function () { + return self.pos.proxy.scale_read_data_price_tare(price, tare).then(function (scale_answer) { + self.set_weight(scale_answer.weight); + self.set_price(scale_answer.price); + if ((scale_answer.error === '30' || scale_answer.error === '31') && scale_answer.weight !== 0) { + self.gui.show_screen(self.next_screen); + // add product *after* switching screen to scroll properly + self.order_product(); + self.pos.proxy.reset_tare(); + } + }); + }, {duration: 500, repeat: true}); - $("#pos-header-text-peser").removeClass('oe_hidden'); } else { - this._super(); + queue.schedule(function () { + return self.pos.proxy.scale_read_data_price(price).then(function (scale_answer) { + self.set_weight(scale_answer.weight); + self.set_price(scale_answer.price); + if ((scale_answer.error === '30' || scale_answer.error === '31') && scale_answer.weight !== 0) { + self.gui.show_screen(self.next_screen); + self.create_transaction(); + self.order_product(); + } + }); + }, {duration: 500, repeat: true}); } + // this._super(); + + var self = this; + + this.$('.next,.add-transaction').click(function(){ + self.create_transaction(); + }); + $("#pos-header-text-peser").removeClass('oe_hidden'); }, @@ -412,8 +395,11 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require) }); gui.define_screen({ - name:'balancescale', - widget: BalanceScaleScreenWidget, + 'name':'balancescale', + 'widget': BalanceScaleScreenWidget, + 'condition': function(){ + return this.pos.config.balance_id; + }, }); @@ -427,46 +413,47 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require) start: function(){ var self = this; -// var queue = this.pos.proxy_queue; -// -// var container = this.gui.get_current_screen_param('container'); -// -// queue.schedule(function () { -// return self.pos.proxy.reset_weight().then(function () { -// self.set_weight(0); -// self.set_price(0); -// }); -// }, {duration: 500}); -// -// // format price -// var scale_screen = this.gui.screen_instances['balancescale']; -// var price = scale_screen.format_price(scale_screen.get_product_price()); -// // var price = this.format_price(this.get_product_price()); -// -// if (container) { -// // format tare -// var tare = this.format_tare(container); -// queue.schedule(function () { -// return self.pos.proxy.scale_read_data_price_tare(price, tare).then(function (scale_answer) { -// self.set_weight(scale_answer.weight); -// self.set_price(scale_answer.price); -// if ((scale_answer.error === '30' || scale_answer.error === '31') && scale_answer.weight !== 0) { -// self.set_weight(0); -// } -// }); -// }, {duration: 500, repeat: true}); -// -// } else { -// queue.schedule(function () { -// return self.pos.proxy.scale_read_data_price(price).then(function (scale_answer) { -// self.set_weight(scale_answer.weight); -// self.set_price(scale_answer.price); -// if ((scale_answer.error === '30' || scale_answer.error === '31') && scale_answer.weight !== 0) { -// self.set_weight(0); -// } -// }); -// }, {duration: 500, repeat: true}); -// } + var queue = this.pos.proxy_queue; + + var container = this.gui.get_current_screen_param('container'); + + queue.schedule(function () { + return self.pos.proxy.reset_weight().then(function () { + self.set_weight(0); + self.set_price(0); + }); + }, {duration: 500}); + + // format price + var scale_screen = this.gui.screen_instances['balancescale']; + var price = scale_screen.format_price(scale_screen.get_product_price()); + // var price = this.format_price(this.get_product_price()); + + if (container) { + // format tare + var tare = this.format_tare(container); + queue.schedule(function () { + return self.pos.proxy.scale_read_data_price_tare(price, tare).then(function (scale_answer) { + self.set_weight(scale_answer.weight); + self.set_price(scale_answer.price); + if ((scale_answer.error === '30' || scale_answer.error === '31') && scale_answer.weight !== 0) { + self.set_weight(0); + } + }); + }, {duration: 500, repeat: true}); + + } else { + queue.schedule(function () { + return self.pos.proxy.scale_read_data_price(price).then(function (scale_answer) { + self.set_weight(scale_answer.weight); + self.set_price(scale_answer.price); + if ((scale_answer.error === '30' || scale_answer.error === '31') && scale_answer.weight !== 0) { + self.set_weight(0); + } + }); + }, {duration: 500, repeat: true}); + } + // this._super(); this.actionpad = new screens.ActionpadWidget(this,{}); this.actionpad.replace(this.$('.placeholder-ActionpadWidget')); @@ -503,28 +490,28 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require) if (_.size(this.action_buttons)) { this.$('.control-buttons').removeClass('oe_hidden'); } - if (this.pos.config.balance_id) { - var scale_screen = this.gui.screen_instances['balancescale']; + var self = this; - scale_screen.$el.removeClass('oe_hidden'); + var scale_screen = this.gui.screen_instances['balancescale']; - this.product_categories_widget.reset_category(); - this.numpad.state.reset(); + scale_screen.$el.removeClass('oe_hidden'); - this.$('.back').click(function(){ - self.gui.show_screen('presentation'); - }); + this.product_categories_widget.reset_category(); + this.numpad.state.reset(); - // Ajout pour le pb de tare - var container = this.gui.get_current_screen_param('container'); - if (container) { - this.pos.proxy.reset_tare(); - } - // Ajout pour le pb de tare + this.$('.back').click(function(){ + self.gui.show_screen('presentation'); + }); - $("#pos-header-text-prod").removeClass('oe_hidden'); + // Ajout pour le pb de tare + var container = this.gui.get_current_screen_param('container'); + if (container) { + this.pos.proxy.reset_tare(); } + // Ajout pour le pb de tare + + $("#pos-header-text-prod").removeClass('oe_hidden'); }, @@ -535,26 +522,34 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require) var screen = this.gui.screen_instances['products-balance']; }, -// set_weight: function(weight){ -// var scale_screen = this.gui.screen_instances['balancescale']; -// -// var container = this.gui.get_current_screen_param('container'); -// -// scale_screen.weight_container = container.weight; -// scale_screen.weight = weight; -// scale_screen.weight_brut = container.weight + scale_screen.weight; -// scale_screen.$('.weight').text(scale_screen.get_product_weight_string()); -// scale_screen.$('.computed-price').text(scale_screen.format_currency(scale_screen.get_product_price() * 0)); -// scale_screen.$('.weight-brut').text(scale_screen.get_product_weight_string_brut()); -// -// if (container){ -// var container_text = (container.weight || 0).toFixed(3) + ' kg'; -// } -// else{ -// var container_text = '' -// } -// scale_screen.$('.tare-container').text(container_text); -// }, + set_weight: function(weight){ + var scale_screen = this.gui.screen_instances['balancescale']; + + var container = this.gui.get_current_screen_param('container'); + if (container) { + scale_screen.weight_container = container.weight; + scale_screen.weight_brut = container.weight + scale_screen.weight; + } + scale_screen.weight = weight; + scale_screen.$('.weight').text(scale_screen.get_product_weight_string()); + scale_screen.$('.computed-price').text(scale_screen.format_currency(scale_screen.get_product_price() * 0)); + scale_screen.$('.weight-brut').text(scale_screen.get_product_weight_string_brut()); + + if (container){ + var container_text = (container.weight || 0).toFixed(3) + ' kg'; + } + else{ + var container_text = '' + } + scale_screen.$('.tare-container').text(container_text); + }, + + set_price: function (price) { + var scale_screen = this.gui.screen_instances['balancescale']; + scale_screen.price = price; + scale_screen.$('.computed-price').text(scale_screen.format_currency(0)); + }, + click_product: function(product) { var scale_screen = this.gui.screen_instances['balancescale']; @@ -643,7 +638,13 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require) this.pos.proxy_queue.clear(); }, }); - gui.define_screen({name:'products-balance', widget: ProductBalanceScreenWidget}); + gui.define_screen({ + 'name':'products-balance', + 'widget': ProductBalanceScreenWidget, + 'condition': function(){ + return this.pos.config.balance_id; + }, + }); /*--------------------------------------*\ | THE SCALE SCREEN FREE | @@ -667,46 +668,40 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require) show: function(){ var self = this; - if (this.pos.config.balance_id) { - - var queue = this.pos.proxy_queue; - var priceStr = '001000'; // bizerba doesn't accept '000000' as unit price - this.renderElement(); - queue.schedule(function () { - return self.pos.proxy.reset_weight().then(function () { - self.set_weight(0); - }); - }, {duration: 500}); + var queue = this.pos.proxy_queue; + var priceStr = '001000'; // bizerba doesn't accept '000000' as unit price + this.renderElement(); + queue.schedule(function () { + return self.pos.proxy.reset_weight().then(function () { + self.set_weight(0); + }); + }, {duration: 500}); - queue.schedule(function () { - return self.pos.proxy.scale_read_data_price(priceStr).then(function (scale_answer) { - self.set_weight(scale_answer.weight); - if ((scale_answer.error === '30' || scale_answer.error === '31') && scale_answer.weight !== 0) { - self.gui.show_screen(self.next_screen); - if (self.pos.config.is_comptoir) { - self.create_container(); - } + queue.schedule(function () { + return self.pos.proxy.scale_read_data_price(priceStr).then(function (scale_answer) { + self.set_weight(scale_answer.weight); + if ((scale_answer.error === '30' || scale_answer.error === '31') && scale_answer.weight !== 0) { + self.gui.show_screen(self.next_screen); + if (self.pos.config.is_comptoir) { + self.create_container(); } - }); - }, {duration: 500, repeat: true}); - this._super(); - - var self = this; - - this.$('.next,.add-container').click(function(){ - self.create_container(); + } }); + }, {duration: 500, repeat: true}); + this._super(); - if(this.pos.config.iface_vkeyboard && this.chrome.widget.keyboard){ - this.chrome.widget.keyboard.connect($(this.el.querySelector('.container-name input'))); - } + var self = this; - $("#pos-header-text-peser").removeClass('oe_hidden'); - $("#pos-topheader-scale-cont").removeClass('oe_hidden'); - } else { - this._super(); + this.$('.next,.add-container').click(function(){ + self.create_container(); + }); + + if(this.pos.config.iface_vkeyboard && this.chrome.widget.keyboard){ + this.chrome.widget.keyboard.connect($(this.el.querySelector('.container-name input'))); } + $("#pos-header-text-peser").removeClass('oe_hidden'); + $("#pos-topheader-scale-cont").removeClass('oe_hidden'); }, @@ -767,8 +762,11 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require) }); gui.define_screen({ - name:'balancecontainerscale', - widget: BalanceContainerScaleScreenWidget, + 'name':'balancecontainerscale', + 'widget': BalanceContainerScaleScreenWidget, + 'condition': function(){ + return this.pos.config.balance_id; + }, }); @@ -798,25 +796,22 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require) show: function(){ this._super(); var self = this; - if (this.pos.config.balance_id) { - var scale_screen = this.gui.screen_instances['balancescale']; - scale_screen.$el.removeClass('oe_hidden'); - var screen = this.gui.screen_instances['products-balance']; - screen.$el.removeClass('oe_hidden'); - $("#pos-header-text-selec").removeClass('oe_hidden'); - $("#pos-header-text-confirm").addClass('oe_hidden'); - } + + var scale_screen = this.gui.screen_instances['balancescale']; + scale_screen.$el.removeClass('oe_hidden'); + var screen = this.gui.screen_instances['products-balance']; + screen.$el.removeClass('oe_hidden'); + $("#pos-header-text-selec").removeClass('oe_hidden'); + $("#pos-header-text-confirm").addClass('oe_hidden'); }, // this methods hides the screen. It's not a good place to put your cleanup stuff as it is called on the // POS initialization. hide: function(){ this._super(); - if (this.pos.config.balance_id) { - var screen = this.gui.screen_instances['products-balance']; - screen.$el.addClass('oe_hidden'); - $("#pos-header-text-selec").addClass('oe_hidden'); - } + var screen = this.gui.screen_instances['products-balance']; + screen.$el.addClass('oe_hidden'); + $("#pos-header-text-selec").addClass('oe_hidden'); }, }); @@ -888,6 +883,12 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require) scale_screen.$('.tare-container').text(container_text); }, + set_price: function (price) { + var scale_screen = this.gui.screen_instances['balancescale']; + scale_screen.price = price; + scale_screen.$('.computed-price').text(scale_screen.format_currency(0)); + }, + _get_active_pricelist: function(){ var current_order = this.pos.get_order(); var current_pricelist = this.pos.default_pricelist; @@ -926,6 +927,9 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require) gui.define_screen({ 'name': 'confirmation', 'widget': ConfirmationScreen, + 'condition': function(){ + return this.pos.config.balance_id; + }, }); // Add the Presentation to the GUI, and set it as the default screen @@ -936,16 +940,24 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require) this.gui.set_startup_screen('presentation'); } }, + + build_chrome: function() { + this._super(); + if (this.pos.config.balance_id) { + this.$('.pos-topheader').addClass('oe_hidden'); + } + else { + this.$('.pos-topheader-title').addClass('oe_hidden'); + } + }, }); gui.Gui.include({ show_saved_screen: function(order,options) { this._super(); - if (this.pos.config.balance_id) { - options = options || {}; - this.close_popup(); - this.show_screen(this.startup_screen); - } + options = options || {}; + this.close_popup(); + this.show_screen(this.startup_screen); }, }); @@ -954,14 +966,10 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require) chrome.OrderSelectorWidget.include({ hide: function(){ - if (this.pos.config.balance_id) { - this.$el.addClass('oe_invisible'); - } + this.$el.addClass('oe_invisible'); }, show: function(){ - if (this.pos.config.balance_id) { - this.$el.removeClass('oe_invisible'); - } + this.$el.removeClass('oe_invisible'); }, renderElement: function(){ var self = this; @@ -974,6 +982,7 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require) } } }, + }); var CheckBarcodePopupDoublon = popups.extend({ diff --git a/static/src/js/models_and_db.js b/static/src/js/models_and_db.js index 0baae65..5506d2b 100644 --- a/static/src/js/models_and_db.js +++ b/static/src/js/models_and_db.js @@ -158,25 +158,6 @@ odoo.define('vracoop_pos_free_balance_v2.models_and_db_balance', function (requi } }, - // load_placeholder_transactions: function(){ - // var self = this; - // var fields = _.find(this.models,function(model){ - // return model.model === 'pos.transaction'; - // }).fields; - - // var domain = [['barcode', '=', 'CONTAINER']]; - // // no need to load it when active because it is already done in standard - // return rpc.query({ - // model: 'product.product', - // method: 'search_read', - // args: [domain, fields], - // }).then(function(products){ - // self.db.add_products(_.map(products, function (product) { - // return new models.Product({}, product); - // })); - // }); - // }, - }); @@ -293,7 +274,6 @@ odoo.define('vracoop_pos_free_balance_v2.models_and_db_balance', function (requi domain: function(self){ return [['write_date','>',self.db.get_today_date()]]; }, loaded: function(self, transactions){ self.db.add_transactions(transactions); - // return self.load_placeholder_transactions(); }, }); diff --git a/static/src/xml/pos.xml b/static/src/xml/pos.xml index 76bc69d..fe3cc3b 100644 --- a/static/src/xml/pos.xml +++ b/static/src/xml/pos.xml @@ -2,7 +2,7 @@ - +
@@ -11,7 +11,7 @@
-
+
@@ -47,11 +47,11 @@ - + Logo -
+
@@ -152,7 +152,7 @@
-
+
@@ -253,7 +253,7 @@
-
+