[IMP] mass_mailing: add 'create_date' in subscription list view
This commit will add create_date field in view to display it as 'Subscription Date' to the user so that concerned people can know when did the contact subscribed into a mailing list. Here, now when we will import contacts in mailing.contacts we are linking the mailing_list in subscription_list_ids using Command to get the values of create_date. TaskId-2702607 Part-of: odoo/odoo#82107
This commit is contained in:
@@ -243,6 +243,7 @@ class TestMailingContactImport(MassMailCommon):
|
||||
# Test that the context key "default_list_ids" is ignored (because we manually set list_ids)
|
||||
contact_import.with_context(default_list_ids=(first_list | second_list).ids).action_import()
|
||||
|
||||
self.env['mailing.list'].invalidate_model(['contact_ids'])
|
||||
# Check the contact of the first mailing list
|
||||
contacts = [
|
||||
(contact.name, contact.email)
|
||||
|
||||
@@ -150,6 +150,7 @@
|
||||
<field name="opt_out_datetime" readonly="1"/>
|
||||
<field name="opt_out"/>
|
||||
<field name="opt_out_reason_id"/>
|
||||
<field name="create_date" string="Subscription Date"/>
|
||||
</tree>
|
||||
</field>
|
||||
</sheet>
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
aria-label="Blacklisted" invisible="not is_blacklisted" groups="base.group_user"></i>
|
||||
<field name="contact_id"/>
|
||||
</div>
|
||||
<field name="create_date" string="Subscription Date"/>
|
||||
<field name="opt_out_datetime" readonly="1"/>
|
||||
<field name="opt_out"/>
|
||||
<field name="opt_out_reason_id"/>
|
||||
@@ -32,6 +33,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Mailing List Subscriptions">
|
||||
<field name="contact_id"/>
|
||||
<field name="create_date" string="Subscription Date"/>
|
||||
<field name="list_id"/>
|
||||
<field name="opt_out"/>
|
||||
<field name="opt_out_reason_id"/>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import fields, models, tools, _
|
||||
from odoo import fields, models, tools, Command, _
|
||||
from odoo.tools.misc import clean_context
|
||||
|
||||
|
||||
@@ -63,7 +63,10 @@ class MailingContactImport(models.TransientModel):
|
||||
if email not in existing_contacts:
|
||||
unique_contacts[email] = {
|
||||
'name': name,
|
||||
'list_ids': self.mailing_list_ids.ids,
|
||||
'subscription_ids': [
|
||||
Command.create({'list_id': mailing_list_id.id})
|
||||
for mailing_list_id in self.mailing_list_ids
|
||||
],
|
||||
}
|
||||
|
||||
if not unique_contacts:
|
||||
|
||||
Reference in New Issue
Block a user