diff --git a/addons/account/tests/test_account_move_send.py b/addons/account/tests/test_account_move_send.py index 6d46ad224ec..7593d95030b 100644 --- a/addons/account/tests/test_account_move_send.py +++ b/addons/account/tests/test_account_move_send.py @@ -1049,3 +1049,12 @@ class TestAccountMoveSend(TestAccountMoveSendCommon): ) self.assertEqual(json.loads(bus_2.message)['payload']['type'], 'warning') self.assertEqual(json.loads(bus_2.message)['payload']['action_button']['res_ids'], invoices_error.ids) + + def test_send_and_print_only(self): + invoice = self.init_invoice("out_invoice", amounts=[1000], post=True) + option_vals = self.env['account.move.send']._get_wizard_vals_restrict_to({'checkbox_send_mail': True}) + wizard = self.create_send_and_print(invoice, **option_vals) + res = wizard.action_send_and_print() + + self.assertTrue(self._get_mail_message(invoice)) # email was sent + self.assertEqual(res['type'], 'ir.actions.act_window_close') # the download which is a default value didn't happen diff --git a/addons/account/wizard/account_move_send.py b/addons/account/wizard/account_move_send.py index 00366a13c48..5676512cb30 100644 --- a/addons/account/wizard/account_move_send.py +++ b/addons/account/wizard/account_move_send.py @@ -146,6 +146,14 @@ class AccountMoveSend(models.TransientModel): 'send_mail': self.checkbox_send_mail, } + @api.model + def _get_wizard_vals_restrict_to(self, only_options): + return { + 'checkbox_download': False, + 'checkbox_send_mail': False, + **only_options, + } + def _get_mail_move_values(self, move, wizard=None): mail_template_id = move.send_and_print_values and move.send_and_print_values.get('mail_template_id') mail_template = wizard and wizard.mail_template_id or self.env['mail.template'].browse(mail_template_id) diff --git a/addons/l10n_es_edi_facturae/wizard/account_move_send.py b/addons/l10n_es_edi_facturae/wizard/account_move_send.py index ab91de00b33..9cea2344da9 100644 --- a/addons/l10n_es_edi_facturae/wizard/account_move_send.py +++ b/addons/l10n_es_edi_facturae/wizard/account_move_send.py @@ -16,6 +16,16 @@ class AccountMoveSend(models.TransientModel): values['l10n_es_edi_facturae_xml'] = self.l10n_es_edi_facturae_checkbox_xml return values + @api.model + def _get_wizard_vals_restrict_to(self, only_options): + # EXTENDS 'account' + values = super()._get_wizard_vals_restrict_to(only_options) + return { + **values, + 'l10n_es_edi_facturae_checkbox_xml': False, + **only_options, + } + # ------------------------------------------------------------------------- # COMPUTE METHODS # ------------------------------------------------------------------------- diff --git a/addons/l10n_it_edi/wizard/account_move_send.py b/addons/l10n_it_edi/wizard/account_move_send.py index fef6a3ad397..b64c7df313c 100644 --- a/addons/l10n_it_edi/wizard/account_move_send.py +++ b/addons/l10n_it_edi/wizard/account_move_send.py @@ -33,6 +33,17 @@ class AccountMoveSend(models.TransientModel): values['l10n_it_edi_checkbox_send'] = self.l10n_it_edi_checkbox_send return values + @api.model + def _get_wizard_vals_restrict_to(self, only_options): + # EXTENDS 'account' + values = super()._get_wizard_vals_restrict_to(only_options) + return { + **values, + 'l10n_it_edi_checkbox_xml_export': False, + 'l10n_it_edi_checkbox_send': False, + **only_options, + } + # ------------------------------------------------------------------------- # COMPUTE/CONSTRAINS METHODS # -------------------------------------------------------------------------