Reputation:
I am using OpenERP-7.0 and Ubuntu-10.04.
Following code is working fine in 6.0 & 6.1 but it's giving error in 7.0
Here is my code:
<record model="ir.actions.act_window" id="action_leave_not_accounted">
<field name="name">Leaves to be Accounted</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">hr.holidays</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('date_from','>=',(datetime.date.today()-relativedelta(weeks=1)).strftime('Y-%m-%d')),('holiday_status_id.name','in',['Annual','Termination','Resignation'])]</field>
<field name="view_id" ref="hr_holidays.view_holiday_simple"/>
</record>
I am facing following error:
7.0/server/openerp/tools/safe_eval.py", line 241, in safe_eval
return eval(test_expr(expr, _SAFE_OPCODES, mode=mode), globals_dict, locals_dict)
File "", line 1, in <module>
NameError: name 'datetime' is not defined
Can anyone please help me?
Thanks in advance.
Upvotes: 2
Views: 1545
Reputation: 3743
Try this it will work:
<field name="domain">[('date_from', '<', (context_today()-datetime.timedelta(weeks=1)).strftime('%Y-%m-%d'))]</field>
Upvotes: 0
Reputation: 101
You can use only time in XML Parsing.
[('date','<',time.strftime('%Y-%m-%d %H:%M:%S'))]
So you have revised your code from V6.1 to V7.0
Upvotes: 2