diff --git a/addons/account/tests/test_account_move_send.py b/addons/account/tests/test_account_move_send.py index ef5057bcc51..5021a10665e 100644 --- a/addons/account/tests/test_account_move_send.py +++ b/addons/account/tests/test_account_move_send.py @@ -888,8 +888,8 @@ class TestAccountMoveSend(TestAccountMoveSendCommon): self.assertFalse(invoice.invoice_pdf_report_id) self.assertTrue(invoice.message_main_attachment_id) - def test_with_empty_mail_template(self): - """ Test you can use the send & print wizard without any mail template. """ + def test_with_empty_mail_template_single(self): + """ Test you can use the send & print wizard without any mail template if and only if you are in single mode. """ self.partner_a.email = "turlututu@tsointsoin" invoice = self.init_invoice("out_invoice", amounts=[1000], post=True) @@ -900,6 +900,18 @@ class TestAccountMoveSend(TestAccountMoveSendCommon): message = self.env['mail.message'].search([('model', '=', invoice._name), ('res_id', '=', invoice.id)], limit=1) self.assertRecordValues(message, [{'subject': custom_subject}]) + def test_with_empty_mail_template_multi(self): + """ Test shouldn't be able to send email without mail template in multi mode. """ + self.partner_a.email = "turlututu@tsointsoin" + invoice_1 = self.init_invoice("out_invoice", amounts=[1000], post=True) + invoice_2 = self.init_invoice("out_invoice", amounts=[1000], post=True) + + custom_subject = "turlututu" + wizard = self.create_send_and_print((invoice_1 + invoice_2), mail_template_id=None, mail_subject=custom_subject) + + with self.assertRaises(UserError): + wizard.action_send_and_print(allow_fallback_pdf=True) + def test_with_draft_invoices(self): """ Use Send & Print wizard on draft invoice(s) should raise an error. """ invoice_posted = self.init_invoice("out_invoice", amounts=[1000], post=True) diff --git a/addons/account/wizard/account_move_send.py b/addons/account/wizard/account_move_send.py index 9789afe98da..e4df2e30978 100644 --- a/addons/account/wizard/account_move_send.py +++ b/addons/account/wizard/account_move_send.py @@ -653,6 +653,10 @@ class AccountMoveSend(models.TransientModel): proforma PDF report instead. """ self.ensure_one() + + if self.mode == 'invoice_multi' and self.checkbox_send_mail and not self.mail_template_id: + raise UserError(_('Please select a mail template to send multiple invoices.')) + force_synchronous = force_synchronous or self.checkbox_download process_later = self.mode == 'invoice_multi' and not force_synchronous if process_later: diff --git a/addons/account/wizard/account_move_send_views.xml b/addons/account/wizard/account_move_send_views.xml index 74f18544498..14d9f2ce07d 100644 --- a/addons/account/wizard/account_move_send_views.xml +++ b/addons/account/wizard/account_move_send_views.xml @@ -80,6 +80,7 @@