From 437116f3c43d4d97b2c2bd6d3f7a39ffd6c7d844 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 11 Jul 2014 11:39:32 +0200 Subject: [PATCH] [FIX] orm: custom m2m with different label At rev 84e9a67cdf78db94cb7a09543c1b7ac4ad19d8b4 a check to avoid the creation of ir.model.relation for custom modules was added. The condition is not correct as based on the string instead of the field name. We do not have access to column name at this level but the the m2m relation table do start with x_ for custom fields (see __init__ method). --- openerp/osv/orm.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index 1f2823b7919..0a38ccf03d4 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -3387,7 +3387,8 @@ class BaseModel(object): m2m_tbl, col1, col2 = f._sql_names(self) # do not create relations for custom fields as they do not belong to a module # they will be automatically removed when dropping the corresponding ir.model.field - if not f.string.startswith('x_'): + # table name for custom relation all starts with x_, see __init__ + if not m2m_tbl.startswith('x_'): self._save_relation_table(cr, m2m_tbl) cr.execute("SELECT relname FROM pg_class WHERE relkind IN ('r','v') AND relname=%s", (m2m_tbl,)) if not cr.dictfetchall():