diff options
| author | Raphael Collet <rco@openerp.com> | 2016-09-15 11:23:11 +0200 |
|---|---|---|
| committer | Raphael Collet <rco@openerp.com> | 2016-09-16 17:35:24 +0200 |
| commit | fa082019a0f36c39ec8c235e812701158bbe1899 (patch) | |
| tree | 822037ab3f737b4be5d15a6d6ef55d31c2946fc4 /odoo/tools/sql.py | |
| parent | fe0478a5c425585af0ca6f0cb728c8a78750519c (diff) | |
[IMP] models: change API of `_group_by_full`
The dictionary `_group_by_full` is replaced by a field parameter `group_expand`
that is assigned to the method name. The API of the method has been simplified
as well:
@api.multi
def _read_group_stage_ids(self, domain, read_group_order=None, access_rights_uid=None):
# the stages are given by self.ids (wrong model);
# read_group_order is the order given to read_group() on self;
# return stages.name_get(), {stage.id: stage.fold)
_group_by_full = {'stage_id': _read_group_stage_ids}
is now written:
stage_id = fields.Many2one(..., group_expand='_read_group_stage_ids')
@api.model
def _read_group_stage_ids(self, stages, domain, order):
# stages is a recordset;
# order is the order to use on stages' model;
# return a recordset which is a superset of stages
Diffstat (limited to 'odoo/tools/sql.py')
| -rw-r--r-- | odoo/tools/sql.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/odoo/tools/sql.py b/odoo/tools/sql.py index 43c54c1a28a..0c67657db8d 100644 --- a/odoo/tools/sql.py +++ b/odoo/tools/sql.py @@ -24,3 +24,12 @@ def pg_varchar(size=0): if size > 0: return 'VARCHAR(%d)' % size return 'VARCHAR' + +def reverse_order(order): + """ Reverse an ORDER BY clause """ + items = [] + for item in order.split(','): + item = item.lower().split() + direction = 'asc' if item[1:] == ['desc'] else 'desc' + items.append('%s %s' % (item[0], direction)) + return ', '.join(items) |
