[MIG] mass_mailing_partner: Migration to 15.0
This commit is contained in:
parent
b7fdd5a1c1
commit
9ac22d2db7
@ -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",
|
||||
|
@ -13,21 +13,18 @@ _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"]
|
||||
partner_model = env["res.partner"]
|
||||
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
|
||||
)
|
||||
if partners:
|
||||
contact.write({"partner_id": partners.id})
|
||||
# ACTION 2: Match existing statistics
|
||||
stat_model = env["mailing.trace"]
|
||||
stats = stat_model.search([("model", "!=", False), ("res_id", "!=", False)])
|
||||
_logger.info("Trying to link %d mass mailing statistics to partner", len(stats))
|
||||
stats.partner_link()
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
# ACTION 1: Match existing contacts
|
||||
contact_model = env["mailing.contact"]
|
||||
partner_model = env["res.partner"]
|
||||
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)
|
||||
if partners:
|
||||
contact.write({"partner_id": partners.id})
|
||||
# ACTION 2: Match existing statistics
|
||||
stat_model = env["mailing.trace"]
|
||||
stats = stat_model.search([("model", "!=", False), ("res_id", "!=", False)])
|
||||
_logger.info("Trying to link %d mass mailing statistics to partner", len(stats))
|
||||
stats.partner_link()
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user