[MERGE]Lunch
bzr revid: api@openerp.com-20121024153323-pl7qwzxjr33zth5h
This commit is contained in:
parent
0ac6c9eff2
commit
3351fb2ff6
|
@ -185,46 +185,42 @@ class lunch_order(osv.Model):
|
|||
def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False):
|
||||
res = super(lunch_order,self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu)
|
||||
if view_type == 'form':
|
||||
doc = etree.XML(res['arch'])
|
||||
for sheet in doc:
|
||||
elements = sheet.xpath("//group[@name='pref']")
|
||||
for element in elements:
|
||||
pref_ref = self.pool.get("lunch.preference")
|
||||
pref_ids = pref_ref.search(cr,uid,[],context=context)
|
||||
for pref in pref_ref.browse(cr,uid,pref_ids,context):
|
||||
if pref['user_id'].id == uid:
|
||||
function_name = "add_preference_"
|
||||
function_name += str(pref.id)
|
||||
new_element = etree.Element("button")
|
||||
new_element.set('name',function_name)
|
||||
new_element.set('icon','gtk-add')
|
||||
new_element.set('type','object')
|
||||
##### title #####
|
||||
title = etree.Element('h3')
|
||||
title.text = pref['product_name']
|
||||
##### price #####
|
||||
price_element=etree.Element("font")
|
||||
text = "Price: "
|
||||
text+= str(pref['price'])
|
||||
text+= "€ "
|
||||
price_element.text = str(text)
|
||||
##### note #####
|
||||
note = etree.Element('i')
|
||||
note.text = "Note: "+str(pref['note'])
|
||||
##### div #####
|
||||
div_element = etree.Element("group")
|
||||
element.append(div_element)
|
||||
div_element.append(title)
|
||||
div_element.append(etree.Element("br"))
|
||||
div_element.append(price_element)
|
||||
div_element.append(etree.Element("br"))
|
||||
div_element.append(new_element)
|
||||
div_element.append(etree.Element("br"))
|
||||
div_element.append(note)
|
||||
div_element.append(etree.Element("br"))
|
||||
div_element.append(etree.Element("br"))
|
||||
res['arch'] = etree.tostring(doc)
|
||||
return res
|
||||
pref_ref = self.pool.get("lunch.preference")
|
||||
pref_ids = pref_ref.search(cr,uid,[],context=context)
|
||||
text=""
|
||||
for pref in pref_ref.browse(cr,uid,pref_ids,context):
|
||||
if pref['user_id'].id == uid:
|
||||
print "*************TEST***************"
|
||||
res['arch'] = ('''<form string=\"Orders Form\" version=\"7.0\">
|
||||
<header>
|
||||
<field name=\"state\" widget=\"statusbar\" statusbar_visible=\"new,confirmed\" modifiers=\"{"readonly": true}\"/>
|
||||
</header>
|
||||
<sheet>
|
||||
<group>
|
||||
<group>
|
||||
<field name=\"user_id\" modifiers=\"{"readonly": [["state", "not in", ["new"]]], "required": true}\"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name=\"date\" modifiers=\"{"readonly": [["state", "not in", ["new"]]], "required": true}\"/>
|
||||
</group>
|
||||
</group>
|
||||
<img src=\"/lunch/static/src/img/warning.png\" width=\"30\" height=\"30\" class=\"oe_left oe_avatar\" attrs=\"{'invisible': [('state','!=','new')]}\" modifiers=\"{"invisible": [["state", "!=", "new"]]}\"/>
|
||||
<div class=\"oe_title\">
|
||||
<field name=\"alerts\" attrs=\"{'invisible': [('state','!=','new')]}\" modifiers=\"{"invisible": [["state", "!=", "new"]], "readonly": true}\"/>
|
||||
</div>
|
||||
<separator name=\"pref\" string=\"Quick Select a Product\"/>
|
||||
<group name=\"pref\">'''+text+'''
|
||||
</group>
|
||||
<separator string=\"Select Products\"/>
|
||||
<field name=\"products\" colspan=\"4\" nolabel=\"1\" on_change=\"onchange_price(products)\" modifiers=\"{"readonly": [["state", "not in", ["new"]]]}\">
|
||||
</field>
|
||||
<group class=\"oe_subtotal_footer oe_right\">
|
||||
<field name=\"total\" modifiers=\"{"readonly": true}\"/>
|
||||
</group>
|
||||
<br/><br/>
|
||||
</sheet>
|
||||
</form>''')
|
||||
print res['arch']
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
|
@ -470,4 +466,3 @@ class lunch_validation(osv.Model):
|
|||
if isconfirmed == True:
|
||||
orders_ref.write(cr,uid,[order.order_id.id],{'state':'confirmed'},context)
|
||||
return {}
|
||||
|
|
@ -287,38 +287,38 @@
|
|||
<field name="name">Orders Form</field>
|
||||
<field name="model">lunch.order</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Orders Form" version="7.0">
|
||||
<form string='Orders Form' version='7.0'>
|
||||
<header>
|
||||
<field name="state" widget="statusbar" statusbar_visible="new,confirmed"/>
|
||||
<field name='state' widget='statusbar' statusbar_visible='new,confirmed'/>
|
||||
</header>
|
||||
<sheet>
|
||||
<group>
|
||||
<group>
|
||||
<field name="user_id"/>
|
||||
<field name='user_id'/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="date"/>
|
||||
<field name='date'/>
|
||||
</group>
|
||||
</group>
|
||||
<img src="/lunch/static/src/img/warning.png" width="30" height="30" class="oe_left oe_avatar" attrs="{'invisible': [('state','!=','new')]}"/>
|
||||
<div class="oe_title">
|
||||
<field name="alerts" attrs="{'invisible': [('state','!=','new')]}"/>
|
||||
<img src='/lunch/static/src/img/warning.png' width='30' height='30' class='oe_left oe_avatar' attrs="{'invisible': [('state','!=','new')]}"/>
|
||||
<div class='oe_title'>
|
||||
<field name='alerts' attrs="{'invisible': [('state','!=','new')]}"/>
|
||||
</div>
|
||||
<separator name="pref" string="Quick Select a Product"/>
|
||||
<group name="pref">
|
||||
<separator name='pref' string='Quick Select a Product'/>
|
||||
<group name='pref'>
|
||||
</group>
|
||||
<separator string="Select Products"/>
|
||||
<field name="products" colspan="4" nolabel="1" on_change="onchange_price(products)">
|
||||
<tree string="List" editable="bottom">
|
||||
<field name="product" colspan="2" on_change="onchange_price(product)"/>
|
||||
<field name="note" />
|
||||
<separator string='Select Products'/>
|
||||
<field name='products' colspan='4' nolabel='1' on_change='onchange_price(products)'>
|
||||
<tree string='List' editable='bottom'>
|
||||
<field name='product' colspan='2' on_change='onchange_price(product)'/>
|
||||
<field name='note' />
|
||||
<field name='supplier'/>
|
||||
<field name="state" invisible="1"/>
|
||||
<field name="price"/>
|
||||
<field name='state' invisible='1'/>
|
||||
<field name='price'/>
|
||||
</tree>
|
||||
</field>
|
||||
<group class="oe_subtotal_footer oe_right">
|
||||
<field name="total"/>
|
||||
<group class='oe_subtotal_footer oe_right'>
|
||||
<field name='total'/>
|
||||
</group>
|
||||
<br/><br/>
|
||||
</sheet>
|
||||
|
|
Loading…
Reference in New Issue