diff options
| author | Stephane Wirtel <stephane@tinyerp.com> | 2009-01-28 16:42:52 +0100 |
|---|---|---|
| committer | Stephane Wirtel <stephane@tinyerp.com> | 2009-01-28 16:42:52 +0100 |
| commit | 99d7959dff64dfbc75ff923b4d9acfdf11d3e95d (patch) | |
| tree | 8588211f61ebd4b86b8570b45cb63cbd3a75c0ed /bin | |
| parent | 3a7c9de403f3bc46502e4b028017a03d8bb276a1 (diff) | |
[FIX] Use the notation for the default values of a many2many field
lp bug: https://launchpad.net/bugs/319257 fixed
bzr revid: stephane@tinyerp.com-20090128154252-4ibps4vcgltfk02s
Diffstat (limited to 'bin')
| -rw-r--r-- | bin/osv/orm.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/bin/osv/orm.py b/bin/osv/orm.py index 97a422856a7..5f74204aa62 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -458,8 +458,7 @@ class orm_template(object): datas += self.__export_row(cr, uid, row, fields, context) return datas - def import_data(self, cr, uid, fields, datas, mode='init', - current_module=None, noupdate=False, context=None, filename=None): + def import_data(self, cr, uid, fields, datas, mode='init', current_module=None, noupdate=False, context=None, filename=None): if not context: context = {} fields = map(lambda x: x.split('/'), fields) @@ -757,8 +756,7 @@ class orm_template(object): # call the 'dynamic selection' function res[f]['selection'] = self._columns[f].selection(self, cr, user, context) - if res[f]['type'] in ('one2many', 'many2many', - 'many2one', 'one2one'): + if res[f]['type'] in ('one2many', 'many2many', 'many2one', 'one2one'): res[f]['relation'] = self._columns[f]._obj res[f]['domain'] = self._columns[f]._domain res[f]['context'] = self._columns[f]._context @@ -2342,7 +2340,13 @@ class orm(orm_template): default.append(f) if len(default): - vals.update(self.default_get(cr, user, default, context)) + default_values = self.default_get(cr, user, default, context) + for dv in default_values: + if dv in self._columns and self._columns[dv]._type == 'many2many': + if default_values[dv] and isinstance(default_values[dv][0], (int, long)): + default_values[dv] = [(6, 0, default_values[dv])] + + vals.update(default_values) tocreate = {} for v in self._inherits: |
