Browse Source

[IMP] partner_deduplicate_acl: black, isort

14.0
Kevin Khao 5 years ago
committed by Carlos Roca
parent
commit
057d847ff8
  1. 11
      partner_deduplicate_acl/__manifest__.py
  2. 51
      partner_deduplicate_acl/tests/test_partner_deduplicate_acl.py
  3. 6
      partner_deduplicate_acl/wizards/partner_merge.py

11
partner_deduplicate_acl/__manifest__.py

@ -10,20 +10,15 @@
"version": "12.0.1.0.0",
"category": "Tools",
"website": "https://github.com/OCA/partner-contact",
"author": "Tecnativa, "
"Odoo Community Association (OCA)",
"author": "Tecnativa, " "Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": [
"contacts",
],
"depends": ["contacts"],
"data": [
"security/partner_deduplicate_acl_security.xml",
"wizards/partner_merge_view.xml",
"views/base_partner_merge_view.xml",
],
"images": [
"images/perms.png",
],
"images": ["images/perms.png"],
}

51
partner_deduplicate_acl/tests/test_partner_deduplicate_acl.py

@ -8,38 +8,39 @@ from odoo.tests import common
class TestPartnerDeduplicateAcl(common.TransactionCase):
def setUp(self):
super(TestPartnerDeduplicateAcl, self).setUp()
self.partner_1 = self.env['res.partner'].create({
'name': 'Partner 1',
'email': 'partner1@example.org',
'is_company': True,
'parent_id': False,
})
self.partner_1 = self.env["res.partner"].create(
{
"name": "Partner 1",
"email": "partner1@example.org",
"is_company": True,
"parent_id": False,
}
)
self.partner_2 = self.partner_1.copy()
self.partner_2.write({
'name': 'Partner 1',
'email': 'partner2@example.org'
})
self.user = self.env['res.users'].create({
'login': 'test_crm_deduplicate_acl',
'name': 'test_crm_deduplicate_acl',
'email': 'partner_deduplicate_acl@example.org',
'groups_id': [
(4, self.env.ref('base.group_user').id),
(4, self.env.ref('base.group_partner_manager').id),
]
})
self.wizard = self.env['base.partner.merge.automatic.wizard'].sudo(
self.user,
).create({
'group_by_name': True,
})
self.partner_2.write({"name": "Partner 1", "email": "partner2@example.org"})
self.user = self.env["res.users"].create(
{
"login": "test_crm_deduplicate_acl",
"name": "test_crm_deduplicate_acl",
"email": "partner_deduplicate_acl@example.org",
"groups_id": [
(4, self.env.ref("base.group_user").id),
(4, self.env.ref("base.group_partner_manager").id),
],
}
)
self.wizard = (
self.env["base.partner.merge.automatic.wizard"]
.sudo(self.user)
.create({"group_by_name": True})
)
def test_same_email_restriction(self):
self.wizard.action_start_manual_process()
with self.assertRaises(exceptions.UserError):
self.wizard.action_merge()
self.user.groups_id = [
(4, self.env.ref('partner_deduplicate_acl.group_unrestricted').id),
(4, self.env.ref("partner_deduplicate_acl.group_unrestricted").id)
]
# Now there shouldn't be error
self.wizard.action_merge()

6
partner_deduplicate_acl/wizards/partner_merge.py

@ -13,10 +13,8 @@ class BasePartnerMergeAutomaticWizard(models.TransientModel):
"""Pass extra_checks=False if we have the extra group for avoiding
the checks.
"""
if self.env.user.has_group(
'partner_deduplicate_acl.group_unrestricted'
):
if self.env.user.has_group("partner_deduplicate_acl.group_unrestricted"):
extra_checks = False
return super()._merge(
partner_ids, dst_partner=dst_partner, extra_checks=extra_checks,
partner_ids, dst_partner=dst_partner, extra_checks=extra_checks
)
Loading…
Cancel
Save