Remove order constraint on register ModelSQL
We create the foreign table if needed before adding the foreign key constraint, thus it is no more needed to order the registration of the ModelSQL. issue5682 review32841002
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
* Remove order constraint on register ModelSQL
|
||||
* Add relate from report to translations
|
||||
|
||||
Version 4.2.0 - 2016-11-28
|
||||
|
||||
@@ -188,7 +188,11 @@ class ModelSQL(ModelStorage):
|
||||
if field.model_name in ('res.user', 'res.group'):
|
||||
ref = field.model_name.replace('.', '_')
|
||||
else:
|
||||
ref = pool.get(field.model_name)._table
|
||||
ref_model = pool.get(field.model_name)
|
||||
ref = ref_model._table
|
||||
# Create foreign key table if missing
|
||||
if not TableHandler.table_exist(ref):
|
||||
TableHandler(ref_model)
|
||||
if field_name in ['create_uid', 'write_uid']:
|
||||
# migration from 3.6
|
||||
table.drop_fk(field_name)
|
||||
|
||||
@@ -15,7 +15,6 @@ def register():
|
||||
Group,
|
||||
User,
|
||||
LoginAttempt,
|
||||
Group2,
|
||||
UserAction,
|
||||
UserGroup,
|
||||
Warning_,
|
||||
|
||||
+3
-10
@@ -3,12 +3,10 @@
|
||||
"Group"
|
||||
from itertools import chain
|
||||
from ..model import ModelView, ModelSQL, fields, Unique
|
||||
from ..pool import Pool, PoolMeta
|
||||
from ..pool import Pool
|
||||
from ..tools import grouped_slice
|
||||
|
||||
__all__ = [
|
||||
'Group', 'Group2',
|
||||
]
|
||||
__all__ = ['Group']
|
||||
|
||||
|
||||
class MenuMany2Many(fields.Many2Many):
|
||||
@@ -33,6 +31,7 @@ class Group(ModelSQL, ModelView):
|
||||
"Group"
|
||||
__name__ = "res.group"
|
||||
name = fields.Char('Name', required=True, select=True, translate=True)
|
||||
users = fields.Many2Many('res.user-res.group', 'group', 'user', 'Users')
|
||||
model_access = fields.One2Many('ir.model.access', 'group',
|
||||
'Access Model')
|
||||
field_access = fields.One2Many('ir.model.field.access', 'group',
|
||||
@@ -115,9 +114,3 @@ class Group(ModelSQL, ModelView):
|
||||
pool.get('ir.model.access')._get_access_cache.clear()
|
||||
pool.get('ir.model.field.access')._get_access_cache.clear()
|
||||
ModelView._fields_view_get_cache.clear()
|
||||
|
||||
|
||||
class Group2:
|
||||
__metaclass__ = PoolMeta
|
||||
__name__ = "res.group"
|
||||
users = fields.Many2Many('res.user-res.group', 'group', 'user', 'Users')
|
||||
|
||||
Reference in New Issue
Block a user