xml - OpenERP How to make a button invisible when datetime field != date today -
in python, have next field:
'transaction_date': fields.datetime('transaction date')
in xml, have following:
<field name="transaction_date" readonly="true" /> <button name="set_void" string="void" type="object" icon="gtk-cancel" groups="mymodule.mygroup" attrs="{'invisible':[('transaction_date','!=', datetime.now())]}" />
the attrs code above doesn't work want is: able show "void" button when transaction_date field's date value = today. possible?
if using v7, seek attrs:
attrs="{'invisible':[('transaction_date','!=',__import__('time').strftime('%%y-%%m-%%d %%h:%%m:%%s'))]}"
if using v6 or v6.1, seek attrs:
attrs="{'invisible':[('transaction_date','!=',time.strftime('%%y-%%m-%%d %%h:%%m:%%s'))]}"
i suggest you should usefields.date
instead of fields.datetime
because field not visible in datetime format because whenever select date & time, seconds not match.
if utilize fields.date utilize time.strftime('%%y-%%m-%%d')
in attrs.
thank you.
xml openerp
No comments:
Post a Comment