From 3982e3524a1ab8bbe18b931d614fbcb46ece07bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Tue, 17 Jul 2012 16:29:23 +0200 Subject: [PATCH 01/77] [FIX] point_of_sale: various css fixes bzr revid: fva@openerp.com-20120717142923-tk4nkp4mdbegcndi --- addons/point_of_sale/static/src/css/pos.css | 3 +++ addons/point_of_sale/static/src/js/pos_scrollbar_widget.js | 1 + 2 files changed, 4 insertions(+) diff --git a/addons/point_of_sale/static/src/css/pos.css b/addons/point_of_sale/static/src/css/pos.css index 0b92dce6504..d90a12b22eb 100644 --- a/addons/point_of_sale/static/src/css/pos.css +++ b/addons/point_of_sale/static/src/css/pos.css @@ -522,6 +522,7 @@ position:relative; vertical-align: top; display: inline-block; + line-height: 100px; font-size: 11px; margin: 5px; width: 120px; @@ -548,6 +549,7 @@ right: 2px; vertical-align: top; color: white; + line-height: 14px; background: #7f82ac; padding: 2px 5px; border-radius: 3px; @@ -561,6 +563,7 @@ box-sizing: border-box; bottom:0; top:auto; + line-height: 14px; width:100%; background: -webkit-linear-gradient(-90deg,rgba(255,255,255,0),rgba(255,255,255,1), rgba(255,255,255,1)); background: -moz-linear-gradient(-90deg,rgba(255,255,255,0),rgba(255,255,255,1), rgba(255,255,255,1)); diff --git a/addons/point_of_sale/static/src/js/pos_scrollbar_widget.js b/addons/point_of_sale/static/src/js/pos_scrollbar_widget.js index d4f6903c435..7c765028231 100644 --- a/addons/point_of_sale/static/src/js/pos_scrollbar_widget.js +++ b/addons/point_of_sale/static/src/js/pos_scrollbar_widget.js @@ -65,6 +65,7 @@ function openerp_pos_scrollbar(instance, module){ //module is instance.point_of_ this.auto_hide(false); this.$element.bind('mousewheel',function(event,delta){ self.scroll(delta*self.wheel_step); + return false; }); this.$element.bind('click',function(event){ var vpos = event.pageY - self.$element.offset().top; From 1e00d4e9ec1c678f01ea53cb1e53a88b77b975b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Tue, 17 Jul 2012 18:25:17 +0200 Subject: [PATCH 02/77] [IMP] point_of_sale: made it easier to change the flux between screens bzr revid: fva@openerp.com-20120717162517-pjsq3x81zfw38siy --- .../static/src/js/pos_screens.js | 42 +++++++++++++------ .../static/src/js/pos_widgets.js | 10 +++-- 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/addons/point_of_sale/static/src/js/pos_screens.js b/addons/point_of_sale/static/src/js/pos_screens.js index eeb45e8a27d..c89228dcc18 100644 --- a/addons/point_of_sale/static/src/js/pos_screens.js +++ b/addons/point_of_sale/static/src/js/pos_screens.js @@ -349,6 +349,9 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa module.ScaleInviteScreenWidget = module.ScreenWidget.extend({ template:'ScaleInviteScreenWidget', + next_screen:'scale', + previous_screen:'products', + show: function(){ this._super(); var self = this; @@ -359,7 +362,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa var weight = self.pos.proxy.weighting_read_kg(); if(weight > 0.001){ clearInterval(this.intervalID); - self.pos_widget.screen_selector.set_current_screen('scale'); + self.pos_widget.screen_selector.set_current_screen(self.next_screen); } },500); @@ -370,7 +373,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa click: function(){ clearInterval(this.intervalID); self.pos.proxy.weighting_end(); - self.pos_widget.screen_selector.set_current_screen('products'); + self.pos_widget.screen_selector.set_current_screen(self.previous_screen); } } ); @@ -383,6 +386,10 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa module.ScaleScreenWidget = module.ScreenWidget.extend({ template:'ScaleScreenWidget', + + next_screen: 'products', + previous_screen: 'products', + show: function(){ this._super(); this.renderElement(); @@ -392,7 +399,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa label: 'back', icon: '/point_of_sale/static/src/img/icons/png48/go-previous.png', click: function(){ - self.pos_widget.screen_selector.set_current_screen('products'); + self.pos_widget.screen_selector.set_current_screen(self.previous_screen); } }); @@ -401,7 +408,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa icon: '/point_of_sale/static/src/img/icons/png48/validate.png', click: function(){ self.order_product(); - self.pos_widget.screen_selector.set_current_screen('products'); + self.pos_widget.screen_selector.set_current_screen(self.next_screen); }, }); @@ -419,7 +426,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa this._super(); this.$('.product-picture').click(function(){ self.order_product(); - self.pos_widget.screen_selector.set_current_screen('products'); + self.pos_widget.screen_selector.set_current_screen(self.next_screen); }); }, get_product: function(){ @@ -458,6 +465,8 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa module.ClientPaymentScreenWidget = module.ScreenWidget.extend({ template:'ClientPaymentScreenWidget', + next_screen: 'welcome', + previous_screen: 'products', show: function(){ this._super(); var self = this; @@ -486,7 +495,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa self.pos.push_order(currentOrder.exportAsJSON()).then(function() { currentOrder.destroy(); self.pos.proxy.transaction_end(); - self.pos_widget.screen_selector.set_current_screen('welcome'); + self.pos_widget.screen_selector.set_current_screen(self.next_screen); }); }else if(payment === 'payment_rejected'){ clearInterval(this.intervalID); @@ -501,7 +510,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa click: function(){ //TODO Go to ask for weighting screen clearInterval(this.intervalID); self.pos.proxy.payment_canceled(); - self.pos_widget.screen_selector.set_current_screen('products'); + self.pos_widget.screen_selector.set_current_screen(self.previous_screen); } } ); @@ -515,12 +524,14 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa module.WelcomeScreenWidget = module.ScreenWidget.extend({ template:'WelcomeScreenWidget', + next_screen: 'products', + show_numpad: false, show_leftpane: false, barcode_client_action: function(ean){ this._super(ean); - this.pos_widget.screen_selector.set_current_screen('products'); + this.pos_widget.screen_selector.set_current_screen(self.next_screen); }, show: function(){ @@ -532,6 +543,9 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa module.ProductScreenWidget = module.ScreenWidget.extend({ template:'ProductScreenWidget', + scale_screen: 'scale_invite', + client_next_screen: 'client_payment', + show_numpad: true, show_leftpane: true, @@ -543,7 +557,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa this.product_list_widget = new module.ProductListWidget(this,{ click_product_action: function(product){ if(product.get('to_weight') && self.pos.use_scale){ - self.pos_widget.screen_selector.set_current_screen('scale_invite', {product: product}); + self.pos_widget.screen_selector.set_current_screen(self.scale_screen, {product: product}); }else{ self.pos.get('selectedOrder').addProduct(product); } @@ -568,7 +582,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa label: 'pay', icon: '/point_of_sale/static/src/img/icons/png48/go-next.png', click: function(){ - self.pos_widget.screen_selector.set_current_screen('client_payment'); + self.pos_widget.screen_selector.set_current_screen(self.client_next_screen); } }); } @@ -643,6 +657,8 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa module.PaymentScreenWidget = module.ScreenWidget.extend({ template: 'PaymentScreenWidget', + back_screen: 'products', + next_screen: 'receipt', init: function(parent, options) { this._super(parent,options); this.model = options.model; @@ -664,7 +680,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa label: 'Back', icon: '/point_of_sale/static/src/img/icons/png48/go-previous.png', click: function(){ - self.pos_widget.screen_selector.set_current_screen('products'); + self.pos_widget.screen_selector.set_current_screen(self.back_screen); }, }); @@ -682,7 +698,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa this.pos_widget.payment_screen.set_numpad_state(null); }, back: function() { - this.pos_widget.screen_selector.set_current_screen('products'); + this.pos_widget.screen_selector.set_current_screen(self.back_screen); }, validateCurrentOrder: function() { var self = this; @@ -697,7 +713,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa self.pos.proxy.print_receipt(currentOrder.export_for_printing()); self.pos.get('selectedOrder').destroy(); //finish order and go back to scan screen }else{ - self.pos_widget.screen_selector.set_current_screen('receipt'); + self.pos_widget.screen_selector.set_current_screen(self.next_screen); } }); }, diff --git a/addons/point_of_sale/static/src/js/pos_widgets.js b/addons/point_of_sale/static/src/js/pos_widgets.js index b20bee712ee..0ee8cbf519d 100644 --- a/addons/point_of_sale/static/src/js/pos_widgets.js +++ b/addons/point_of_sale/static/src/js/pos_widgets.js @@ -676,6 +676,10 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa self.build_widgets(); + self.screen_selector.set_default_screen(); + + self.pos.barcode_reader.connect(); + instance.webclient.set_content_full_screen(true); if (!self.pos.get('pos_session')) { @@ -700,6 +704,9 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa }); }, + + // This method instantiates all the screens, widgets, etc. If you want to add new screens change the + // startup screen, etc, override this method. build_widgets: function() { // -------- Screens --------- @@ -788,9 +795,6 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa default_mode: this.pos.use_selfcheckout ? 'client' : 'cashier', }); - this.screen_selector.set_default_screen(); - - this.pos.barcode_reader.connect(); }, //FIXME this method is probably not at the right place ... From 3577764184ebe2c6f34e59c8e781f4455882a1a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Tue, 17 Jul 2012 18:26:09 +0200 Subject: [PATCH 03/77] [FIX] point_of_sale: removed auto-installation of the module bzr revid: fva@openerp.com-20120717162609-sj48xe8u8k52v4j2 --- addons/point_of_sale/__openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/point_of_sale/__openerp__.py b/addons/point_of_sale/__openerp__.py index 5e7e5578f72..4c0bb14cc10 100644 --- a/addons/point_of_sale/__openerp__.py +++ b/addons/point_of_sale/__openerp__.py @@ -99,6 +99,6 @@ Main features : 'static/src/css/keyboard.css' ], 'qweb': ['static/src/xml/pos.xml'], - 'auto_install': True, + 'auto_install': False, } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From c94104586517da23fec98b8b50f93fb1ab30556c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Wed, 18 Jul 2012 11:29:54 +0200 Subject: [PATCH 04/77] [IMP] point_of_sale: very very subtle css improvement bzr revid: fva@openerp.com-20120718092954-ww84yaxh1p2cyf1b --- addons/point_of_sale/static/src/css/pos.css | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/point_of_sale/static/src/css/pos.css b/addons/point_of_sale/static/src/css/pos.css index d90a12b22eb..4ec88e02185 100644 --- a/addons/point_of_sale/static/src/css/pos.css +++ b/addons/point_of_sale/static/src/css/pos.css @@ -530,9 +530,9 @@ background:#fff; border: 1px solid #fff; border-radius: 3px; - -webkit-box-shadow: 0px 1px 8px rgba(0,0,0,0.2); - -moz-box-shadow: 0px 1px 8px rgba(0,0,0,0.2); - box-shadow: 0px 1px 8px rgba(0,0,0,0.2); + -webkit-box-shadow: 0px 1px 8px rgba(127,130,172,0.4); + -moz-box-shadow: 0px 1px 8px rgba(127,130,172,0.4); + box-shadow: 0px 1px 8px rgba(127,130,172,0.4); } .point-of-sale .product .product-img { From 6df84daaee48ea46ace902aee121c26aa1b243f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Thu, 19 Jul 2012 17:25:19 +0200 Subject: [PATCH 05/77] [IMP] point_of_sale: removed action bar bzr revid: fva@openerp.com-20120719152519-l6gbweu58fk54ga3 --- addons/point_of_sale/static/src/css/pos.css | 41 +++++++-- .../static/src/js/pos_screens.js | 84 ++++++++++++------ .../static/src/js/pos_widgets.js | 86 ++++++++++++++----- addons/point_of_sale/static/src/xml/pos.xml | 31 ++----- 4 files changed, 163 insertions(+), 79 deletions(-) diff --git a/addons/point_of_sale/static/src/css/pos.css b/addons/point_of_sale/static/src/css/pos.css index 4ec88e02185..b03633e181c 100644 --- a/addons/point_of_sale/static/src/css/pos.css +++ b/addons/point_of_sale/static/src/css/pos.css @@ -156,11 +156,11 @@ } .point-of-sale #rightheader button { - color: black; - height:29px; - margin:2px; + color: #273072; + height:27px; + margin:3px; margin-right:0px; - border: 1px solid black; + border: 1px solid #353A7E; background: #7f82ac; background: -webkit-gradient(linear, left top, left bottom, from(#b2b3d7), to(#7f82ac)); background: -moz-linear-gradient(#b2b3d7, #7f82ac); @@ -187,6 +187,33 @@ font-weight: 900; } +/* c) The session buttons */ + +.point-of-sale #rightheader .header-button{ + float:right; + height:32px; + padding-left:10px; + padding-right:10px; + border-right: 1px solid #3a3a3a; + border-left: 1px solid #3a3a3a; + color:#DDD; + line-height:32px; + text-align:center; + cursor: pointer; + + -webkit-transition-property: background; + -webkit-transition-duration: 0.2s; + -webkit-transition-timing-function: ease-out; +} +.point-of-sale #rightheader .header-button:last-child{ + border-left: 1px solid #3a3a3a; +} +.point-of-sale #rightheader .header-button:hover{ + background: rgba(0,0,0,0.2); + text-shadow: #000 0px 0px 3px; + color:#EEE; +} + /* c) The notifications indicator */ .point-of-sale .oe_pos_synch-notification{ @@ -234,7 +261,8 @@ left:0; width:440px; top:0px; - bottom:105px; + /*bottom:105px;*/ + bottom:0; border-right: solid 1px #CECBCB; background-color: white; } @@ -318,7 +346,8 @@ .point-of-sale #rightpane { position: absolute; top: 0; - bottom: 105px; + /*bottom: 105px;*/ + bottom:0; left: 440px; right: 0; vertical-align: top; diff --git a/addons/point_of_sale/static/src/js/pos_screens.js b/addons/point_of_sale/static/src/js/pos_screens.js index c89228dcc18..93e25ab21dc 100644 --- a/addons/point_of_sale/static/src/js/pos_screens.js +++ b/addons/point_of_sale/static/src/js/pos_screens.js @@ -152,14 +152,6 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa this.pos_widget.screen_selector.show_popup('help'); }, - logout_button_action: function(){ - this.pos_widget.screen_selector.set_user_mode('client'); - }, - - close_button_action: function(){ - this.pos_widget.try_close(); - }, - barcode_product_screen: 'products', //if defined, this screen will be loaded when a product is scanned barcode_product_error_popup: 'error', //if defined, this popup will be loaded when there's an error in the popup @@ -223,6 +215,29 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa } }, + // shows an action bar on the screen. The actionbar is automatically shown when you add a button + // with add_action_button() + show_action_bar: function(){ + this.pos_widget.action_bar.show(); + this.$element.css({'bottom':'105px'}); + }, + + // hides the action bar. The actionbar is automatically hidden when it is empty + hide_action_bar: function(){ + this.pos_widget.action_bar.hide(); + this.$element.css({'bottom':'0px'}); + }, + + // adds a new button to the action bar. The button definition takes three parameters, all optional : + // - label: the text below the button + // - icon: a small icon that will be shown + // - click: a callback that will be executed when the button is clicked. + // the method returns a reference to the button widget, and automatically show the actionbar. + add_action_button: function(button_def){ + this.show_action_bar(); + return this.pos_widget.action_bar.add_new_button(button_def); + }, + // this method shows the screen and sets up all the widget related to this screen. Extend this method // if you want to alter the behavior of the screen. show: function(){ @@ -231,15 +246,30 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa this.$element.show(); } + if(this.pos_widget.action_bar.get_button_count() > 0){ + this.show_action_bar(); + }else{ + this.hide_action_bar(); + } + var self = this; var cashier_mode = this.pos_widget.screen_selector.get_user_mode() === 'cashier'; this.pos_widget.set_numpad_visible(this.show_numpad && cashier_mode); this.pos_widget.set_leftpane_visible(this.show_leftpane); this.pos_widget.set_cashier_controls_visible(cashier_mode); - this.pos_widget.action_bar.set_element_visible('help-button', !cashier_mode, function(){ self.help_button_action(); }); - this.pos_widget.action_bar.set_element_visible('logout-button', cashier_mode && this.pos.use_selfcheckout, function(){ self.logout_button_action(); }); - this.pos_widget.action_bar.set_element_visible('close-button', cashier_mode, function(){ self.close_button_action(); }); + /*this.pos_widget.action_bar.set_element_visible('help-button', !cashier_mode, function(){ self.help_button_action(); });*/ + + if(cashier_mode && this.pos.use_selfcheckout){ + this.pos_widget.client_button.show(); + }else{ + this.pos_widget.client_button.hide(); + } + if(cashier_mode){ + this.pos_widget.close_button.show(); + }else{ + this.pos_widget.close_button.hide(); + } this.pos_widget.username.set_user_mode(this.pos_widget.screen_selector.get_user_mode()); @@ -251,7 +281,6 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa }); }, - // this method is called when the screen is closed to make place for a new screen. this is a good place // to put your cleanup stuff as it is guaranteed that for each show() there is one and only one close() close: function(){ @@ -366,8 +395,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa } },500); - this.pos_widget.action_bar.add_new_button( - { + this.add_action_button({ label: 'back', icon: '/point_of_sale/static/src/img/icons/png48/go-previous.png', click: function(){ @@ -375,8 +403,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa self.pos.proxy.weighting_end(); self.pos_widget.screen_selector.set_current_screen(self.previous_screen); } - } - ); + }); }, close: function(){ this._super(); @@ -395,7 +422,8 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa this.renderElement(); var self = this; - this.pos_widget.action_bar.add_new_button({ + + this.add_action_button({ label: 'back', icon: '/point_of_sale/static/src/img/icons/png48/go-previous.png', click: function(){ @@ -403,7 +431,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa } }); - this.validate_button = this.pos_widget.action_bar.add_new_button({ + this.validate_button = this.add_action_button({ label: 'Validate', icon: '/point_of_sale/static/src/img/icons/png48/validate.png', click: function(){ @@ -465,8 +493,10 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa module.ClientPaymentScreenWidget = module.ScreenWidget.extend({ template:'ClientPaymentScreenWidget', + next_screen: 'welcome', previous_screen: 'products', + show: function(){ this._super(); var self = this; @@ -503,17 +533,15 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa } },500); - this.pos_widget.action_bar.add_new_button( - { + this.add_action_button({ label: 'back', icon: '/point_of_sale/static/src/img/icons/png48/go-previous.png', - click: function(){ //TODO Go to ask for weighting screen + click: function(){ clearInterval(this.intervalID); self.pos.proxy.payment_canceled(); self.pos_widget.screen_selector.set_current_screen(self.previous_screen); } - } - ); + }); }, close: function(){ this._super(); @@ -578,7 +606,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa } if(this.pos_widget.screen_selector.current_mode === 'client'){ - this.pos_widget.action_bar.add_new_button({ + this.add_action_button({ label: 'pay', icon: '/point_of_sale/static/src/img/icons/png48/go-next.png', click: function(){ @@ -618,13 +646,13 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa this._super(); var self = this; - this.pos_widget.action_bar.add_new_button({ + this.add_action_button({ label: 'Print', icon: '/point_of_sale/static/src/img/icons/png48/printer.png', click: function(){ self.print(); }, }); - this.pos_widget.action_bar.add_new_button({ + this.add_action_button({ label: 'Next Order', icon: '/point_of_sale/static/src/img/icons/png48/go-next.png', click: function() { self.finishOrder(); }, @@ -676,7 +704,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa this.set_numpad_state(this.pos_widget.numpad.state); - this.back_button = this.pos_widget.action_bar.add_new_button({ + this.back_button = this.add_action_button({ label: 'Back', icon: '/point_of_sale/static/src/img/icons/png48/go-previous.png', click: function(){ @@ -684,7 +712,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa }, }); - this.validate_button = this.pos_widget.action_bar.add_new_button({ + this.validate_button = this.add_action_button({ label: 'Validate', icon: '/point_of_sale/static/src/img/icons/png48/validate.png', click: function(){ diff --git a/addons/point_of_sale/static/src/js/pos_widgets.js b/addons/point_of_sale/static/src/js/pos_widgets.js index 0ee8cbf519d..a8948437f2c 100644 --- a/addons/point_of_sale/static/src/js/pos_widgets.js +++ b/addons/point_of_sale/static/src/js/pos_widgets.js @@ -112,7 +112,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa template:'OrderWidget', init: function(parent, options) { this._super(parent,options); - this.compact = false; + this.compact = options.compact !== undefined ? options.compact : true; this.set_numpad_state(options.numpadState); this.pos.bind('change:selectedOrder', this.change_selected_order, this); this.bind_orderline_events(); @@ -166,6 +166,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa this._super(); if(!this.compact){ + console.log('not compact'); $('.point-of-sale .order-container').css({'bottom':'0px'}); } @@ -212,6 +213,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa this.$('.summary .value.total').html(this.format_currency(total)); }, set_compact: function(compact){ + console.log('set_compact',compact); if(this.compact !== compact){ this.compact = compact; this.renderElement(); @@ -313,6 +315,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa module.ActionButtonWidget = instance.web.Widget.extend({ template:'ActionButtonWidget', + icon_template:'ActionButtonWidgetWithIcon', init: function(parent, options){ this._super(parent, options); this.label = options.label || 'button'; @@ -320,7 +323,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa this.click_action = options.click; if(options.icon){ this.icon = options.icon; - this.template = 'ActionButtonWidgetWithIcon'; + this.template = this.icon_template; } }, renderElement: function(){ @@ -359,18 +362,20 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa this.button_list = []; return this; }, + get_button_count: function(){ + return this.button_list.length; + }, add_new_button: function(button_options){ - if(arguments.length == 1){ - var button = new module.ActionButtonWidget(this,button_options); - this.button_list.push(button); - button.appendTo($('.pos-actionbar-button-list')); - return button; - }else{ - for(var i = 0; i < arguments.length; i++){ - this.add_new_button(arguments[i]); - } - } - return undefined; + var button = new module.ActionButtonWidget(this,button_options); + this.button_list.push(button); + button.appendTo($('.pos-actionbar-button-list')); + return button; + }, + show:function(){ + this.$element.show(); + }, + hide:function(){ + this.$element.hide(); }, }); @@ -419,14 +424,10 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa this._super(); var hasimages = false; //if none of the subcategories have images, we don't display buttons with icons - console.log('barfoo'); - _.each(this.subcategories, function(category){ if(category.category_image_small){ - console.log("Image:",category.category_image_small); hasimages = true; }else{ - console.log('NoImage:',category.category_image_small); } }); @@ -603,14 +604,35 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa }, }); + module.HeaderButtonWidget = module.PosBaseWidget.extend({ + template: 'HeaderButtonWidget', + init: function(parent, options){ + options = options || {}; + this._super(parent, options); + this.action = options.action; + this.label = options.label; + }, + renderElement: function(){ + var self = this; + this._super(); + if(this.action){ + this.$element.click(function(){ self.action(); }); + } + }, + show: function(){ this.$element.show(); }, + hide: function(){ this.$element.hide(); }, + + }); + + // ---------- Main Point of Sale Widget ---------- // this is used to notify the user that data is being synchronized on the network module.SynchNotificationWidget = module.PosBaseWidget.extend({ template: "SynchNotificationWidget", - init: function(parent,options) { + init: function(parent, options){ options = options || {}; - this._super(parent,options); + this._super(parent, options); }, renderElement: function() { var self = this; @@ -652,6 +674,14 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa this.leftpane_visible = true; this.leftpane_width = '440px'; this.cashier_controls_visible = true; + var degree = 0; + /* + //Epileptic mode + setInterval(function(){ + $('body').css({'-webkit-filter':'sepia('+Math.round(Math.random())+') hue-rotate('+Math.random()*360+'deg) blur('+Math.random()*5+'px)' }); + },100); + */ + }, start: function() { @@ -708,6 +738,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa // This method instantiates all the screens, widgets, etc. If you want to add new screens change the // startup screen, etc, override this method. build_widgets: function() { + var self = this; // -------- Screens --------- @@ -749,13 +780,13 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa // -------- Misc --------- this.notification = new module.SynchNotificationWidget(this,{}); - this.notification.replace(this.$('.placeholder-SynchNotificationWidget')); + this.notification.appendTo(this.$('#rightheader')); this.username = new module.UsernameWidget(this,{}); this.username.replace(this.$('.placeholder-UsernameWidget')); this.action_bar = new module.ActionBarWidget(this); - this.action_bar.appendTo($(".point-of-sale #content")); + this.action_bar.appendTo($(".point-of-sale #rightpane")); this.paypad = new module.PaypadWidget(this, {}); this.paypad.replace($('#placeholder-PaypadWidget')); @@ -770,6 +801,19 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa 'keyboard_model': 'simple' }); this.onscreen_keyboard.appendTo($(".point-of-sale #content")); + + this.close_button = new module.HeaderButtonWidget(this,{ + label:'Close', + action: function(){ self.try_close(); }, + }); + this.close_button.appendTo(this.$('#rightheader')); + + this.client_button = new module.HeaderButtonWidget(this,{ + label:'Self-Checkout', + action: function(){ self.screen_selector.set_user_mode('client'); }, + }); + this.client_button.appendTo(this.$('#rightheader')); + // -------- Screen Selector --------- diff --git a/addons/point_of_sale/static/src/xml/pos.xml b/addons/point_of_sale/static/src/xml/pos.xml index 441189dae24..b690f6ebe6b 100644 --- a/addons/point_of_sale/static/src/xml/pos.xml +++ b/addons/point_of_sale/static/src/xml/pos.xml @@ -15,7 +15,7 @@
    - +
    @@ -44,6 +44,12 @@
    + +
    + +
    +
    +
    There are pending operations that could not be saved into the database, are you sure you want to exit?
    @@ -531,30 +537,7 @@
    -
    -
    -
    - -
    Help
    -
    -
    -
    -
    - -
    Close
    -
    -
    -
    -
    - -
    Client Mode
    -
    -
    -
      -
    From 7a1cee1401bf7c5ea97981a69b4f25a0601ba1bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Fri, 20 Jul 2012 17:24:21 +0200 Subject: [PATCH 06/77] [IMP] point_of_sale: refactored the ean checksum method bzr revid: fva@openerp.com-20120720152421-lfq05r6xkczl1y56 --- addons/product/product.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/addons/product/product.py b/addons/product/product.py index 3cbff880cf9..c50ad3c27b9 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -30,15 +30,10 @@ from tools.translate import _ def is_pair(x): return not x%2 -def check_ean(eancode): - if not eancode: - return True +def ean_checksum(eancode): + """returns the checksum of an ean string of length 13, returns -1 if the string has the wrong length""" if len(eancode) <> 13: - return False - try: - int(eancode) - except: - return False + return -1 oddsum=0 evensum=0 total=0 @@ -54,10 +49,20 @@ def check_ean(eancode): total=(oddsum * 3) + evensum check = int(10 - math.ceil(total % 10.0)) %10 + return check - if check != int(eancode[-1]): +def check_ean(eancode): + """returns True if eancode is a valid ean13 string, or null""" + if not eancode: + return True + if len(eancode) <> 13: return False - return True + try: + int(eancode) + except: + return False + return ean_checksum(eancode) == int(eancode[-1]) + #---------------------------------------------------------- # UOM #---------------------------------------------------------- From f1fbf44b5c9ae1275c9fb9e6a5c1ef8e337742a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Fri, 20 Jul 2012 19:00:12 +0200 Subject: [PATCH 07/77] [WIP] point_of_sale: barcode validation wizard (wip) bzr revid: fva@openerp.com-20120720170012-eqp81clbpbfsr3hl --- addons/point_of_sale/point_of_sale.py | 38 ++++++++++++------ addons/point_of_sale/point_of_sale_view.xml | 44 +++++++++++++++------ addons/product/product.py | 13 ++++++ 3 files changed, 70 insertions(+), 25 deletions(-) diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py index ed3fa9c1730..d86d4c3d8ad 100644 --- a/addons/point_of_sale/point_of_sale.py +++ b/addons/point_of_sale/point_of_sale.py @@ -22,6 +22,7 @@ import pdb import io import openerp import addons +import openerp.addons.product.product import time from datetime import datetime @@ -143,8 +144,6 @@ class pos_config(osv.osv): obj.sequence_id.unlink() return super(pos_config, self).unlink(cr, uid, ids, context=context) -pos_config() - class pos_session(osv.osv): _name = 'pos.session' _order = 'id desc' @@ -425,8 +424,6 @@ class pos_session(osv.osv): 'context' : context, } -pos_session() - class pos_order(osv.osv): _name = "pos.order" _description = "Point of Sale" @@ -1038,8 +1035,6 @@ class pos_order(osv.osv): self.create_account_move(cr, uid, ids, context=context) return True -pos_order() - class account_bank_statement(osv.osv): _inherit = 'account.bank.statement' _columns= { @@ -1138,8 +1133,6 @@ class pos_order_line(osv.osv): }) return super(pos_order_line, self).copy_data(cr, uid, id, default, context=context) -pos_order_line() - class pos_category(osv.osv): _name = 'pos.category' _description = "Point of Sale Category" @@ -1211,12 +1204,24 @@ class pos_category(osv.osv): # 'category_image': _get_default_image, #} -pos_category() - import io, StringIO +class ean_wizard(osv.osv_memory): + _name = 'pos.ean_wizard' + _columns = { + 'ean13_pattern': fields.char('Ean13 Pattern', size=32, required=True, translate=True), + } + def sanitize_ean13(self, cr, uid, ids, context): + for r in self.browse(cr,uid,ids): + ean13 = openerp.addons.product.product.sanitize_ean13(r.ean13_pattern) + m = context.get('active_model') + m_id = context.get('active_id') + self.pool.get(m).write(cr,uid,[m_id],{'ean13':ean13}) + class product_product(osv.osv): _inherit = 'product.product' + + def _get_small_image(self, cr, uid, ids, prop, unknow_none, context=None): result = {} for obj in self.browse(cr, uid, ids, context=context): @@ -1247,7 +1252,16 @@ class product_product(osv.osv): 'to_weight' : False, } -product_product() - + def add_ean13(self, cr, uid, ids, context): + return { + 'name': _('Return Products'), + 'type': 'ir.actions.act_window', + 'view_type': 'form', + 'view_mode': 'form', + 'res_model': 'pos.ean_wizard', + 'target' : 'new', + 'view_id': False, + 'context':context, + } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/point_of_sale/point_of_sale_view.xml b/addons/point_of_sale/point_of_sale_view.xml index f3b491116b7..1145189b408 100644 --- a/addons/point_of_sale/point_of_sale_view.xml +++ b/addons/point_of_sale/point_of_sale_view.xml @@ -618,12 +618,22 @@ form - - - - - - + + + + + + + + + + + + + + +