Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[18.0][MIG] partner_email_duplicate_warn: Migration to 18.0 #1960

Open
wants to merge 15 commits into
base: 18.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 120 additions & 0 deletions partner_email_duplicate_warn/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
============================
Partner Email Duplicate Warn
============================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:e913ed3a2d09a1bcf38e84716d752129e458d0daca05e796c69943998ddf3849
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpartner--contact-lightgray.png?logo=github
:target: https://github.com/OCA/partner-contact/tree/17.0/partner_email_duplicate_warn
:alt: OCA/partner-contact
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/partner-contact-17-0/partner-contact-17-0-partner_email_duplicate_warn
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/partner-contact&target_branch=17.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module adds a warning banner on the partner form view if another
partner has the same e-mail. It helps spot duplicate partners. If the
duplication is confirmed, the user can then use the native partner merge
wizard available from the partner tree view (menu *Action > Merge*).

|image1|

It is similar to the native warning banner when another partner has the
same VAT number. T his module has a twin brother named
**partner_mobile_duplicate_warn** which adds a warning banner when
another partner has the same mobile phone number.

.. |image1| image:: https://raw.githubusercontent.com/OCA/partner-contact/17.0/partner_email_duplicate_warn/static/description/partner_warn_banner.png

**Table of contents**

.. contents::
:local:

Configuration
=============

No configuration required.

Usage
=====

The warning banner is displayed on the partner form view if another
partner: - has the same e-mail address (independantly from the case,
from starting spaces and ending spaces), - is not the parent nor the
child of the partner, - if the partner is attached to a specific
company: is in the same company or is not attached to a specific
company, - if the partner is not attached to a specific company: is in
any company or not attached to a specific company.

Known issues / Roadmap
======================

- Add a button "Merge partner" in the end of the warning message to
save clicks to user.
- Set same_email_partner_id as Many2many and find a way to display all
the duplicate in the warning banner with clickable links.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/partner-contact/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/partner-contact/issues/new?body=module:%20partner_email_duplicate_warn%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Akretion

Contributors
------------

- Alexis de Lattre <[email protected]>

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

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.

.. |maintainer-alexis-via| image:: https://github.com/alexis-via.png?size=40px
:target: https://github.com/alexis-via
:alt: alexis-via

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-alexis-via|

This module is part of the `OCA/partner-contact <https://github.com/OCA/partner-contact/tree/17.0/partner_email_duplicate_warn>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions partner_email_duplicate_warn/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
19 changes: 19 additions & 0 deletions partner_email_duplicate_warn/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2021 Akretion France (http://www.akretion.com/)
# @author: Alexis de Lattre <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Partner Email Duplicate Warn",
"version": "18.0.1.0.0",
"category": "Partner Management",
"license": "AGPL-3",
"summary": "Warning banner on partner form if another partner has the same email",
"author": "Akretion,Odoo Community Association (OCA)",
"maintainers": ["alexis-via"],
"website": "https://github.com/OCA/partner-contact",
"depends": ["base"],
"data": [
"views/res_partner.xml",
],
"installable": True,
}
38 changes: 38 additions & 0 deletions partner_email_duplicate_warn/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * partner_email_duplicate_warn
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-11-02 12:37+0000\n"
"Last-Translator: Alexis de Lattre <[email protected]>\n"
"Language-Team: none\n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n > 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: partner_email_duplicate_warn
#: model:ir.model,name:partner_email_duplicate_warn.model_res_partner
msgid "Contact"
msgstr "Contact"

#. module: partner_email_duplicate_warn
#: model_terms:ir.ui.view,arch_db:partner_email_duplicate_warn.view_partner_form
msgid "Duplicate warning: partner"
msgstr "Avertissement doublon : le contact"

#. module: partner_email_duplicate_warn
#: model:ir.model.fields,field_description:partner_email_duplicate_warn.field_res_partner__same_email_partner_id
#: model:ir.model.fields,field_description:partner_email_duplicate_warn.field_res_users__same_email_partner_id
msgid "Partner with same e-mail"
msgstr "Partenaire avec le même e-mail"

#. module: partner_email_duplicate_warn
#: model_terms:ir.ui.view,arch_db:partner_email_duplicate_warn.view_partner_form
msgid "has the same <b>Email</b>."
msgstr "a le même <b>E-mail</b>."
39 changes: 39 additions & 0 deletions partner_email_duplicate_warn/i18n/hr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * partner_email_duplicate_warn
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-06-08 14:11+0000\n"
"Last-Translator: Bole <[email protected]>\n"
"Language-Team: none\n"
"Language: hr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
"X-Generator: Weblate 4.17\n"

#. module: partner_email_duplicate_warn
#: model:ir.model,name:partner_email_duplicate_warn.model_res_partner
msgid "Contact"
msgstr "Kontakt"

#. module: partner_email_duplicate_warn
#: model_terms:ir.ui.view,arch_db:partner_email_duplicate_warn.view_partner_form
msgid "Duplicate warning: partner"
msgstr "Upozorenje o duplikatu: Partner"

#. module: partner_email_duplicate_warn
#: model:ir.model.fields,field_description:partner_email_duplicate_warn.field_res_partner__same_email_partner_id
#: model:ir.model.fields,field_description:partner_email_duplicate_warn.field_res_users__same_email_partner_id
msgid "Partner with same e-mail"
msgstr "Partner sa istom email adresom"

#. module: partner_email_duplicate_warn
#: model_terms:ir.ui.view,arch_db:partner_email_duplicate_warn.view_partner_form
msgid "has the same <b>Email</b>."
msgstr "ima isti <b>Email</b>."
38 changes: 38 additions & 0 deletions partner_email_duplicate_warn/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * partner_email_duplicate_warn
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-12-27 09:37+0000\n"
"Last-Translator: mymage <[email protected]>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: partner_email_duplicate_warn
#: model:ir.model,name:partner_email_duplicate_warn.model_res_partner
msgid "Contact"
msgstr "Contatto"

#. module: partner_email_duplicate_warn
#: model_terms:ir.ui.view,arch_db:partner_email_duplicate_warn.view_partner_form
msgid "Duplicate warning: partner"
msgstr "Avviso duplicato: partner"

#. module: partner_email_duplicate_warn
#: model:ir.model.fields,field_description:partner_email_duplicate_warn.field_res_partner__same_email_partner_id
#: model:ir.model.fields,field_description:partner_email_duplicate_warn.field_res_users__same_email_partner_id
msgid "Partner with same e-mail"
msgstr "Fornitori con la stessa e-mail"

#. module: partner_email_duplicate_warn
#: model_terms:ir.ui.view,arch_db:partner_email_duplicate_warn.view_partner_form
msgid "has the same <b>Email</b>."
msgstr "ha la stessa <b>e-mail</b>."
35 changes: 35 additions & 0 deletions partner_email_duplicate_warn/i18n/partner_email_duplicate_warn.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * partner_email_duplicate_warn
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \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: partner_email_duplicate_warn
#: model:ir.model,name:partner_email_duplicate_warn.model_res_partner
msgid "Contact"
msgstr ""

#. module: partner_email_duplicate_warn
#: model_terms:ir.ui.view,arch_db:partner_email_duplicate_warn.view_partner_form_with_email_warning
msgid "Duplicate warning: partner"
msgstr ""

#. module: partner_email_duplicate_warn
#: model:ir.model.fields,field_description:partner_email_duplicate_warn.field_res_partner__same_email_partner_id
#: model:ir.model.fields,field_description:partner_email_duplicate_warn.field_res_users__same_email_partner_id
msgid "Partner with same e-mail"
msgstr ""

#. module: partner_email_duplicate_warn
#: model_terms:ir.ui.view,arch_db:partner_email_duplicate_warn.view_partner_form_with_email_warning
msgid "has the same <b>Email</b>."
msgstr ""
1 change: 1 addition & 0 deletions partner_email_duplicate_warn/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import res_partner
48 changes: 48 additions & 0 deletions partner_email_duplicate_warn/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright 2021 Akretion France (http://www.akretion.com/)
# @author: Alexis de Lattre <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class ResPartner(models.Model):
_inherit = "res.partner"

same_email_partner_id = fields.Many2one(
"res.partner",
compute="_compute_same_email_partner_id",
string="Partner with same e-mail",
compute_sudo=True,
)

@api.depends("email", "company_id")
def _compute_same_email_partner_id(self):
for partner in self:
same_email_partner_id = False
if partner.email and partner.email.strip():
partner_email = partner.email.strip().lower()
domain = [("email", "=ilike", "%" + partner_email + "%")]
if partner.company_id:
domain += [
"|",
("company_id", "=", False),
("company_id", "=", partner.company_id.id),
]
partner_id = partner._origin.id
if partner_id:
domain += [
("id", "!=", partner_id),
"!",
("id", "child_of", partner_id),
"!",
("id", "parent_of", partner_id),
]
search_partners = self.with_context(active_test=False).search(domain)
for search_partner in search_partners:
if (
search_partner.email
and search_partner.email.strip().lower() == partner_email
):
same_email_partner_id = search_partner
break
partner.same_email_partner_id = same_email_partner_id
3 changes: 3 additions & 0 deletions partner_email_duplicate_warn/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
1 change: 1 addition & 0 deletions partner_email_duplicate_warn/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
No configuration required.
1 change: 1 addition & 0 deletions partner_email_duplicate_warn/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Alexis de Lattre \<<[email protected]>\>
11 changes: 11 additions & 0 deletions partner_email_duplicate_warn/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
This module adds a warning banner on the partner form view if another
partner has the same e-mail. It helps spot duplicate partners. If the
duplication is confirmed, the user can then use the native partner merge
wizard available from the partner tree view (menu *Action \> Merge*).

![](static/description/partner_warn_banner.png)

It is similar to the native warning banner when another partner has the
same VAT number. T his module has a twin brother named
**partner_mobile_duplicate_warn** which adds a warning banner when
another partner has the same mobile phone number.
4 changes: 4 additions & 0 deletions partner_email_duplicate_warn/readme/ROADMAP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- Add a button "Merge partner" in the end of the warning message to save
clicks to user.
- Set same_email_partner_id as Many2many and find a way to display all
the duplicate in the warning banner with clickable links.
7 changes: 7 additions & 0 deletions partner_email_duplicate_warn/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
The warning banner is displayed on the partner form view if another
partner: - has the same e-mail address (independantly from the case,
from starting spaces and ending spaces), - is not the parent nor the
child of the partner, - if the partner is attached to a specific
company: is in the same company or is not attached to a specific
company, - if the partner is not attached to a specific company: is in
any company or not attached to a specific company.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading