Skip to content

Commit

Permalink
[IMP] account,l10n_es_edi_facturae,l10n_it_edi: Send & Print only giv…
Browse files Browse the repository at this point in the history
…en 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#157532

Related: odoo/enterprise#58574
Signed-off-by: Laurent Smet (las) <las@odoo.com>
  • Loading branch information
clbr-odoo committed Mar 14, 2024
1 parent d7cfc38 commit d5ccb8d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
9 changes: 9 additions & 0 deletions addons/account/tests/test_account_move_send.py
Original file line number Diff line number Diff line change
Expand Up @@ -1049,3 +1049,12 @@ def _hook_invoice_document_before_pdf_report_render(self, invoice, invoice_data)
)
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
8 changes: 8 additions & 0 deletions addons/account/wizard/account_move_send.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,14 @@ def _get_wizard_values(self):
'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)
Expand Down
10 changes: 10 additions & 0 deletions addons/l10n_es_edi_facturae/wizard/account_move_send.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ def _get_wizard_values(self):
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
# -------------------------------------------------------------------------
Expand Down
11 changes: 11 additions & 0 deletions addons/l10n_it_edi/wizard/account_move_send.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@ def _get_wizard_values(self):
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
# -------------------------------------------------------------------------
Expand Down

0 comments on commit d5ccb8d

Please sign in to comment.