Skip to content

Commit

Permalink
[FIX] account: Remove invoice_pdf_report_id on reset to draft
Browse files Browse the repository at this point in the history
Current Behavior:
`is_move_sent` is not updated if there is an existing `invoice_pdf_report_id`.

Purpose of this PR:
Remove the `invoice_pdf_report_id` when resetting invoice to draft so that when the invoice is sent again (using the Send and Print wizard),
`is_move_sent` is updated.

Steps to Reproduce on Runbot:
1) Create and Send and Print invoice. (`is_move_sent` is set to True)
2) Reset invoice to draft. (`is_move_sent` is set to False)
3) Confirm and resend invoice using Send and Print wizard. (`is_move_sent` remains False, expected to be changed to True)

Notes:
This PR #116698 added a _compute in Odoo 16, however it was removed in Odoo 17 with this PR #125392
`is_move_sent` is not updated when on the second Send and Print because of the existing `invoice_pdf_report_id` (generated and linked during the first Send and Print).

opw-3849109
  • Loading branch information
iada-odoo committed Apr 29, 2024
1 parent f168c4b commit 7c5a642
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion addons/account/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -4152,7 +4152,7 @@ def button_draft(self):
move.mapped('line_ids.analytic_line_ids').unlink()

self.mapped('line_ids').remove_move_reconcile()
self.write({'state': 'draft', 'is_move_sent': False})
self.write({'state': 'draft'})

def button_request_cancel(self):
""" Hook allowing the localizations to request a cancellation from the government before cancelling the invoice. """
Expand Down
8 changes: 8 additions & 0 deletions addons/account/tests/test_account_move_send.py
Original file line number Diff line number Diff line change
Expand Up @@ -1060,3 +1060,11 @@ def test_send_and_print_only(self):

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

def test_out_invoice_is_move_sent(self):
invoice = self.init_invoice(move_type='out_invoice', amounts=[1000.0], 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)

wizard.action_send_and_print()
self.assertTrue(invoice.is_move_sent)

0 comments on commit 7c5a642

Please sign in to comment.