diff --git a/partner_deduplicate_by_website/README.rst b/partner_deduplicate_by_website/README.rst new file mode 100644 index 000000000..58ea0d56d --- /dev/null +++ b/partner_deduplicate_by_website/README.rst @@ -0,0 +1,60 @@ +.. 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 + +=============================== +Deduplicate Contacts by website +=============================== + +This module extends the criteria to match duplicated contacts using the field +website. + +Usage +===== + +To use this module, you need to: + +#. Go to *Sales > Tools > Deduplicate Contacts*. +#. Mark "Website" in the section "Search duplicates based on duplicated data + in". +#. This criteria will be used for deduplicating. + +.. 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 +`_. 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 +------ + +* `Arrow `_. + +Contributors +------------ + +* Pedro M. Baeza + +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. diff --git a/partner_deduplicate_by_website/__init__.py b/partner_deduplicate_by_website/__init__.py new file mode 100644 index 000000000..f8944f05c --- /dev/null +++ b/partner_deduplicate_by_website/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import wizards diff --git a/partner_deduplicate_by_website/__openerp__.py b/partner_deduplicate_by_website/__openerp__.py new file mode 100644 index 000000000..811dc48f1 --- /dev/null +++ b/partner_deduplicate_by_website/__openerp__.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Copyright 2016 Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "Deduplicate Contacts by Website", + "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', + ], +} diff --git a/partner_deduplicate_by_website/i18n/es.po b/partner_deduplicate_by_website/i18n/es.po new file mode 100644 index 000000000..8df9a361a --- /dev/null +++ b/partner_deduplicate_by_website/i18n/es.po @@ -0,0 +1,22 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * crm_deduplicate_by_website +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-06-09 08:13+0000\n" +"PO-Revision-Date: 2016-06-09 08:13+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_by_website +#: field:base.partner.merge.automatic.wizard,group_by_website:0 +msgid "Website" +msgstr "Sitio web" + diff --git a/partner_deduplicate_by_website/static/description/icon.png b/partner_deduplicate_by_website/static/description/icon.png new file mode 100644 index 000000000..1f1ca2b0e Binary files /dev/null and b/partner_deduplicate_by_website/static/description/icon.png differ diff --git a/partner_deduplicate_by_website/static/description/icon.svg b/partner_deduplicate_by_website/static/description/icon.svg new file mode 100644 index 000000000..39edf7d05 --- /dev/null +++ b/partner_deduplicate_by_website/static/description/icon.svg @@ -0,0 +1,111 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + diff --git a/partner_deduplicate_by_website/tests/__init__.py b/partner_deduplicate_by_website/tests/__init__.py new file mode 100644 index 000000000..fd9064d3e --- /dev/null +++ b/partner_deduplicate_by_website/tests/__init__.py @@ -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_by_website diff --git a/partner_deduplicate_by_website/tests/test_crm_deduplicate_by_website.py b/partner_deduplicate_by_website/tests/test_crm_deduplicate_by_website.py new file mode 100644 index 000000000..e34e1f0f6 --- /dev/null +++ b/partner_deduplicate_by_website/tests/test_crm_deduplicate_by_website.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# Copyright 2016 Pedro M. Baeza +# 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 TestDeduplicateByWebsite(common.TransactionCase): + def setUp(self): + super(TestDeduplicateByWebsite, self).setUp() + self.partner_1 = self.env['res.partner'].create({ + 'name': 'Partner 1', + 'website': 'www.test-deduplicate.com', + }) + self.partner_2 = self.env['res.partner'].create({ + 'name': 'Partner 2', + 'website': 'www.test-deduplicate.com', + }) + + def test_deduplicate_by_website(self): + wizard = self.env['base.partner.merge.automatic.wizard'].create({ + 'group_by_website': True, + }) + wizard.start_process_cb() + 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): + found_match = True + break + self.assertTrue(found_match) diff --git a/partner_deduplicate_by_website/wizards/__init__.py b/partner_deduplicate_by_website/wizards/__init__.py new file mode 100644 index 000000000..c93eadfed --- /dev/null +++ b/partner_deduplicate_by_website/wizards/__init__.py @@ -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 diff --git a/partner_deduplicate_by_website/wizards/partner_merge.py b/partner_deduplicate_by_website/wizards/partner_merge.py new file mode 100644 index 000000000..2e5388eeb --- /dev/null +++ b/partner_deduplicate_by_website/wizards/partner_merge.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +# Copyright 2016 Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openerp import fields, models + + +class BasePartnerMergeAutomaticWizard(models.TransientModel): + _inherit = "base.partner.merge.automatic.wizard" + + group_by_website = fields.Boolean('Website') + + def _generate_query(self, fields, maximum_group=100): + """Inject the additional criteria 'website 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(BasePartnerMergeAutomaticWizard, self)._generate_query( + fields, maximum_group=maximum_group) + if 'website' in fields: + if 'WHERE' in query: + index = query.find('WHERE') + query = (query[:index + 6] + "website IS NOT NULL AND " + + query[index + 6:]) + else: + index = query.find(' GROUP BY') + query = (query[:index] + " WHERE website IS NOT NULL" + + query[index:]) + return query diff --git a/partner_deduplicate_by_website/wizards/partner_merge_view.xml b/partner_deduplicate_by_website/wizards/partner_merge_view.xml new file mode 100644 index 000000000..ad081ac89 --- /dev/null +++ b/partner_deduplicate_by_website/wizards/partner_merge_view.xml @@ -0,0 +1,22 @@ + + + + + + + + base.partner.merge.automatic.wizard + + + + + + + + + + + + +