diff options
| author | Raphael Collet <rco@openerp.com> | 2014-11-03 16:00:50 +0100 |
|---|---|---|
| committer | Raphael Collet <rco@openerp.com> | 2014-11-04 13:47:57 +0100 |
| commit | f2e4a10e1a58c932f9a989e642771f5ae75d756a (patch) | |
| tree | b5d933afe79088ecf5b8a5bc9eae957fb8898b0b /addons/share | |
| parent | 0f52e22906a969a8ca3b2c38acddf5bf8a6386be (diff) | |
[IMP] use model._fields instead of model._all_columns to cover all fields
The old-api model._all_columns contains information about model._columns and
inherited columns. This dictionary is missing new-api computed non-stored
fields, and the new field objects provide a more readable api...
This commit contains the following changes:
- adapt several methods of BaseModel to use fields instead of columns and
_all_columns
- copy all semantic-free attributes of related fields from their source
- add attribute 'group_operator' on integer and float fields
- base, base_action_rule, crm, edi, hr, mail, mass_mailing, pad,
payment_acquirer, share, website, website_crm, website_mail: simply use
_fields instead of _all_columns
- base, decimal_precision, website: adapt qweb rendering methods to use fields
instead of columns
Diffstat (limited to 'addons/share')
| -rw-r--r-- | addons/share/wizard/share_wizard.py | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/addons/share/wizard/share_wizard.py b/addons/share/wizard/share_wizard.py index e4c50446ebf..6d3ba0ec31f 100644 --- a/addons/share/wizard/share_wizard.py +++ b/addons/share/wizard/share_wizard.py @@ -384,38 +384,37 @@ class share_wizard(osv.TransientModel): models = [x[1].model for x in relation_fields] model_obj = self.pool.get('ir.model') model_osv = self.pool[model.model] - for colinfo in model_osv._all_columns.itervalues(): - coldef = colinfo.column - coltype = coldef._type + for field in model_osv._fields.itervalues(): + ftype = field.type relation_field = None - if coltype in ttypes and colinfo.column._obj not in models: - relation_model_id = model_obj.search(cr, UID_ROOT, [('model','=',coldef._obj)])[0] + if ftype in ttypes and field.comodel_name not in models: + relation_model_id = model_obj.search(cr, UID_ROOT, [('model','=',field.comodel_name)])[0] relation_model_browse = model_obj.browse(cr, UID_ROOT, relation_model_id, context=context) - relation_osv = self.pool[coldef._obj] + relation_osv = self.pool[field.comodel_name] #skip virtual one2many fields (related, ...) as there is no reverse relationship - if coltype == 'one2many' and hasattr(coldef, '_fields_id'): + if ftype == 'one2many' and field.inverse_name: # don't record reverse path if it's not a real m2o (that happens, but rarely) - dest_model_ci = relation_osv._all_columns - reverse_rel = coldef._fields_id - if reverse_rel in dest_model_ci and dest_model_ci[reverse_rel].column._type == 'many2one': + dest_fields = relation_osv._fields + reverse_rel = field.inverse_name + if reverse_rel in dest_fields and dest_fields[reverse_rel].type == 'many2one': relation_field = ('%s.%s'%(reverse_rel, suffix)) if suffix else reverse_rel local_rel_fields.append((relation_field, relation_model_browse)) for parent in relation_osv._inherits: if parent not in models: parent_model = self.pool[parent] - parent_colinfos = parent_model._all_columns + parent_fields = parent_model._fields parent_model_browse = model_obj.browse(cr, UID_ROOT, model_obj.search(cr, UID_ROOT, [('model','=',parent)]))[0] - if relation_field and coldef._fields_id in parent_colinfos: + if relation_field and field.inverse_name in parent_fields: # inverse relationship is available in the parent local_rel_fields.append((relation_field, parent_model_browse)) else: # TODO: can we setup a proper rule to restrict inherited models # in case the parent does not contain the reverse m2o? local_rel_fields.append((None, parent_model_browse)) - if relation_model_id != model.id and coltype in ['one2many', 'many2many']: + if relation_model_id != model.id and ftype in ['one2many', 'many2many']: local_rel_fields += self._get_recursive_relations(cr, uid, relation_model_browse, - [coltype], relation_fields + local_rel_fields, suffix=relation_field, context=context) + [ftype], relation_fields + local_rel_fields, suffix=relation_field, context=context) return local_rel_fields def _get_relationship_classes(self, cr, uid, model, context=None): |
