[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
This commit is contained in:
parent
d299567edb
commit
bc40ea4ee9
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue