[IMP] mass_mailing: support batch creation
See merge commit for more details. Task ID-2330149 COM PR odoo/odoo#61246 ENT PR odoo/enterprise#14561 Co-Authored-By: Thibault Delavallée <tde@odoo.com> Co-Authored-By: Victor Feyens <vfe@odoo.com>
This commit is contained in:
committed by
Thibault Delavallée
co-authored by
Thibault Delavallée
parent
e045e5d925
commit
3dc757008f
@@ -293,13 +293,15 @@ class MassMailing(models.Model):
|
||||
# ORM
|
||||
# ------------------------------------------------------
|
||||
|
||||
@api.model
|
||||
def create(self, values):
|
||||
if values.get('subject') and not values.get('name'):
|
||||
values['name'] = "%s %s" % (values['subject'], datetime.strftime(fields.datetime.now(), tools.DEFAULT_SERVER_DATETIME_FORMAT))
|
||||
if values.get('body_html'):
|
||||
values['body_html'] = self._convert_inline_images_to_urls(values['body_html'])
|
||||
return super(MassMailing, self).create(values)
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
now = fields.Datetime.now()
|
||||
for values in vals_list:
|
||||
if values.get('subject') and not values.get('name'):
|
||||
values['name'] = "%s %s" % (values['subject'], now)
|
||||
if values.get('body_html'):
|
||||
values['body_html'] = self._convert_inline_images_to_urls(values['body_html'])
|
||||
return super().create(vals_list)
|
||||
|
||||
def write(self, values):
|
||||
if values.get('body_html'):
|
||||
|
||||
@@ -27,15 +27,17 @@ class MassMailingContactListRel(models.Model):
|
||||
'A contact cannot be subscribed multiple times to the same list!')
|
||||
]
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
if 'opt_out' in vals:
|
||||
vals['unsubscription_date'] = vals['opt_out'] and fields.Datetime.now()
|
||||
return super(MassMailingContactListRel, self).create(vals)
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
now = fields.Datetime.now()
|
||||
for vals in vals_list:
|
||||
if 'opt_out' in vals:
|
||||
vals['unsubscription_date'] = now if vals['opt_out'] else False
|
||||
return super().create(vals_list)
|
||||
|
||||
def write(self, vals):
|
||||
if 'opt_out' in vals:
|
||||
vals['unsubscription_date'] = vals['opt_out'] and fields.Datetime.now()
|
||||
vals['unsubscription_date'] = fields.Datetime.now() if vals['opt_out'] else False
|
||||
return super(MassMailingContactListRel, self).write(vals)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user