Merge lp:~pexego/openobject-server/add_weighted_average_grouping_server into lp:openobject-server
Proposed by
Omar (Pexego)
Status: | Rejected |
---|---|
Rejected by: | Fabien (Open ERP) |
Proposed branch: | lp:~pexego/openobject-server/add_weighted_average_grouping_server |
Merge into: | lp:openobject-server |
Diff against target: |
15 lines (+5/-1) 1 file modified
openerp/osv/orm.py (+5/-1) |
To merge this branch: | bzr merge lp:~pexego/openobject-server/add_weighted_average_grouping_server |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
OpenERP Core Team | Pending | ||
Review via email: mp+98502@code.launchpad.net |
Description of the change
Adds possibility of select a field as group operator to perform weighted average when grouping with four simple lines in orm.py.
example:
_columns = {
...
'price_unit': fields.float('Unit price', digits=(16,2), group_operator=
'product_qty': fields.
...
}
To post a comment you must log in.
Unmerged revisions
- 4101. By Omar (Pexego)
-
[ADD] Adds possibility of select a field as group operator to perform weighted average when grouping
I like very much the simplicity of the code, but I'm concerned about the obfuscated meaning of passing a field name in the group_operator attribute. It really feels like a hack. Could we imagine something more explicit? 'product_ qty' attribute on columns, that will be used to compute the weighted mean when group_operator is sum? "sum/product_ qty", which is relatively easy to parse but carries a clearer meaning?
Some ideas:
- support an additional group_weight=
- use a more verbose syntax for group_operator, for example group_operator=
What do you think?
Side note: read_group() is becoming huge, so it may be a right time to start splitting it into smaller functions if we continue to improve it, but that might go into a separate refactoring