From a11100adb8304297865668ac999b574055af8ec4 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Mon, 9 Feb 2015 15:43:43 +0100 Subject: [PATCH] [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. --- openerp/fields.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/openerp/fields.py b/openerp/fields.py index 9f7e1fc7755..00ffb293c3e 100644 --- a/openerp/fields.py +++ b/openerp/fields.py @@ -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