From 1eedcaedad3a528c6eea48571b9eb215b5a5d225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Wed, 29 Aug 2012 14:56:40 +0200 Subject: [PATCH 01/11] [IMP] point_of_sale: TODO changes bzr revid: fva@openerp.com-20120829125640-5bml13zupja3w30b --- addons/point_of_sale/static/src/js/TODO.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/point_of_sale/static/src/js/TODO.txt b/addons/point_of_sale/static/src/js/TODO.txt index edadbe188ea..5eeb4c2606a 100644 --- a/addons/point_of_sale/static/src/js/TODO.txt +++ b/addons/point_of_sale/static/src/js/TODO.txt @@ -49,9 +49,9 @@ TODO AUG 20 v L'impression est foireuse * CLIENT - - create a new branch + v create a new branch - Self-checkout welcome screen - - removal of products for the root category + ~ removal of products for the root category - Terminal de payement - Code à barres - Vidanges From 846ec67adc911b32712039c09225142195aa70ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Fri, 31 Aug 2012 16:31:59 +0200 Subject: [PATCH 02/11] [WIP] point_of_sale: disable validation button when order not fully paid bzr revid: fva@openerp.com-20120831143159-a64527c3a1a8chk0 --- addons/point_of_sale/static/src/js/screens.js | 2 ++ addons/point_of_sale/static/src/js/widgets.js | 24 ++++++++++++++++--- addons/point_of_sale/static/src/xml/pos.xml | 4 ++-- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/addons/point_of_sale/static/src/js/screens.js b/addons/point_of_sale/static/src/js/screens.js index 4d4e09575ea..ff07da30822 100644 --- a/addons/point_of_sale/static/src/js/screens.js +++ b/addons/point_of_sale/static/src/js/screens.js @@ -735,6 +735,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa this.validate_button = this.add_action_button({ label: 'Validate', + name: 'validation', icon: '/point_of_sale/static/src/img/icons/png48/validate.png', click: function(){ self.validateCurrentOrder(); @@ -806,6 +807,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa this.$('#payment-paid-total').html(paidTotal.toFixed(2)); this.$('#payment-remaining').html(remaining.toFixed(2)); this.$('#payment-change').html(change.toFixed(2)); + this.pos_widget.action_bar.set_button_disabled('validation', remaining > 0); }, set_numpad_state: function(numpadState) { if (this.numpadState) { diff --git a/addons/point_of_sale/static/src/js/widgets.js b/addons/point_of_sale/static/src/js/widgets.js index 5b98865a971..5de1fd8b3fe 100644 --- a/addons/point_of_sale/static/src/js/widgets.js +++ b/addons/point_of_sale/static/src/js/widgets.js @@ -370,14 +370,21 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa this.label = options.label || 'button'; this.rightalign = options.rightalign || false; this.click_action = options.click; + this.disabled = options.disabled || false; if(options.icon){ this.icon = options.icon; this.template = this.icon_template; } }, + set_disabled: function(disabled){ + if(this.disabled != disabled){ + this.disabled = !!disabled; + this.renderElement(); + } + }, renderElement: function(){ this._super(); - if(this.click_action){ + if(this.click_action && !this.disabled){ this.$el.click(_.bind(this.click_action, this)); } }, @@ -388,12 +395,12 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa init: function(parent, options){ this._super(parent,options); this.button_list = []; - this.fake_buttons = {}; + this.buttons = {}; this.visibility = {}; }, set_element_visible: function(element, visible, action){ if(visible != this.visibility[element]){ - this.visibility[element] = visible; + this.visibility[element] = !!visible; if(visible){ this.$('.'+element).show(); }else{ @@ -401,14 +408,22 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa } } if(visible && action){ + this.action[element] = action; this.$('.'+element).off('click').click(action); } }, + set_button_disabled: function(name, disabled){ + var b = this.buttons[name]; + if(b){ + b.set_disabled(disabled); + } + }, destroy_buttons:function(){ for(var i = 0; i < this.button_list.length; i++){ this.button_list[i].destroy(); } this.button_list = []; + this.buttons = {}; return this; }, get_button_count: function(){ @@ -417,6 +432,9 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa add_new_button: function(button_options){ var button = new module.ActionButtonWidget(this,button_options); this.button_list.push(button); + if(button_options.name){ + this.buttons[name] = button; + } button.appendTo(this.$('.pos-actionbar-button-list')); return button; }, diff --git a/addons/point_of_sale/static/src/xml/pos.xml b/addons/point_of_sale/static/src/xml/pos.xml index 81f929d50e2..bbe278758d5 100644 --- a/addons/point_of_sale/static/src/xml/pos.xml +++ b/addons/point_of_sale/static/src/xml/pos.xml @@ -540,7 +540,7 @@ -
  • +
  • @@ -548,7 +548,7 @@ -
  • +
  • From 9cfe5665a5648693547da4bf0b0b9d2fb0547aaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Fri, 31 Aug 2012 16:56:06 +0200 Subject: [PATCH 03/11] [DONE] point_of_sale: disable validation button when order not fully paid bzr revid: fva@openerp.com-20120831145606-nrk44gs60lab4k3l --- addons/point_of_sale/static/src/css/pos.css | 6 ++++-- addons/point_of_sale/static/src/js/screens.js | 6 +++++- addons/point_of_sale/static/src/js/widgets.js | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/addons/point_of_sale/static/src/css/pos.css b/addons/point_of_sale/static/src/css/pos.css index a9baf041942..bfe2ef7f9dc 100644 --- a/addons/point_of_sale/static/src/css/pos.css +++ b/addons/point_of_sale/static/src/css/pos.css @@ -1072,12 +1072,14 @@ -webkit-transition-timing-function: ease-out; } -.point-of-sale .pos-actionbar .button.disabled{ - color:#AAA; +.point-of-sale .pos-actionbar .button.disabled *{ + opacity: 0.5; } .point-of-sale .pos-actionbar .button.disabled:hover{ border: 1px solid #cacaca; border-radius: 4px; + color: #555; + cursor: default; background: #e2e2e2; background: -webkit-linear-gradient(#f0f0f0, #e2e2e2); diff --git a/addons/point_of_sale/static/src/js/screens.js b/addons/point_of_sale/static/src/js/screens.js index ff07da30822..9a2071c6335 100644 --- a/addons/point_of_sale/static/src/js/screens.js +++ b/addons/point_of_sale/static/src/js/screens.js @@ -741,6 +741,8 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa self.validateCurrentOrder(); }, }); + + this.updatePaymentSummary(); }, close: function(){ this._super(); @@ -807,7 +809,9 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa this.$('#payment-paid-total').html(paidTotal.toFixed(2)); this.$('#payment-remaining').html(remaining.toFixed(2)); this.$('#payment-change').html(change.toFixed(2)); - this.pos_widget.action_bar.set_button_disabled('validation', remaining > 0); + if(this.pos_widget.action_bar){ + this.pos_widget.action_bar.set_button_disabled('validation', remaining > 0); + } }, set_numpad_state: function(numpadState) { if (this.numpadState) { diff --git a/addons/point_of_sale/static/src/js/widgets.js b/addons/point_of_sale/static/src/js/widgets.js index 5de1fd8b3fe..6de31c88dfd 100644 --- a/addons/point_of_sale/static/src/js/widgets.js +++ b/addons/point_of_sale/static/src/js/widgets.js @@ -433,7 +433,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa var button = new module.ActionButtonWidget(this,button_options); this.button_list.push(button); if(button_options.name){ - this.buttons[name] = button; + this.buttons[button_options.name] = button; } button.appendTo(this.$('.pos-actionbar-button-list')); return button; From f29be675e2b63a85c0e2d1032fb448dc9714b6a4 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Mon, 3 Sep 2012 11:55:27 +0200 Subject: [PATCH 04/11] [FIX] all image stuff on groups, users, partners bzr revid: fp@tinyerp.com-20120903095527-7rk7wxuldv80fj4v --- openerp/addons/base/res/res_partner.py | 28 ++++++++---------- openerp/addons/base/res/res_users.py | 1 + openerp/addons/base/res/res_users_view.xml | 6 ++-- openerp/addons/base/static/src/img/avatar.png | Bin 10341 -> 22372 bytes .../base/static/src/img/company_image.png | Bin 4127 -> 22053 bytes 5 files changed, 15 insertions(+), 20 deletions(-) diff --git a/openerp/addons/base/res/res_partner.py b/openerp/addons/base/res/res_partner.py index e4d6d0341b0..56cb08fa41d 100644 --- a/openerp/addons/base/res/res_partner.py +++ b/openerp/addons/base/res/res_partner.py @@ -225,14 +225,16 @@ class res_partner(osv.osv): return [context['category_id']] return False - def _get_default_image(self, cr, uid, is_company, context=None): + def _get_default_image(self, cr, uid, is_company, context=None, colorize=False): if is_company: image = open(openerp.modules.get_module_resource('base', 'static/src/img', 'company_image.png')).read() else: from PIL import Image from StringIO import StringIO - from random import random - color = (int(random() * 192 + 32), int(random() * 192 + 32), int(random() * 192 + 32)) + color = (255,255,255) + if colorize: + from random import random + color = (int(random() * 192 + 32), int(random() * 192 + 32), int(random() * 192 + 32)) face = Image.open(openerp.modules.get_module_resource('base', 'static/src/img', 'avatar.png')) avatar = Image.new('RGB', face.size) avatar.paste(color) @@ -240,7 +242,7 @@ class res_partner(osv.osv): buffer = StringIO() avatar.save(buffer, 'PNG') image = buffer.getvalue() - return tools.image_resize_image_big(image.encode('base64')) + return image.encode('base64') _defaults = { 'active': True, @@ -253,9 +255,7 @@ class res_partner(osv.osv): 'is_company': False, 'type': 'default', 'use_parent_address': True, - 'image': lambda self, cr, uid, context: self._get_default_image(cr, uid, False, context), - 'image_small': lambda self, cr, uid, context: self._get_default_image(cr, uid, False, context), - 'image_medium': lambda self, cr, uid, context: self._get_default_image(cr, uid, False, context), + 'image': lambda self, cr, uid, context: self._get_default_image(cr, uid, context.get('default_is_company', False), context), } def copy(self, cr, uid, id, default=None, context=None): @@ -333,9 +333,6 @@ class res_partner(osv.osv): domain_siblings = [('parent_id', '=', vals['parent_id']), ('use_parent_address', '=', True)] update_ids = [vals['parent_id']] + self.search(cr, uid, domain_siblings, context=context) self.update_address(cr, uid, update_ids, vals, context) - if 'image' not in vals : - image_value = self._get_default_image(cr, uid, vals.get('is_company', False) or context.get('default_is_company'), context) - vals.update(tools.image_get_resized_images(image_value, return_big=True)) return super(res_partner,self).create(cr, uid, vals, context=context) def update_address(self, cr, uid, ids, vals, context=None): @@ -379,18 +376,17 @@ class res_partner(osv.osv): email_regex = re.compile('([a-zA-Z0-9._%-]+@[a-zA-Z0-9_-]+\.[a-zA-Z0-9._]{1,8})') contact_regex_res = contact_regex.findall(name) email_regex_res = email_regex.findall(name) + email = False if contact_regex_res: name = contact_regex_res[0][0].rstrip(' ') # remove extra spaces on the right email = contact_regex_res[0][1] - rec_id = self.create(cr, uid, {self._rec_name: name, 'email': email}, context); - return self.name_get(cr, uid, [rec_id], context)[0] elif email_regex_res: email = '%s' % (email_regex_res[0]) - rec_id = self.create(cr, uid, {self._rec_name: email, 'email': email}, context); - return self.name_get(cr, uid, [rec_id], context)[0] else: - rec_id = super(res_partner, self).create(cr, uid, {self._rec_name: name}, context) - return self.name_get(cr, uid, [rec_id], context)[0] + pass + data = {self._rec_name: name, 'email': email} + rec_id = self.create(cr, uid, data, context); + return self.name_get(cr, uid, [rec_id], context)[0] def name_search(self, cr, uid, name, args=None, operator='ilike', context=None, limit=100): if not args: diff --git a/openerp/addons/base/res/res_users.py b/openerp/addons/base/res/res_users.py index ca45f03258c..d0f07daa004 100644 --- a/openerp/addons/base/res/res_users.py +++ b/openerp/addons/base/res/res_users.py @@ -251,6 +251,7 @@ class res_users(osv.osv): 'company_id': _get_company, 'company_ids': _get_companies, 'groups_id': _get_group, + 'image': lambda self, cr, uid, context: self.pool.get('res.partner')._get_default_image(cr, uid, False, context, colorize=True), } def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): diff --git a/openerp/addons/base/res/res_users_view.xml b/openerp/addons/base/res/res_users_view.xml index 9c32d32287c..a1d0b0d5f2e 100644 --- a/openerp/addons/base/res/res_users_view.xml +++ b/openerp/addons/base/res/res_users_view.xml @@ -88,7 +88,7 @@
    - +