diff --git a/base_partner_merge/__openerp__.py b/base_partner_merge/__openerp__.py index 5c2a145d78f..876919b6be7 100644 --- a/base_partner_merge/__openerp__.py +++ b/base_partner_merge/__openerp__.py @@ -10,7 +10,7 @@ 'base', ], 'data': [ - 'security/ir.model.access.csv', + 'security/security.xml', 'base_partner_merge_view.xml', ], 'installable': True, diff --git a/base_partner_merge/base_partner_merge.py b/base_partner_merge/base_partner_merge.py index 416430d0bff..e9360e35014 100644 --- a/base_partner_merge/base_partner_merge.py +++ b/base_partner_merge/base_partner_merge.py @@ -340,6 +340,16 @@ def _merge(self, cr, uid, partner_ids, dst_partner=None, context=None): partner_ids = proxy.exists(cr, uid, list(partner_ids), context=context) + + if not self.pool['res.users'].has_group( + cr, uid, 'base_partner_merge.group_partner_merge' + ): + raise orm.except_orm( + _('Error'), + _("You do not belong in the 'Partner Merge' group. " + "Please contact the Administrator to get access to " + "the partner merge functionality.")) + if len(partner_ids) < 2: return @@ -350,10 +360,9 @@ def _merge(self, cr, uid, partner_ids, dst_partner=None, context=None): "together. You can re-open the wizard several times if " "needed.")) - if (openerp.SUPERUSER_ID != uid - and len(set(partner.email for partner - in proxy.browse(cr, uid, partner_ids, - context=context))) > 1): + if (len(set(partner.email for partner + in proxy.browse(cr, uid, partner_ids, + context=context))) > 1): raise orm.except_orm( _('Error'), _("All contacts must have the same email. Only the " @@ -371,23 +380,6 @@ def _merge(self, cr, uid, partner_ids, dst_partner=None, context=None): src_partners = ordered_partners[:-1] _logger.info("dst_partner: %s", dst_partner.id) - if (openerp.SUPERUSER_ID != uid - and self._model_is_installed(cr, uid, 'account.move.line', - context=context) - and self.pool.get('account.move.line' - ).search(cr, openerp.SUPERUSER_ID, - [('partner_id', - 'in', - [partner.id for partner - in src_partners])], - context=context)): - raise orm.except_orm( - _('Error'), - _("Only the destination contact may be linked to existing " - "Journal Items. Please ask the Administrator if you need to" - " merge several contacts linked to existing Journal " - "Items.")) - call_it = lambda function: function(cr, uid, src_partners, dst_partner, context=context) diff --git a/base_partner_merge/base_partner_merge_view.xml b/base_partner_merge/base_partner_merge_view.xml index 5ae786aaa53..0c8144774b0 100644 --- a/base_partner_merge/base_partner_merge_view.xml +++ b/base_partner_merge/base_partner_merge_view.xml @@ -2,7 +2,7 @@ - + Deduplicate Contacts @@ -15,7 +15,7 @@ @@ -116,7 +116,7 @@ + target="new" multi="True" key2="client_action_multi" view_mode="form" name="Automatic Merge" groups="group_partner_merge"/> diff --git a/base_partner_merge/security/security.xml b/base_partner_merge/security/security.xml new file mode 100644 index 00000000000..9505e1b17c7 --- /dev/null +++ b/base_partner_merge/security/security.xml @@ -0,0 +1,11 @@ + + + + + Partner Merge + + + + + +