Merge lp:~0k.io/openobject-server/use-priority-attribute-for-store-function into lp:openobject-server

Proposed by Valentin Lab
Status: Needs review
Proposed branch: lp:~0k.io/openobject-server/use-priority-attribute-for-store-function
Merge into: lp:openobject-server
Diff against target: 12 lines (+1/-1)
1 file modified
openerp/osv/orm.py (+1/-1)
To merge this branch: bzr merge lp:~0k.io/openobject-server/use-priority-attribute-for-store-function
Reviewer Review Type Date Requested Status
Martin Trigaux (OpenERP) (community) Needs Information
Review via email: mp+171499@code.launchpad.net

Description of the change

The priority attribute for field is not used for stored function fields. And as I have several function that rely upon each others, I would like to use it to force their order of calculation, this involves replacing a hardwritten default of "10" for the priority by the currently existing 'priority' attribute.

Is this wrong ? Thanks.

To post a comment you must log in.
Revision history for this message
Martin Trigaux (OpenERP) (mat-openerp) wrote :

Hello,

Not sure I got what you want to achieve. There is no priority attribute on the field definition. The 10 value is when you don't define any trigger, so the priority does not really apply here.
When you define several triggers, you can set a priority. For instance look at the definition of the field planned_hours in the model project.project

'planned_hours': fields.function(_progress_rate, multi="progress", string='Planned Time', help="Sum of planned hours of all tasks related to this project and its child projects.",
    store = {
        'project.project': (_get_project_and_parents, ['tasks', 'parent_id', 'child_ids'], 10),
        'project.task': (_get_projects_from_tasks, ['planned_hours', 'remaining_hours', 'work_ids', 'state'], 20),
    }),

review: Needs Information

Unmerged revisions

4912. By Valentin Lab

new: use ``priority`` attribute for priorisation of store function.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openerp/osv/orm.py'
2--- openerp/osv/orm.py 2013-06-19 09:13:32 +0000
3+++ openerp/osv/orm.py 2013-06-26 10:16:34 +0000
4@@ -996,7 +996,7 @@
5 continue
6 sm = f.store
7 if sm is True:
8- sm = {self._name: (lambda self, cr, uid, ids, c={}: ids, None, 10, None)}
9+ sm = {self._name: (lambda self, cr, uid, ids, c={}: ids, None, f.priority, None)}
10 for object, aa in sm.items():
11 if len(aa) == 4:
12 (fnct, fields2, order, length) = aa