diff --git a/partner_deduplicate_by_ref/__manifest__.py b/partner_deduplicate_by_ref/__manifest__.py index 1c5831c9f..8cca0bc8e 100644 --- a/partner_deduplicate_by_ref/__manifest__.py +++ b/partner_deduplicate_by_ref/__manifest__.py @@ -5,14 +5,9 @@ "version": "12.0.1.0.0", "category": "Tools", "website": "https://www.github.com/OCA/partner-contact", - "author": "Tecnativa, " - "Odoo Community Association (OCA)", + "author": "Tecnativa, " "Odoo Community Association (OCA)", "license": "AGPL-3", "installable": True, - "depends": [ - "partner_deduplicate_acl", - ], - "data": [ - 'wizards/partner_merge_view.xml', - ], + "depends": ["partner_deduplicate_acl",], + "data": ["wizards/partner_merge_view.xml",], } diff --git a/partner_deduplicate_by_ref/tests/test_partner_deduplicate_by_ref.py b/partner_deduplicate_by_ref/tests/test_partner_deduplicate_by_ref.py index dd069533c..961808765 100644 --- a/partner_deduplicate_by_ref/tests/test_partner_deduplicate_by_ref.py +++ b/partner_deduplicate_by_ref/tests/test_partner_deduplicate_by_ref.py @@ -8,42 +8,35 @@ from odoo.tools.safe_eval import safe_eval class TestDeduplicateByRef(common.TransactionCase): def setUp(self): super().setUp() - self.partner_1 = self.env['res.partner'].create({ - 'name': 'Partner 1', - 'ref': '123456', - 'email': 'test@deduplicate.com', - }) - self.partner_2 = self.env['res.partner'].create({ - 'name': 'Partner 2', - 'ref': '123456', - 'email': 'test@deduplicate.com', - }) + self.partner_1 = self.env["res.partner"].create( + {"name": "Partner 1", "ref": "123456", "email": "test@deduplicate.com",} + ) + self.partner_2 = self.env["res.partner"].create( + {"name": "Partner 2", "ref": "123456", "email": "test@deduplicate.com",} + ) def test_deduplicate_by_ref(self): - wizard = self.env['base.partner.merge.automatic.wizard'].create({ - 'group_by_ref': True, - }) + wizard = self.env["base.partner.merge.automatic.wizard"].create( + {"group_by_ref": True,} + ) wizard.action_start_manual_process() found_match = False for line in wizard.line_ids: match_ids = safe_eval(line.aggr_ids) - if (self.partner_1.id in match_ids and - self.partner_2.id in match_ids): + if self.partner_1.id in match_ids and self.partner_2.id in match_ids: found_match = True break self.assertTrue(found_match) def test_deduplicate_by_ref_and_is_company(self): - wizard = self.env['base.partner.merge.automatic.wizard'].create({ - 'group_by_ref': True, - 'group_by_email': True, - }) + wizard = self.env["base.partner.merge.automatic.wizard"].create( + {"group_by_ref": True, "group_by_email": True,} + ) wizard.action_start_manual_process() found_match = False for line in wizard.line_ids: match_ids = safe_eval(line.aggr_ids) - if (self.partner_1.id in match_ids and - self.partner_2.id in match_ids): + if self.partner_1.id in match_ids and self.partner_2.id in match_ids: found_match = True break self.assertTrue(found_match) diff --git a/partner_deduplicate_by_ref/wizards/partner_merge.py b/partner_deduplicate_by_ref/wizards/partner_merge.py index bfd12002a..500c58a81 100644 --- a/partner_deduplicate_by_ref/wizards/partner_merge.py +++ b/partner_deduplicate_by_ref/wizards/partner_merge.py @@ -7,22 +7,19 @@ from openerp import fields, models class BasePartnerMergeAutomaticWizard(models.TransientModel): _inherit = "base.partner.merge.automatic.wizard" - group_by_ref = fields.Boolean('Reference') + group_by_ref = fields.Boolean("Reference") def _generate_query(self, fields, maximum_group=100): """Inject the additional criteria 'ref IS NOT NULL' when needed. There's no better way to do it, as there are no hooks for adding this criteria regularly. """ - query = super()._generate_query( - fields, maximum_group=maximum_group) - if 'ref' in fields: - if 'WHERE' in query: - index = query.find('WHERE') - query = (query[:index + 6] + "ref IS NOT NULL AND " + - query[index + 6:]) + query = super()._generate_query(fields, maximum_group=maximum_group) + if "ref" in fields: + if "WHERE" in query: + index = query.find("WHERE") + query = query[: index + 6] + "ref IS NOT NULL AND " + query[index + 6 :] else: - index = query.find(' GROUP BY') - query = (query[:index] + " WHERE ref IS NOT NULL" + - query[index:]) + index = query.find(" GROUP BY") + query = query[:index] + " WHERE ref IS NOT NULL" + query[index:] return query diff --git a/partner_deduplicate_by_ref/wizards/partner_merge_view.xml b/partner_deduplicate_by_ref/wizards/partner_merge_view.xml index 016c266cc..6a3d06780 100644 --- a/partner_deduplicate_by_ref/wizards/partner_merge_view.xml +++ b/partner_deduplicate_by_ref/wizards/partner_merge_view.xml @@ -1,20 +1,20 @@ - + - - base.partner.merge.automatic.wizard - + - + - - + + -