[IMP] account,l10n_es_edi_facturae,l10n_it_edi: Send & Print only given options

Add the possibility to call the send & print with *only* a set of options.
All other checkboxes are therefore set to False, instead of their default computed value.

closes odoo/odoo#157532

Related: odoo/enterprise#58574
Signed-off-by: Laurent Smet (las) <las@odoo.com>
This commit is contained in:
Claire Bretton (clbr)
2024-03-14 08:06:24 +00:00
parent d7cfc3844c
commit d5ccb8dff1
4 changed files with 38 additions and 0 deletions
@@ -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
@@ -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)
@@ -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
# -------------------------------------------------------------------------
@@ -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
# -------------------------------------------------------------------------