[FIX] base: no crash when setting wrong relation to m2m
Before this rev., in the ir.model.fields form view, it crashed when the user specified an invalid model name as a relation for fields of type many2many (the onchange crashed). This rev. displays a warning instead. opw 1837401
This commit is contained in:
@@ -376,6 +376,13 @@ class ir_model_fields(osv.osv):
|
||||
def _onchange_ttype(self):
|
||||
self.copy = (self.ttype != 'one2many')
|
||||
if self.ttype == 'many2many' and self.model_id and self.relation:
|
||||
if self.relation not in self.env:
|
||||
return {
|
||||
'warning': {
|
||||
'title': _('Model %s does not exist' % self.relation),
|
||||
'message': _('Please specify a valid model for the object relation'),
|
||||
}
|
||||
}
|
||||
names = self._custom_many2many_names(self.model_id.model, self.relation)
|
||||
self.relation_table, self.column1, self.column2 = names
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user