Comment 13 for bug 925361

Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

The new method is finally called "context_today" to clearly indicate that it will work using the session context.
It was added in server trunk at revision [1] and the main places in addons that should use it were updated at revision [2].

This also leaves an easy path for fixing related minor cases in the future.

Using it as a _defaults initializer is very easy:

 _ defaults = {
    'date_field': fields.date.context_today,
 }

No need to import time or use a lambda anymore...

Thanks everyone who provided feedback!

PS: no similar method fields.datetime.context_now was created because datetime values behave as expected when computed in server time, so it is better to use the existing UTC-based fields.datetime.now (also usable for _defaults)

[1] server trunk r.4050 rev-id: <email address hidden>
[2] addons trunk r.6565 rev-id: <email address hidden>