|
|
@ -8,30 +8,36 @@ from odoo.tools.safe_eval import safe_eval |
|
|
|
class TestDeduplicateFilter(common.TransactionCase): |
|
|
|
def setUp(self): |
|
|
|
super(TestDeduplicateFilter, 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_1.copy() |
|
|
|
self.partner_2 = self.env['res.partner'].create({ |
|
|
|
'name': 'Partner 2', |
|
|
|
'email': 'partner2@example.org', |
|
|
|
'is_company': False, |
|
|
|
'parent_id': self.partner_1.id, |
|
|
|
}) |
|
|
|
self.partner_2 = self.env["res.partner"].create( |
|
|
|
{ |
|
|
|
"name": "Partner 2", |
|
|
|
"email": "partner2@example.org", |
|
|
|
"is_company": False, |
|
|
|
"parent_id": self.partner_1.id, |
|
|
|
} |
|
|
|
) |
|
|
|
self.partner_2.copy() |
|
|
|
self.partner_3 = self.env['res.partner'].create({ |
|
|
|
'name': 'Partner 3', |
|
|
|
'email': 'partner3@example.org', |
|
|
|
'is_company': False, |
|
|
|
'parent_id': False, |
|
|
|
}) |
|
|
|
self.partner_3 = self.env["res.partner"].create( |
|
|
|
{ |
|
|
|
"name": "Partner 3", |
|
|
|
"email": "partner3@example.org", |
|
|
|
"is_company": False, |
|
|
|
"parent_id": False, |
|
|
|
} |
|
|
|
) |
|
|
|
self.partner_3.copy() |
|
|
|
self.wizard = self.env['base.partner.merge.automatic.wizard'].create({ |
|
|
|
'group_by_email': True, |
|
|
|
}) |
|
|
|
self.wizard = self.env["base.partner.merge.automatic.wizard"].create( |
|
|
|
{"group_by_email": True} |
|
|
|
) |
|
|
|
|
|
|
|
def test_deduplicate_exclude_is_company(self): |
|
|
|
self.wizard.exclude_is_company = True |
|
|
@ -40,7 +46,7 @@ class TestDeduplicateFilter(common.TransactionCase): |
|
|
|
for line in self.wizard.line_ids: |
|
|
|
match_ids = safe_eval(line.aggr_ids) |
|
|
|
if self.partner_1.id in match_ids: |
|
|
|
self.assertTrue(False, 'Partner with is company not excluded') |
|
|
|
self.assertTrue(False, "Partner with is company not excluded") |
|
|
|
if self.partner_2.id in match_ids: |
|
|
|
matched_founds += 1 |
|
|
|
if self.partner_3.id in match_ids: |
|
|
@ -54,9 +60,9 @@ class TestDeduplicateFilter(common.TransactionCase): |
|
|
|
for line in self.wizard.line_ids: |
|
|
|
match_ids = safe_eval(line.aggr_ids) |
|
|
|
if self.partner_1.id in match_ids: |
|
|
|
self.assertTrue(False, 'Partner without parent not excluded') |
|
|
|
self.assertTrue(False, "Partner without parent not excluded") |
|
|
|
if self.partner_3.id in match_ids: |
|
|
|
self.assertTrue(False, 'Partner without parent not excluded') |
|
|
|
self.assertTrue(False, "Partner without parent not excluded") |
|
|
|
if self.partner_2.id in match_ids: |
|
|
|
matched_founds += 1 |
|
|
|
self.assertEqual(matched_founds, 1) |
|
|
@ -68,7 +74,7 @@ class TestDeduplicateFilter(common.TransactionCase): |
|
|
|
for line in self.wizard.line_ids: |
|
|
|
match_ids = safe_eval(line.aggr_ids) |
|
|
|
if self.partner_2.id in match_ids: |
|
|
|
self.assertTrue(False, 'Partner with parent not excluded') |
|
|
|
self.assertTrue(False, "Partner with parent not excluded") |
|
|
|
if self.partner_1.id in match_ids: |
|
|
|
matched_founds += 1 |
|
|
|
if self.partner_3.id in match_ids: |
|
|
|