[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", "name": "Link partners with mass-mailing",
"version": "14.0.1.0.1", "version": "15.0.1.0.0",
"author": "Tecnativa, " "Odoo Community Association (OCA)", "author": "Tecnativa, " "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/social", "website": "https://github.com/OCA/social",
"license": "AGPL-3", "license": "AGPL-3",

View File

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

View File

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