From bc40ea4ee95e894509eba03963f5cec6b703ece4 Mon Sep 17 00:00:00 2001 From: Arnaud Pineux Date: Wed, 9 Jan 2013 12:08:20 +0100 Subject: [PATCH 1/5] [FIX] The lunch 'history' or 'preferences' didn't show the last order. It now shows the 5 last orders of every product category bzr revid: api@openerp.com-20130109110820-fq4iae12p5sg4lam --- addons/lunch/lunch.py | 85 ++++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 41 deletions(-) diff --git a/addons/lunch/lunch.py b/addons/lunch/lunch.py index f61ecc8eb7d..3883a98d553 100644 --- a/addons/lunch/lunch.py +++ b/addons/lunch/lunch.py @@ -168,7 +168,7 @@ class lunch_order(osv.Model): line_ref = self.pool.get("lunch.order.line") if view_type == 'form': doc = etree.XML(res['arch']) - pref_ids = line_ref.search(cr, uid, [('user_id', '=', uid)], order='create_date desc', context=context) + pref_ids = line_ref.search(cr, uid, [('user_id', '=', uid)], order='id desc', context=context) xml_start = etree.Element("div") #If there are no preference (it's the first time for the user) if len(pref_ids)==0: @@ -222,55 +222,58 @@ class lunch_order(osv.Model): xml_pref_1.append(xml_pref_2) i = 0 value = value.values() + sorted_values = {} for val in value: - for pref in val.values(): - #We only show 5 preferences per category (or it will be too long) - if i==5: break - i+=1 - xml_pref_3 = etree.Element("div") - xml_pref_3.set('class','oe_lunch_vignette') - xml_pref_1.append(xml_pref_3) + for elmt in val.values(): + sorted_values[elmt.id]=elmt + for key, pref in sorted(sorted_values.iteritems(), key=lambda (k,v): (k,v), reverse=True): + #We only show 5 preferences per category (or it will be too long) + if i==5: break + i+=1 + xml_pref_3 = etree.Element("div") + xml_pref_3.set('class','oe_lunch_vignette') + xml_pref_1.append(xml_pref_3) - xml_pref_4 = etree.Element("span") - xml_pref_4.set('class','oe_lunch_button') - xml_pref_3.append(xml_pref_4) + xml_pref_4 = etree.Element("span") + xml_pref_4.set('class','oe_lunch_button') + xml_pref_3.append(xml_pref_4) - xml_pref_5 = etree.Element("button") - xml_pref_5.set('name',"add_preference_"+str(pref.id)) - xml_pref_5.set('class','oe_link oe_i oe_button_plus') - xml_pref_5.set('type','object') - xml_pref_5.set('string','+') - xml_pref_4.append(xml_pref_5) + xml_pref_5 = etree.Element("button") + xml_pref_5.set('name',"add_preference_"+str(pref.id)) + xml_pref_5.set('class','oe_link oe_i oe_button_plus') + xml_pref_5.set('type','object') + xml_pref_5.set('string','+') + xml_pref_4.append(xml_pref_5) - xml_pref_6 = etree.Element("button") - xml_pref_6.set('name',"add_preference_"+str(pref.id)) - xml_pref_6.set('class','oe_link oe_button_add') - xml_pref_6.set('type','object') - xml_pref_6.set('string',_("Add")) - xml_pref_4.append(xml_pref_6) + xml_pref_6 = etree.Element("button") + xml_pref_6.set('name',"add_preference_"+str(pref.id)) + xml_pref_6.set('class','oe_link oe_button_add') + xml_pref_6.set('type','object') + xml_pref_6.set('string',_("Add")) + xml_pref_4.append(xml_pref_6) - xml_pref_7 = etree.Element("div") - xml_pref_7.set('class','oe_group_text_button') - xml_pref_3.append(xml_pref_7) + xml_pref_7 = etree.Element("div") + xml_pref_7.set('class','oe_group_text_button') + xml_pref_3.append(xml_pref_7) - xml_pref_8 = etree.Element("div") - xml_pref_8.set('class','oe_lunch_text') - xml_pref_8.text = escape(pref.product_id.name)+str(" ") - xml_pref_7.append(xml_pref_8) + xml_pref_8 = etree.Element("div") + xml_pref_8.set('class','oe_lunch_text') + xml_pref_8.text = escape(pref.product_id.name)+str(" ") + xml_pref_7.append(xml_pref_8) - price = pref.product_id.price or 0.0 - cur = currency.name or '' - xml_pref_9 = etree.Element("span") - xml_pref_9.set('class','oe_tag') - xml_pref_9.text = str(price)+str(" ")+cur - xml_pref_8.append(xml_pref_9) + price = pref.product_id.price or 0.0 + cur = currency.name or '' + xml_pref_9 = etree.Element("span") + xml_pref_9.set('class','oe_tag') + xml_pref_9.text = str(price)+str(" ")+cur + xml_pref_8.append(xml_pref_9) - xml_pref_10 = etree.Element("div") - xml_pref_10.set('class','oe_grey') - xml_pref_10.text = escape(pref.note or '') - xml_pref_3.append(xml_pref_10) + xml_pref_10 = etree.Element("div") + xml_pref_10.set('class','oe_grey') + xml_pref_10.text = escape(pref.note or '') + xml_pref_3.append(xml_pref_10) - xml_start.append(xml_pref_1) + xml_start.append(xml_pref_1) first_node = doc.xpath("//div[@name='preferences']") if first_node and len(first_node)>0: From d4c87342fb89b1a4ddf2c16eb1021cba94114b2c Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Tue, 26 Feb 2013 16:31:09 +0100 Subject: [PATCH 2/5] [FIX] Removes grouping functionality in creating invoices from sales orders and avoids double invoices lp bug: https://launchpad.net/bugs/1092843 fixed bzr revid: jco@openerp.com-20130226153109-xs603vv26vyiuke0 --- addons/sale/wizard/sale_make_invoice.py | 1 - addons/sale/wizard/sale_make_invoice.xml | 11 +++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/addons/sale/wizard/sale_make_invoice.py b/addons/sale/wizard/sale_make_invoice.py index 87911228cb6..2d5bd29b2c2 100644 --- a/addons/sale/wizard/sale_make_invoice.py +++ b/addons/sale/wizard/sale_make_invoice.py @@ -51,7 +51,6 @@ class sale_make_invoice(osv.osv_memory): if context is None: context = {} data = self.read(cr, uid, ids)[0] - order_obj.action_invoice_create(cr, uid, context.get(('active_ids'), []), data['grouped'], date_invoice = data['invoice_date']) wf_service = netsvc.LocalService("workflow") for id in context.get(('active_ids'), []): wf_service.trg_validate(uid, 'sale.order', id, 'manual_invoice', cr) diff --git a/addons/sale/wizard/sale_make_invoice.xml b/addons/sale/wizard/sale_make_invoice.xml index ced64a0f79d..14e11e228bc 100644 --- a/addons/sale/wizard/sale_make_invoice.xml +++ b/addons/sale/wizard/sale_make_invoice.xml @@ -6,16 +6,15 @@ sale.make.invoice
-
-
- +
+
From d90170fae5abeb405ee52755e1f4688cdd73a63c Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Wed, 20 Mar 2013 11:48:53 +0100 Subject: [PATCH 3/5] [FIX] sale: another way to fix the batch invoicing of sale.order that currently create invoices in double bzr revid: qdp-launchpad@openerp.com-20130320104853-odqz2m966igg5ept --- addons/sale/wizard/sale_make_invoice.py | 13 +++++++------ addons/sale/wizard/sale_make_invoice.xml | 1 + 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/addons/sale/wizard/sale_make_invoice.py b/addons/sale/wizard/sale_make_invoice.py index 2d5bd29b2c2..d4757ae43ff 100644 --- a/addons/sale/wizard/sale_make_invoice.py +++ b/addons/sale/wizard/sale_make_invoice.py @@ -20,7 +20,6 @@ from openerp.osv import fields, osv from openerp.tools.translate import _ -from openerp import netsvc class sale_make_invoice(osv.osv_memory): _name = "sale.make.invoice" @@ -40,7 +39,7 @@ class sale_make_invoice(osv.osv_memory): record_id = context and context.get('active_id', False) order = self.pool.get('sale.order').browse(cr, uid, record_id, context=context) if order.state == 'draft': - raise osv.except_osv(_('Warning!'),'You cannot create invoice when sales order is not confirmed.') + raise osv.except_osv(_('Warning!'), 'You cannot create invoice when sales order is not confirmed.') return False def make_invoices(self, cr, uid, ids, context=None): @@ -51,9 +50,11 @@ class sale_make_invoice(osv.osv_memory): if context is None: context = {} data = self.read(cr, uid, ids)[0] - wf_service = netsvc.LocalService("workflow") - for id in context.get(('active_ids'), []): - wf_service.trg_validate(uid, 'sale.order', id, 'manual_invoice', cr) + for sale_order in context.get(('active_ids'), []): + if sale_order.state != 'manual': + raise osv.except_osv(_('Warning!'), "You shouldn't manually invoice the following sale order %s" % (sale_order.name)) + + order_obj.action_invoice_create(cr, uid, context.get(('active_ids'), []), data['grouped'], date_invoice=data['invoice_date']) for o in order_obj.browse(cr, uid, context.get(('active_ids'), []), context=context): for i in o.invoice_ids: @@ -62,7 +63,7 @@ class sale_make_invoice(osv.osv_memory): result = mod_obj.get_object_reference(cr, uid, 'account', 'action_invoice_tree1') id = result and result[1] or False result = act_obj.read(cr, uid, [id], context=context)[0] - result['domain'] = "[('id','in', ["+','.join(map(str,newinv))+"])]" + result['domain'] = "[('id','in', [" + ','.join(map(str, newinv)) + "])]" return result diff --git a/addons/sale/wizard/sale_make_invoice.xml b/addons/sale/wizard/sale_make_invoice.xml index 14e11e228bc..de680feb049 100644 --- a/addons/sale/wizard/sale_make_invoice.xml +++ b/addons/sale/wizard/sale_make_invoice.xml @@ -8,6 +8,7 @@
+