summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Dony <odo@openerp.com>2011-09-30 13:23:48 +0200
committerOlivier Dony <odo@openerp.com>2011-09-30 13:23:48 +0200
commitbabb7aa0ecc19f681d6b1b11a9be1f884cbca77e (patch)
treeb814db452d211eca6eb1ec6154fef40aa4c66693
parent0bb9cbd51b98e3db51b4c92b50a1dbf04a9ae206 (diff)
[FIX] fields: m2m SQL names may be dynamic now, care for it in field_to_dict()
Also cleaned up field_to_dict signature and callers to honor conventions. lp bug: https://launchpad.net/bugs/863019 fixed bzr revid: odo@openerp.com-20110930112348-4c8undh1d6h1y3ps
-rw-r--r--openerp/osv/fields.py9
-rw-r--r--openerp/osv/orm.py2
2 files changed, 6 insertions, 5 deletions
diff --git a/openerp/osv/fields.py b/openerp/osv/fields.py
index 6619e66b075..0d60a1cbb95 100644
--- a/openerp/osv/fields.py
+++ b/openerp/osv/fields.py
@@ -1285,7 +1285,7 @@ class property(function):
self.field_id = {}
-def field_to_dict(self, cr, user, context, field):
+def field_to_dict(model, cr, user, field, context=None):
""" Return a dictionary representation of a field.
The string, help, and selection attributes (if any) are untranslated. This
@@ -1308,8 +1308,9 @@ def field_to_dict(self, cr, user, context, field):
res['fnct_inv_arg'] = field._fnct_inv_arg or False
res['func_obj'] = field._obj or False
if isinstance(field, many2many):
- res['related_columns'] = list((field._id1, field._id2))
- res['third_table'] = field._rel
+ (table, col1, col2) = field._sql_names(model)
+ res['related_columns'] = [col1, col2]
+ res['third_table'] = table
for arg in ('string', 'readonly', 'states', 'size', 'required', 'group_operator',
'change_default', 'translate', 'help', 'select', 'selectable'):
if getattr(field, arg):
@@ -1328,7 +1329,7 @@ def field_to_dict(self, cr, user, context, field):
res['selection'] = field.selection
else:
# call the 'dynamic selection' function
- res['selection'] = field.selection(self, cr, user, context)
+ res['selection'] = field.selection(model, cr, user, context)
if res['type'] in ('one2many', 'many2many', 'many2one', 'one2one'):
res['relation'] = field._obj
res['domain'] = field._domain
diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py
index 7e3ffa7fcb0..2a8553e122b 100644
--- a/openerp/osv/orm.py
+++ b/openerp/osv/orm.py
@@ -3136,7 +3136,7 @@ class BaseModel(object):
if allfields and f not in allfields:
continue
- res[f] = fields.field_to_dict(self, cr, user, context, field)
+ res[f] = fields.field_to_dict(self, cr, user, field, context=context)
if not write_access:
res[f]['readonly'] = True