trytond-patches/issue5118.diff

28 lines
1.2 KiB
Diff

diff -r 8dec33688c06 trytond/trytond/model/modelsql.py
--- a/trytond/trytond/model/modelsql.py Tue Nov 03 12:20:49 2015 +0100
+++ b/trytond/trytond/model/modelsql.py Wed Nov 11 09:57:58 2015 +0100
@@ -128,6 +128,8 @@
def __register__(cls, module_name):
TableHandler = backend.get('TableHandler')
super(ModelSQL, cls).__register__(module_name)
+ pool = Pool()
+ ModelField = pool.get('ir.model.field')
if cls.table_query():
return
@@ -205,7 +207,13 @@
if isinstance(field, fields.Many2One) \
and field.model_name == cls.__name__ \
and field.left and field.right:
- cls._rebuild_tree(field_name, None, 0)
+ irfields = ModelField.search([
+ ('model.model', '=', field.model_name),
+ ('module', '=', module_name),
+ ('name', 'in', [field.left, field.right]),
+ ])
+ if irfields:
+ cls._rebuild_tree(field_name, None, 0)
for ident, constraint, _ in cls._sql_constraints:
table.add_constraint(ident, constraint)