[MIG] mass_mailing_partner: Migration to 15.0

This commit is contained in:
emagdalenaC2i 2022-01-01 16:25:45 +01:00
parent b7fdd5a1c1
commit 9ac22d2db7
3 changed files with 18 additions and 21 deletions

View File

@ -6,7 +6,7 @@
{
"name": "Link partners with mass-mailing",
"version": "14.0.1.0.1",
"version": "15.0.1.0.0",
"author": "Tecnativa, " "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/social",
"license": "AGPL-3",

View File

@ -13,7 +13,6 @@ _logger = logging.getLogger(__name__)
def post_init_hook(cr, registry):
with api.Environment.manage():
env = api.Environment(cr, SUPERUSER_ID, {})
# ACTION 1: Match existing contacts
contact_model = env["mailing.contact"]
@ -21,9 +20,7 @@ def post_init_hook(cr, registry):
contacts = contact_model.search([("email", "!=", False)])
_logger.info("Trying to match %d contacts to partner by email", len(contacts))
for contact in contacts:
partners = partner_model.search(
[("email", "=ilike", contact.email)], limit=1
)
partners = partner_model.search([("email", "=ilike", contact.email)], limit=1)
if partners:
contact.write({"partner_id": partners.id})
# ACTION 2: Match existing statistics

View File

@ -9,7 +9,7 @@
<field name="model">mailing.trace</field>
<field name="inherit_id" ref="mass_mailing.mailing_trace_view_form" />
<field name="arch" type="xml">
<field name="res_id" position="after">
<field name="message_id" position="after">
<field name="partner_id" />
</field>
</field>
@ -20,7 +20,7 @@
<field name="model">mailing.trace</field>
<field name="inherit_id" ref="mass_mailing.mailing_trace_view_tree" />
<field name="arch" type="xml">
<field name="sent" position="before">
<field name="sent_datetime" position="before">
<field name="partner_id" />
</field>
</field>