Browse Source

[ADD] crm_deduplicate_by_ref

=================================
Deduplicate Contacts by reference
=================================

This module extends the criteria to match duplicated contacts using the field
reference.

Usage
=====

To use this module, you need to:

* Go to *Sales > Tools > Deduplicate Contacts*.
* Mark "Reference" in the section "Search duplicates based on duplicated data
  in".
* This criteria will be used for deduplicating.
12.0
Pedro M. Baeza 8 years ago
committed by david
parent
commit
c69ee72f8f
  1. 60
      partner_deduplicate_by_ref/README.rst
  2. 4
      partner_deduplicate_by_ref/__init__.py
  3. 21
      partner_deduplicate_by_ref/__openerp__.py
  4. 27
      partner_deduplicate_by_ref/i18n/es.po
  5. BIN
      partner_deduplicate_by_ref/static/description/icon.png
  6. 107
      partner_deduplicate_by_ref/static/description/icon.svg
  7. 4
      partner_deduplicate_by_ref/tests/__init__.py
  8. 50
      partner_deduplicate_by_ref/tests/test_crm_deduplicate_by_ref.py
  9. 5
      partner_deduplicate_by_ref/wizards/__init__.py
  10. 29
      partner_deduplicate_by_ref/wizards/partner_merge.py
  11. 20
      partner_deduplicate_by_ref/wizards/partner_merge_view.xml

60
partner_deduplicate_by_ref/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 reference
=================================
This module extends the criteria to match duplicated contacts using the field
reference.
Usage
=====
To use this module, you need to:
#. Go to *Sales > Tools > Deduplicate Contacts*.
#. Mark "Reference" 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/9.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
------
* `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.

4
partner_deduplicate_by_ref/__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

21
partner_deduplicate_by_ref/__openerp__.py

@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Pedro M. Baeza <pedro.baeza@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Deduplicate Contacts by reference",
"version": "9.0.1.0.0",
"category": "Tools",
"website": "https://www.tecnativa.com",
"author": "Tecnativa, "
"Odoo Community Association (OCA)",
"license": "AGPL-3",
"installable": True,
"depends": [
"crm",
"crm_deduplicate_acl",
],
"data": [
'wizards/partner_merge_view.xml',
],
}

27
partner_deduplicate_by_ref/i18n/es.po

@ -0,0 +1,27 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * crm_deduplicate_by_ref
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 9.0c\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-03-01 21:29+0000\n"
"PO-Revision-Date: 2017-03-01 21:29+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_ref
#: model:ir.model.fields,field_description:crm_deduplicate_by_ref.field_base_partner_merge_automatic_wizard_group_by_ref
msgid "Reference"
msgstr "Referencia"
#. module: crm_deduplicate_by_ref
#: model:ir.model,name:crm_deduplicate_by_ref.model_base_partner_merge_automatic_wizard
msgid "base.partner.merge.automatic.wizard"
msgstr "base.partner.merge.automatic.wizard"

BIN
partner_deduplicate_by_ref/static/description/icon.png

After

Width: 128  |  Height: 128  |  Size: 10 KiB

107
partner_deduplicate_by_ref/static/description/icon.svg
File diff suppressed because it is too large
View File

4
partner_deduplicate_by_ref/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_ref

50
partner_deduplicate_by_ref/tests/test_crm_deduplicate_by_ref.py

@ -0,0 +1,50 @@
# -*- coding: utf-8 -*-
# Copyright 2017 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 TestDeduplicateByRef(common.TransactionCase):
def setUp(self):
super(TestDeduplicateByRef, self).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',
})
def test_deduplicate_by_ref(self):
wizard = self.env['base.partner.merge.automatic.wizard'].create({
'group_by_ref': 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)
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.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)

5
partner_deduplicate_by_ref/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

29
partner_deduplicate_by_ref/wizards/partner_merge.py

@ -0,0 +1,29 @@
# -*- 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 fields, models
class BasePartnerMergeAutomaticWizard(models.TransientModel):
_inherit = "base.partner.merge.automatic.wizard"
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(BasePartnerMergeAutomaticWizard, self)._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:])
return query

20
partner_deduplicate_by_ref/wizards/partner_merge_view.xml

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2017 Pedro M. Baeza <pedro.baeza@tecnativa.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
<odoo>
<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="group_by_parent_id" position="after">
<field name="group_by_ref"/>
</field>
<xpath expr="//field[@name='partner_ids']/tree//field[@name='country_id']" position="after">
<field name="ref"/>
</xpath>
</field>
</record>
</odoo>
Loading…
Cancel
Save