← Back to team overview

c2c-oerpscenario team mailing list archive

[Bug 624509] Re: default date value computed at server startup

 

** Changed in: openobject-addons
   Importance: Undecided => Medium

** Changed in: openobject-addons
       Status: New => Confirmed

** Changed in: openobject-addons
     Assignee: (unassigned) => OpenERP R&D Addons Team 1 (openerp-dev-addons1)

-- 
default date value computed at server startup
https://bugs.launchpad.net/bugs/624509
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to the OpenERP Project Group.

Status in OpenObject Addons Modules: Confirmed

Bug description:
Summary
========
When encoding a new line of "task work" inside the project task, the default date provided is always the same.

Use Case:
========
Start openerp-server, start time is: 2010-08-25 08:00:15
encode a new task work, the default date is: 2010-08-25 08:00:15
5 minutes later, encode a new task work, the default date is still:  2010-08-25 08:00:15

Details
======
The default value for task.work is specified like this:

_defaults = {
    ...
    'date': time.strftime('%Y-%m-%d'),
    ...
}

The problem here, is that the "date" will be computed when the object is instantiated, not when the client request default date. For this kind of default value, we should specify it using the "lambda" way.

Lot of others modules seems to declare default value like this, for example:
...
sale/sale.py:284:        'date_order': time.strftime('%Y-%m-%d'),
...
stock/stock.py:1260:  'date':  time.strftime('%Y-%m-%d %H:%M:%S'),
...

Code Versions
============
Mainline: 6.0
Server: vir@xxxxxxxxxxx-20100819122709-ukhv72chs7t2olsj
Addons: codehost@crowberry-20100826035718-f9pjmr6ydefie407
Client: nch@xxxxxxxxxxx-20100825095238-1lxzqpyzjoc414dq