diff --git a/trytond/res/group.py b/trytond/res/group.py index 6737ba748d..d5407f1509 100644 --- a/trytond/res/group.py +++ b/trytond/res/group.py @@ -33,6 +33,8 @@ class Group(ModelSQL, ModelView): name = fields.Char('Name', required=True, select=1, translate=True) model_access = fields.One2Many('ir.model.access', 'group', 'Access Model') + field_access = fields.One2Many('ir.model.field.access', 'group', + 'Access Field') rule_groups = fields.Many2Many('ir.rule.group-res.group', 'group_id', 'rule_group_id', 'Rules', domain=[('global_p', '!=', True), ('default_p', '!=', True)]) @@ -45,6 +47,29 @@ class Group(ModelSQL, ModelView): ('name_uniq', 'unique (name)', 'The name of the group must be unique!') ] + def copy(self, ids, default=None): + int_id = isinstance(ids, (int, long)) + if int_id: + ids = [ids] + + if default is None: + default = {} + default = default.copy() + + new_ids = [] + for group in self.browse(ids): + i = 1 + while True: + name = '%s (%d)' % (group.name, i) + if not self.search([('name', '=', name)], order=[]): + break + i += 1 + default['name'] = name + new_ids.append(super(Group, self).copy(group.id, default=default)) + if int_id: + return new_ids[0] + return new_ids + def create(self, vals): res = super(Group, self).create(vals) # Restart the cache on the domain_get method diff --git a/trytond/res/group.xml b/trytond/res/group.xml index a1b05a8a85..5835c0200b 100644 --- a/trytond/res/group.xml +++ b/trytond/res/group.xml @@ -19,13 +19,13 @@ this repository contains the full copyright notices and license terms. --> - - + - - - - + + + + +