Odoo Help

Sudhir Arya (ERP Harbor Consulting Services)
On 2/7/13, 3:16 AM

I found solution and it worked for me:

<field name="domain">[('date_from', '&lt;', (context_today()-datetime.timedelta(weeks=1)).strftime('%Y-%m-%d'))]</field>

Hello Sudhir..I had used your code but its giving error like context_today is not defined..My code is <field name="domain">[('date', '=', context_today().strftime('%Y-%m-%d'))]</field>

on 11/28/13, 8:08 AM

Hello, I am getting same issue "NameError: name 'context_today' is not defined." I dont get it why even it might work well at your side. Can help me ?

Denero Team
on 1/18/14, 3:42 AM
On 2/7/13, 1:12 AM

You can try __import__('datetime') instead of datetime.date.today()

Antonin Bourguignon (abo)
On 2/5/13, 11:04 AM

In a XML file, you have to use html entities to express inequality symbols < and > in a domain: respectively &lt; and &gt;.

Also a proper syntax for datetime can be found in a few places with a simple grep, for instance in stock/board_warehouse_view.xml:

<field name="domain">[('type','=','in'),('day','&lt;=', time.strftime('%Y-%m-%d')),('day','&gt;',(context_today()-datetime.timedelta(days=15)).strftime('%Y-%m-%d'))]</field>
Nicolas Bessi
On 2/5/13, 11:12 AM


It won't work, the domain is not aware of datetime.

In V7.0 you have to use the code directive of action: `<record id="ir_actions_server_timsheet_sheet" model="ir.actions.server">

        <field name="sequence" eval="5"/>
        <field name="state">code</field>
        <field name="type">ir.actions.server</field>
        <field name="model_id" ref="model_hr_timesheet_current_open"/>
        <field name="code">action = pool.get('hr.timesheet.current.open').open_timesheet(cr, uid, None, context)</field>
        <field name="condition">True</field>
        <field name="name">My Timesheet</field>


Thank you for you answer. But can you please explain how can I achieve my requirement?

Sudhir Arya (ERP Harbor Consulting Services)
on 2/6/13, 12:33 AM

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)


Asked: 2/5/13, 9:38 AM
Seen: 10200 times
Last updated: 9/30/17, 6:21 AM