Browse Source
crm_deduplicate_filter
crm_deduplicate_filter
=========================================== Exclude some records from the deduplication =========================================== This module extends the possibilities of the contact deduplication allowing to filter the applicable set according several criteria. For now, only the filter for restricting the deduplication to only companies or only contacts is implemented. Usage ===== To use this module, you need to: "Parent company set (Contacts)" in the section 'Exclude contacts having'. kind of records.pull/726/head
Pedro M. Baeza
9 years ago
committed by
Victor Martin
11 changed files with 365 additions and 0 deletions
-
65partner_deduplicate_filter/README.rst
-
4partner_deduplicate_filter/__init__.py
-
20partner_deduplicate_filter/__openerp__.py
-
32partner_deduplicate_filter/i18n/es.po
-
BINpartner_deduplicate_filter/static/description/icon.png
-
102partner_deduplicate_filter/static/description/icon.svg
-
4partner_deduplicate_filter/tests/__init__.py
-
77partner_deduplicate_filter/tests/test_crm_deduplicate_filter.py
-
5partner_deduplicate_filter/wizards/__init__.py
-
35partner_deduplicate_filter/wizards/partner_merge.py
-
21partner_deduplicate_filter/wizards/partner_merge_view.xml
@ -0,0 +1,65 @@ |
|||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg |
|||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html |
|||
:alt: License: AGPL-3 |
|||
|
|||
=========================================== |
|||
Exclude some records from the deduplication |
|||
=========================================== |
|||
|
|||
This module extends the possibilities of the contact deduplication allowing |
|||
to filter the applicable set according to several criteria. |
|||
|
|||
For now, only the filter for restricting the deduplication to only companies or |
|||
only contacts is implemented. |
|||
|
|||
Usage |
|||
===== |
|||
|
|||
To use this module, you need to: |
|||
|
|||
#. Go to *Sales > Tools > Deduplicate Contacts*. |
|||
#. Mark "'Is a company?' field selected", "Parent company not set" or |
|||
"Parent company set (Contacts)" in the section 'Exclude contacts having'. |
|||
#. This criteria will be used for excluding in the deduplication the selected |
|||
kind of records. |
|||
|
|||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas |
|||
:alt: Try me on Runbot |
|||
:target: https://runbot.odoo-community.org/runbot/111/8.0 |
|||
|
|||
Bug Tracker |
|||
=========== |
|||
|
|||
Bugs are tracked on `GitHub Issues |
|||
<https://github.com/OCA/crm/issues>`_. In case of trouble, please |
|||
check there if your issue has already been reported. If you spotted it first, |
|||
help us smashing it by providing a detailed and welcomed feedback. |
|||
|
|||
Credits |
|||
======= |
|||
|
|||
Images |
|||
------ |
|||
|
|||
* `Funnel <https://openclipart.org/detail/245510/funnel>`_. |
|||
* `Arrow <https://openclipart.org/detail/131875/convergent>`_. |
|||
|
|||
Contributors |
|||
------------ |
|||
|
|||
* Pedro M. Baeza <pedro.baeza@tecnativa.com> |
|||
|
|||
Maintainer |
|||
---------- |
|||
|
|||
.. image:: https://odoo-community.org/logo.png |
|||
:alt: Odoo Community Association |
|||
:target: https://odoo-community.org |
|||
|
|||
This module is maintained by the OCA. |
|||
|
|||
OCA, or the Odoo Community Association, is a nonprofit organization whose |
|||
mission is to support the collaborative development of Odoo features and |
|||
promote its widespread use. |
|||
|
|||
To contribute to this module, please visit https://odoo-community.org. |
@ -0,0 +1,4 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from . import wizards |
@ -0,0 +1,20 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2016 Pedro M. Baeza <pedro.baeza@tecnativa.com> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
{ |
|||
"name": "Exclude records from the deduplication", |
|||
"version": "8.0.1.0.0", |
|||
"category": "Tools", |
|||
"website": "https://www.tecnativa.com", |
|||
"author": "Tecnativa, " |
|||
"Odoo Community Association (OCA)", |
|||
"license": "AGPL-3", |
|||
"installable": True, |
|||
"depends": [ |
|||
"crm", |
|||
], |
|||
"data": [ |
|||
'wizards/partner_merge_view.xml', |
|||
], |
|||
} |
@ -0,0 +1,32 @@ |
|||
# Translation of Odoo Server. |
|||
# This file contains the translation of the following modules: |
|||
# * crm_deduplicate_filter |
|||
# |
|||
msgid "" |
|||
msgstr "" |
|||
"Project-Id-Version: Odoo Server 8.0\n" |
|||
"Report-Msgid-Bugs-To: \n" |
|||
"POT-Creation-Date: 2016-08-12 19:57+0000\n" |
|||
"PO-Revision-Date: 2016-08-12 19:57+0000\n" |
|||
"Last-Translator: <>\n" |
|||
"Language-Team: \n" |
|||
"MIME-Version: 1.0\n" |
|||
"Content-Type: text/plain; charset=UTF-8\n" |
|||
"Content-Transfer-Encoding: \n" |
|||
"Plural-Forms: \n" |
|||
|
|||
#. module: crm_deduplicate_filter |
|||
#: field:base.partner.merge.automatic.wizard,exclude_is_company:0 |
|||
msgid "'Is a company?' field selected" |
|||
msgstr "El campo '¿Es una compañía?' seleccionado" |
|||
|
|||
#. module: crm_deduplicate_filter |
|||
#: field:base.partner.merge.automatic.wizard,exclude_parent:0 |
|||
msgid "Parent company set (Contacts)" |
|||
msgstr "La compañía padre establecida (Contactos)" |
|||
|
|||
#. module: crm_deduplicate_filter |
|||
#: field:base.partner.merge.automatic.wizard,exclude_not_parent:0 |
|||
msgid "Parent company not set" |
|||
msgstr "La compañía padre no establecida" |
|||
|
After Width: 128 | Height: 128 | Size: 11 KiB |
102
partner_deduplicate_filter/static/description/icon.svg
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,4 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from . import test_crm_deduplicate_filter |
@ -0,0 +1,77 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2016 Pedro M. Baeza <pedro.baeza@tecnativa.com> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from openerp.tests import common |
|||
from openerp.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.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.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.copy() |
|||
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 |
|||
self.wizard.start_process_cb() |
|||
matched_founds = 0 |
|||
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') |
|||
if self.partner_2.id in match_ids: |
|||
matched_founds += 1 |
|||
if self.partner_3.id in match_ids: |
|||
matched_founds += 1 |
|||
self.assertEqual(matched_founds, 2) |
|||
|
|||
def test_deduplicate_exclude_not_parent(self): |
|||
self.wizard.exclude_not_parent = True |
|||
self.wizard.start_process_cb() |
|||
matched_founds = 0 |
|||
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') |
|||
if self.partner_3.id in match_ids: |
|||
self.assertTrue(False, 'Partner without parent not excluded') |
|||
if self.partner_2.id in match_ids: |
|||
matched_founds += 1 |
|||
self.assertEqual(matched_founds, 1) |
|||
|
|||
def test_deduplicate_exclude_parent(self): |
|||
self.wizard.exclude_parent = True |
|||
self.wizard.start_process_cb() |
|||
matched_founds = 0 |
|||
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') |
|||
if self.partner_1.id in match_ids: |
|||
matched_founds += 1 |
|||
if self.partner_3.id in match_ids: |
|||
matched_founds += 1 |
|||
self.assertEqual(matched_founds, 2) |
@ -0,0 +1,5 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2016 Antiun Ingeniería S.L. - Jairo Llopis |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from . import partner_merge |
@ -0,0 +1,35 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2016 Pedro M. Baeza <pedro.baeza@tecnativa.com> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from openerp import api, fields, models |
|||
|
|||
|
|||
class BasePartnerMergeAutomaticWizard(models.TransientModel): |
|||
_inherit = "base.partner.merge.automatic.wizard" |
|||
|
|||
exclude_is_company = fields.Boolean("'Is a company?' field selected") |
|||
exclude_not_parent = fields.Boolean("Parent company not set") |
|||
exclude_parent = fields.Boolean("Parent company set (Contacts)") |
|||
|
|||
@api.multi |
|||
def _process_query(self, query): |
|||
if any([self.exclude_is_company, self.exclude_not_parent, |
|||
self.exclude_parent]): |
|||
filters = [] |
|||
if self.exclude_is_company: |
|||
filters.append("is_company = False") |
|||
if self.exclude_not_parent: |
|||
filters.append("parent_id IS NOT NULL") |
|||
if self.exclude_parent: |
|||
filters.append("parent_id IS NULL") |
|||
index_where = query.find('WHERE') |
|||
index_group_by = query.find('GROUP BY') |
|||
subquery = "%s" % ' AND '.join(filters) |
|||
if index_where > 0: |
|||
subquery = "AND (%s) " % subquery |
|||
else: # pragma: no cover |
|||
subquery = "WHERE %s " % subquery |
|||
query = query[:index_group_by] + subquery + query[index_group_by:] |
|||
return super(BasePartnerMergeAutomaticWizard, self)._process_query( |
|||
query) |
@ -0,0 +1,21 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<!-- Copyright 2016 Pedro M. Baeza <pedro.baeza@tecnativa.com> |
|||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). --> |
|||
|
|||
<openerp> |
|||
<data> |
|||
|
|||
<record id="base_partner_merge_automatic_wizard_form" model="ir.ui.view"> |
|||
<field name="model">base.partner.merge.automatic.wizard</field> |
|||
<field name="inherit_id" ref="crm.base_partner_merge_automatic_wizard_form"/> |
|||
<field name="arch" type="xml"> |
|||
<field name='exclude_contact' position="before"> |
|||
<field name="exclude_is_company"/> |
|||
<field name="exclude_not_parent"/> |
|||
<field name="exclude_parent"/> |
|||
</field> |
|||
</field> |
|||
</record> |
|||
|
|||
</data> |
|||
</openerp> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue