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

[15.0][MIG] mass_mailing_contact_partner #1297

Closed
Closed
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
94 changes: 94 additions & 0 deletions mass_mailing_contact_partner/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
============================
Mass Mailing Contact Partner
============================

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

.. |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%2Fsocial-lightgray.png?logo=github
:target: https://github.com/OCA/social/tree/15.0/mass_mailing_contact_partner
:alt: OCA/social
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/social-15-0/social-15-0-mass_mailing_contact_partner
: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/social&target_branch=15.0
:alt: Try me on Runboat

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

This module links mailing.contacts with res.partners.

The same mailing.contact can be linked to multiple partners, if they
share the same email address.

This module is different than `mass_mailing_partner` because the relationship
is in the opposite direction.

It's recommended to use it with `mass_mailing_unique` module.

**Table of contents**

.. contents::
:local:

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/social/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/social/issues/new?body=module:%20mass_mailing_contact_partner%0Aversion:%2015.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
~~~~~~~

* Camptocamp

Contributors
~~~~~~~~~~~~

* `Camptocamp <https://www.camptocamp.com>`_

* Iván Todorovich <ivan.todorovich@gmail.com>

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-ivantodorovich| image:: https://github.com/ivantodorovich.png?size=40px
:target: https://github.com/ivantodorovich
:alt: ivantodorovich

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

|maintainer-ivantodorovich|

This module is part of the `OCA/social <https://github.com/OCA/social/tree/15.0/mass_mailing_contact_partner>`_ 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 mass_mailing_contact_partner/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
16 changes: 16 additions & 0 deletions mass_mailing_contact_partner/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2021 Camptocamp (http://www.camptocamp.com).
# @author Iván Todorovich <ivan.todorovich@gmail.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Mass Mailing Contact Partner",
"summary": "Links mailing.contacts with res.partners.",
"version": "15.0.1.0.0",
"author": "Camptocamp, Odoo Community Association (OCA)",
"maintainers": ["ivantodorovich"],
"website": "https://github.com/OCA/social",
"license": "AGPL-3",
"category": "Marketing",
"depends": ["mass_mailing"],
"data": ["views/mailing_contact.xml"],
}
70 changes: 70 additions & 0 deletions mass_mailing_contact_partner/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mass_mailing_contact_partner
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-01-26 19:33+0000\n"
"Last-Translator: Ivorra78 <informatica@totmaterial.es>\n"
"Language-Team: none\n"
"Language: es\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: mass_mailing_contact_partner
#: model:ir.model,name:mass_mailing_contact_partner.model_res_partner
msgid "Contact"
msgstr "Contacto"

#. module: mass_mailing_contact_partner
#: model:ir.model.fields,field_description:mass_mailing_contact_partner.field_mailing_contact__display_name
#: model:ir.model.fields,field_description:mass_mailing_contact_partner.field_res_partner__display_name
msgid "Display Name"
msgstr "Mostrar Nombre"

#. module: mass_mailing_contact_partner
#: model:ir.model.fields,field_description:mass_mailing_contact_partner.field_mailing_contact__id
#: model:ir.model.fields,field_description:mass_mailing_contact_partner.field_res_partner__id
msgid "ID"
msgstr "ID"

#. module: mass_mailing_contact_partner
#: model:ir.model.fields,field_description:mass_mailing_contact_partner.field_mailing_contact____last_update
#: model:ir.model.fields,field_description:mass_mailing_contact_partner.field_res_partner____last_update
msgid "Last Modified on"
msgstr "Última Modificación el"

#. module: mass_mailing_contact_partner
#: model:ir.model,name:mass_mailing_contact_partner.model_mailing_contact
msgid "Mailing Contact"
msgstr "Contacto por Correo"

#. module: mass_mailing_contact_partner
#: model:ir.model.fields,field_description:mass_mailing_contact_partner.field_res_partner__mailing_contact_id
#: model:ir.model.fields,field_description:mass_mailing_contact_partner.field_res_users__mailing_contact_id
msgid "Mass Mailing Contact"
msgstr "Contacto de Lista de Correo"

#. module: mass_mailing_contact_partner
#: model:ir.model.fields,field_description:mass_mailing_contact_partner.field_mailing_contact__partner_ids
#: model_terms:ir.ui.view,arch_db:mass_mailing_contact_partner.mailing_contact_view_form
msgid "Partners"
msgstr "Socios"

#. module: mass_mailing_contact_partner
#: model:ir.model.fields,field_description:mass_mailing_contact_partner.field_mailing_contact__partner_count
msgid "Partners Count"
msgstr "Conteo de Socios"

#. module: mass_mailing_contact_partner
#: model:ir.model.fields,help:mass_mailing_contact_partner.field_res_partner__mailing_contact_id
#: model:ir.model.fields,help:mass_mailing_contact_partner.field_res_users__mailing_contact_id
msgid "The mailing list contact that matches this partner's email."
msgstr ""
"El contacto de la lista de correo que coincide con el correo electrónico de "
"este socio."
68 changes: 68 additions & 0 deletions mass_mailing_contact_partner/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mass_mailing_contact_partner
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-12-07 13:35+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\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: mass_mailing_contact_partner
#: model:ir.model,name:mass_mailing_contact_partner.model_res_partner
msgid "Contact"
msgstr "Contatto"

#. module: mass_mailing_contact_partner
#: model:ir.model.fields,field_description:mass_mailing_contact_partner.field_mailing_contact__display_name
#: model:ir.model.fields,field_description:mass_mailing_contact_partner.field_res_partner__display_name
msgid "Display Name"
msgstr "Nome visualizzato"

#. module: mass_mailing_contact_partner
#: model:ir.model.fields,field_description:mass_mailing_contact_partner.field_mailing_contact__id
#: model:ir.model.fields,field_description:mass_mailing_contact_partner.field_res_partner__id
msgid "ID"
msgstr "ID"

#. module: mass_mailing_contact_partner
#: model:ir.model.fields,field_description:mass_mailing_contact_partner.field_mailing_contact____last_update
#: model:ir.model.fields,field_description:mass_mailing_contact_partner.field_res_partner____last_update
msgid "Last Modified on"
msgstr "Ultima modifica il"

#. module: mass_mailing_contact_partner
#: model:ir.model,name:mass_mailing_contact_partner.model_mailing_contact
msgid "Mailing Contact"
msgstr "Contatto spedizione"

#. module: mass_mailing_contact_partner
#: model:ir.model.fields,field_description:mass_mailing_contact_partner.field_res_partner__mailing_contact_id
#: model:ir.model.fields,field_description:mass_mailing_contact_partner.field_res_users__mailing_contact_id
msgid "Mass Mailing Contact"
msgstr "Contatto Mass Mailing"

#. module: mass_mailing_contact_partner
#: model:ir.model.fields,field_description:mass_mailing_contact_partner.field_mailing_contact__partner_ids
#: model_terms:ir.ui.view,arch_db:mass_mailing_contact_partner.mailing_contact_view_form
msgid "Partners"
msgstr "Partner"

#. module: mass_mailing_contact_partner
#: model:ir.model.fields,field_description:mass_mailing_contact_partner.field_mailing_contact__partner_count
msgid "Partners Count"
msgstr "Conteggio partner"

#. module: mass_mailing_contact_partner
#: model:ir.model.fields,help:mass_mailing_contact_partner.field_res_partner__mailing_contact_id
#: model:ir.model.fields,help:mass_mailing_contact_partner.field_res_users__mailing_contact_id
msgid "The mailing list contact that matches this partner's email."
msgstr "Il contatto della mailing list collegato all'email di questo contatto."
65 changes: 65 additions & 0 deletions mass_mailing_contact_partner/i18n/mass_mailing_contact_partner.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mass_mailing_contact_partner
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.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: mass_mailing_contact_partner
#: model:ir.model,name:mass_mailing_contact_partner.model_res_partner
msgid "Contact"
msgstr ""

#. module: mass_mailing_contact_partner
#: model:ir.model.fields,field_description:mass_mailing_contact_partner.field_mailing_contact__display_name
#: model:ir.model.fields,field_description:mass_mailing_contact_partner.field_res_partner__display_name
msgid "Display Name"
msgstr ""

#. module: mass_mailing_contact_partner
#: model:ir.model.fields,field_description:mass_mailing_contact_partner.field_mailing_contact__id
#: model:ir.model.fields,field_description:mass_mailing_contact_partner.field_res_partner__id
msgid "ID"
msgstr ""

#. module: mass_mailing_contact_partner
#: model:ir.model.fields,field_description:mass_mailing_contact_partner.field_mailing_contact____last_update
#: model:ir.model.fields,field_description:mass_mailing_contact_partner.field_res_partner____last_update
msgid "Last Modified on"
msgstr ""

#. module: mass_mailing_contact_partner
#: model:ir.model,name:mass_mailing_contact_partner.model_mailing_contact
msgid "Mailing Contact"
msgstr ""

#. module: mass_mailing_contact_partner
#: model:ir.model.fields,field_description:mass_mailing_contact_partner.field_res_partner__mailing_contact_id
#: model:ir.model.fields,field_description:mass_mailing_contact_partner.field_res_users__mailing_contact_id
msgid "Mass Mailing Contact"
msgstr ""

#. module: mass_mailing_contact_partner
#: model:ir.model.fields,field_description:mass_mailing_contact_partner.field_mailing_contact__partner_ids
#: model_terms:ir.ui.view,arch_db:mass_mailing_contact_partner.mailing_contact_view_form
msgid "Partners"
msgstr ""

#. module: mass_mailing_contact_partner
#: model:ir.model.fields,field_description:mass_mailing_contact_partner.field_mailing_contact__partner_count
msgid "Partners Count"
msgstr ""

#. module: mass_mailing_contact_partner
#: model:ir.model.fields,help:mass_mailing_contact_partner.field_res_partner__mailing_contact_id
#: model:ir.model.fields,help:mass_mailing_contact_partner.field_res_users__mailing_contact_id
msgid "The mailing list contact that matches this partner's email."
msgstr ""
2 changes: 2 additions & 0 deletions mass_mailing_contact_partner/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import mailing_contact
from . import res_partner
74 changes: 74 additions & 0 deletions mass_mailing_contact_partner/models/mailing_contact.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Copyright 2021 Camptocamp (http://www.camptocamp.com).
# @author Iván Todorovich <ivan.todorovich@gmail.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class MailingContact(models.Model):
_inherit = "mailing.contact"

partner_ids = fields.One2many(
"res.partner",
"mailing_contact_id",
string="Partners",
readonly=True,
)
partner_count = fields.Integer(
string="Partners Count",
compute="_compute_partner_count",
)

@api.model_create_multi
def create(self, vals_list):
# Try to relate partners with the same email.
records = super().create(vals_list)
records._recompute_partner_relation()
return records

def write(self, vals):
# If email is updated, it may render the partner relations outdated.
# Recompute all partners with prev and current email.
if "email" in vals:
prev_emails = [rec.email_normalized for rec in self]
res = super().write(vals)
if "email" in vals:
self._recompute_partner_relation(include_emails=prev_emails)
return res

def _recompute_partner_relation(self, include_emails=None):
"""Recomputes partner mailing_contact_id relation

Our relation is based on the email field, not a real FK.

In case new records are created, or their emails are updated,
we need to also update the related partners relations.
"""
emails = self.mapped("email_normalized")
if include_emails:
emails += include_emails
# Make sure they're unique
emails = list(set(emails))
if not emails: # pragma: no cover
return
partners = self.env["res.partner"].search([("email_normalized", "in", emails)])
partners._compute_mailing_contact_id()

@api.depends("partner_ids")
def _compute_partner_count(self):
results = self.env["res.partner"].read_group(
[("mailing_contact_id", "in", self.ids)],
fields=["mailing_contact_id"],
groupby=["mailing_contact_id"],
)
count_map = {
x["mailing_contact_id"][0]: x["mailing_contact_id_count"] for x in results
}
for rec in self:
rec.partner_count = count_map.get(rec.id, 0)

def action_view_partner_ids(self):
action = self.env["ir.actions.actions"]._for_xml_id("base.action_partner_form")
action["domain"] = [("mailing_contact_id", "in", self.ids)]
action["context"] = False
return action
Loading
Loading