Hello,
In V8, I have an action on which I'd like to use a comparison with current date :
<record id="action_rez_by_date" model="ir.actions.act_window">
<field name="name">Réservations en cours (j/j+1/j+2/j+3)</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sale.order</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form,calendar,graph</field>
<field name="domain">[('occupation_date_in','>',time.strftime('%Y-%m-%d'))]</field>
occupation_date_in is declared as following
_columns = {
'occupation_date_in': fields.date('Rental date in', readonly=True, states={'draft': [('readonly', False)],'sent': [('readonly', False)],'progress': [('readonly', False)],'manual': [('readonly', False)]}),
}
After restarting Odoo and refreshing the view, I get the following message :
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 530, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 567, in dispatch
result = self._call_function(**self.params)
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 303, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/openerp/service/model.py", line 113, in wrapper
return f(dbname, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 300, in checked_call
return self.endpoint(*a, **kw)
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 796, in __call__
return self.method(*args, **kw)
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 396, in response_wrap
response = f(*args, **kw)
File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 869, in load_needaction
return request.session.model('ir.ui.menu').get_needaction_data(menu_ids, request.context)
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 900, in proxy
result = meth(cr, request.uid, *args, **kw)
File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper
return old_api(self, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/openerp/addons/base/ir/ir_ui_menu.py", line 341, in get_needaction_data
dom = menu.action.domain and eval(menu.action.domain, {'uid': uid}) or []
File "/usr/lib/python2.7/dist-packages/openerp/tools/safe_eval.py", line 314, in safe_eval
return eval(c, globals_dict, locals_dict)
File "", line 1, in <module>
ValueError: "name 'time' is not defined" while evaluating
u"[('occupation_date_in','>',time.strftime('%Y-%m-%d'))]"
This kind of comparison is used in many places in odoo modules, what's wrong?
Thanks,
David
have you putted "import time" at beginning of the file???