Comment 12 for bug 1314680

Revision history for this message
Christophe Simonis (OpenERP) (kangol) wrote :

No, stored function fields are not recomputed one at a time.
In 7.0 they are recomputed 40 by 40 [0]. Yes, it may be low but that the default since Feb 2008 [1]. This value has been bump to 1000 in trunk.
One thing that may cause slowness was that, in case of m2o function fields, the name_get() was done id by id. This has been fixed last month in trunk [2]

About, your good example, that's effectively a good example how to NOT do a migration script.
Stored function fields are computed (in batch) in _auto_init(), before init() and also BEFORE migration post- scripts are executed.
Your module is not slow because of this query in init() but because your function field is badly written. You execute a query per id [3] instead of executing a single query with all the ids the ORM give you.

[0] http://bazaar.launchpad.net/~openerp/openobject-server/7.0/view/head:/openerp/osv/orm.py#L82
[1] http://bazaar.launchpad.net/~openerp/openobject-server/trunk/revision/702/bin/osv/orm.py
[2] http://bazaar.launchpad.net/~openerp/openobject-server/trunk/revision/5185/openerp/osv/fields.py
[3] http://bazaar.launchpad.net/~account-report-core-editor/account-financial-report/7.0/view/head:/account_financial_report_webkit/account_move_line.py#L58