[FIX] fields: new-api many2many fields always determine their table and columns

The mechanism to determine the table and column names of new-api many2many
fields only worked for many2many fields created from old-api many2many columns!

This fixes #4851.
This commit is contained in:
Raphael Collet 2015-02-09 15:43:43 +01:00
parent 028458a87f
commit a11100adb8
1 changed files with 5 additions and 3 deletions

View File

@ -1724,10 +1724,12 @@ class Many2many(_RelationalMulti):
def _setup_regular(self, env):
super(Many2many, self)._setup_regular(env)
if not self.relation:
if isinstance(self.column, fields.many2many):
if not self.relation and self.store:
# retrieve self.relation from the corresponding column
column = self.to_column()
if isinstance(column, fields.many2many):
self.relation, self.column1, self.column2 = \
self.column._sql_names(env[self.model_name])
column._sql_names(env[self.model_name])
if self.relation:
m2m = env.registry._m2m