diff options
| author | Christophe Simonis <chs@odoo.com> | 2016-09-22 15:23:45 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2016-09-22 15:23:45 +0200 |
| commit | 856476d4418390ca89ef161e31faf61248eeaa1d (patch) | |
| tree | f87ab29316440a28e9032d1b811eeb7ea5155653 /odoo/models.py | |
| parent | 4b812d9965128b02b4ac5ea49a66da622953cddc (diff) | |
| parent | b1b700adb1f26bb43e8f4b77b85f969a4b52d36c (diff) | |
[MERGE] forward port branch saas-12 up to b1b700a
Diffstat (limited to 'odoo/models.py')
| -rw-r--r-- | odoo/models.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/odoo/models.py b/odoo/models.py index 9c081ff53d0..a912af902c4 100644 --- a/odoo/models.py +++ b/odoo/models.py @@ -377,6 +377,7 @@ class BaseModel(object): cr.execute(query, vals) self.invalidate_cache() + @api.model def _add_field(self, name, field): """ Add the given ``field`` under the given ``name`` in the class """ @@ -536,6 +537,7 @@ class BaseModel(object): '_register': False, '_original_module': cls._module, '_inherit_children': OrderedSet(), # names of children models + '_inherits_children': set(), # names of children models '_fields': {}, # populated in _setup_base() }) check_parent = cls._build_model_check_parent @@ -633,7 +635,11 @@ class BaseModel(object): cls._sequence = cls._sequence or (cls._table + '_id_seq') cls._constraints = cls._constraints.values() - # recompute attributes of children models + # update _inherits_children of parent models + for parent_name in cls._inherits: + pool[parent_name]._inherits_children.add(cls._name) + + # recompute attributes of _inherit_children models for child_name in cls._inherit_children: child_class = pool[child_name] child_class._build_model_attributes(pool) @@ -1933,7 +1939,7 @@ class BaseModel(object): """ result = self._read_group_raw(domain, fields, groupby, offset=offset, limit=limit, orderby=orderby, lazy=lazy) - groupby = [groupby] if isinstance(groupby, basestring) else groupby + groupby = [groupby] if isinstance(groupby, basestring) else list(OrderedSet(groupby)) dt = [ f for f in groupby if self._fields[f.split(':')[0]].type in ('date', 'datetime') @@ -1957,7 +1963,7 @@ class BaseModel(object): query = self._where_calc(domain) fields = fields or [f.name for f in self._fields.itervalues() if f.store] - groupby = [groupby] if isinstance(groupby, basestring) else groupby + groupby = [groupby] if isinstance(groupby, basestring) else list(OrderedSet(groupby)) groupby_list = groupby[:1] if lazy else groupby annotated_groupbys = [self._read_group_process_groupby(gb, query) for gb in groupby_list] groupby_fields = [g['field'] for g in annotated_groupbys] |
