Skip to content

Commit

Permalink
Keyword arguments problem on merge partner (OCA#128)
Browse files Browse the repository at this point in the history
Closes OCA#125
  • Loading branch information
cubells authored and cesar-tecnativa committed Jul 5, 2022
1 parent 7d20141 commit eeba9a1
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 20 deletions.
5 changes: 3 additions & 2 deletions partner_deduplicate_acl/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Usage

To use this module, you need to:

#. Ask your admin to give you the new rigts.
#. Ask your admin to give you the new rights.
#. Go to *Sales > Tools > Deduplicate Contacts* as usual.

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
Expand Down Expand Up @@ -76,8 +76,9 @@ Contributors
------------

* Rafael Blasco <rafabn@antiun.com>
* Jairo Llopis <yajo.sk8@gmail.com>
* Jairo Llopis <jairo.llopis@tecnativa.com>
* Vicent Cubells <vicent.cubells@tecnativa.com>
* Pedro M. Baeza <pedro.baeza@tecnativa.com>

Maintainer
----------
Expand Down
2 changes: 1 addition & 1 deletion partner_deduplicate_acl/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"name": "Deduplicate Contacts ACL",
"summary": "Contact deduplication with fine-grained permission control",
"version": "9.0.1.0.0",
"version": "9.0.1.1.0",
"category": "Tools",
"website": "http://www.tecnativa.com",
"author": "Tecnativa, "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<record id="group_unrestricted" model="res.groups">
<field name="name">Without restrictions</field>
<field name="category_id" ref="category"/>
<field name="implied_ids" eval="[(4, ref('group_manually'))]"/>
<field name="implied_ids" eval="[(4, ref('group_automatically'))]"/>
</record>

<!-- Respect previous behavior -->
Expand Down
16 changes: 9 additions & 7 deletions partner_deduplicate_acl/views/base_partner_merge_view.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- © 2016 Tecnativa S.L. - Jairo Llopis
© 2016 Tecnativa S.L. - Vicent Cubells
<!-- Copyright 2016 Tecnativa - Jairo Llopis
Copyright 2016 Tecnativa - Vicent Cubells
Copyright 2017 Tecnativa - Pedro M. Baeza
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
<odoo>
<menuitem id='root_menu' name='Tools' parent='base.menu_base_partner' sequence="25"/>
<menuitem id='partner_merge_automatic_menu'
action='crm.action_partner_deduplicate'
groups='base.group_system'
parent='root_menu' />
<menuitem id='root_menu' name='Tools' parent='base.menu_base_partner' sequence="25"/>
<menuitem id='partner_merge_automatic_menu'
action='crm.action_partner_deduplicate'
groups='group_automatically'
parent='root_menu'
/>
</odoo>
20 changes: 11 additions & 9 deletions partner_deduplicate_acl/wizards/partner_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@
# © 2016 Tecnativa, S.L. - Vicent Cubells
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import api, models
from openerp import SUPERUSER_ID, models


class BasePartnerMergeAutomaticWizard(models.TransientModel):
_inherit = "base.partner.merge.automatic.wizard"

@api.model
def _merge(self, partner_ids, dst_partner=None):
"""Allow non-admins to merge partners with different emails."""
# Know if user has unrestricted access
if self.env.user.has_group('crm_deduplicate_acl.group_unrestricted'):
# Run as admin if so
self = self.sudo()
def _merge(self, cr, uid, partner_ids, dst_partner=None, context=None):
"""Allow non-admins to merge partners"""

user = self.pool["res.users"].browse(cr, uid, uid, context=context)
return super(BasePartnerMergeAutomaticWizard, self)._merge(
partner_ids=partner_ids, dst_partner=dst_partner
cr,
SUPERUSER_ID if user.has_group(
'crm_deduplicate_acl.group_unrestricted') else uid,
partner_ids,
dst_partner=dst_partner,
context=context
)

0 comments on commit eeba9a1

Please sign in to comment.