diff --git a/addons/mass_mailing/models/mailing.py b/addons/mass_mailing/models/mailing.py index 06483415ab4..5715129952c 100644 --- a/addons/mass_mailing/models/mailing.py +++ b/addons/mass_mailing/models/mailing.py @@ -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'): diff --git a/addons/mass_mailing/models/mailing_contact.py b/addons/mass_mailing/models/mailing_contact.py index 6ebd1132820..16a13125359 100644 --- a/addons/mass_mailing/models/mailing_contact.py +++ b/addons/mass_mailing/models/mailing_contact.py @@ -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)