Skip to content

Commit

Permalink
[FIX] account: Remove is_move_sent change 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 `is_move_sent`: False on when resetting the account move to draft.
This guarantees, that once the move has been sent via action_send_and_print, it will be marked as sent.

Steps to Reproduce on Runbot:
Create and Send and Print invoice. (is_move_sent is set to True)
Reset invoice to draft. (is_move_sent is set to False)
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 saas-16.3  with this PR #125392. is_move_sent is not updated 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 May 17, 2024
1 parent aa608bb commit 7d29132
Show file tree
Hide file tree
Showing 2 changed files with 15 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 @@ -4121,7 +4121,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.state = 'draft'

def button_cancel(self):
self.write({'auto_post': 'no', 'state': 'cancel'})
Expand Down
14 changes: 14 additions & 0 deletions addons/account/tests/test_account_move_send.py
Original file line number Diff line number Diff line change
Expand Up @@ -880,3 +880,17 @@ def test_with_draft_invoices(self):
self.create_send_and_print(invoice_draft)
with self.assertRaises(UserError):
self.create_send_and_print(invoice_posted + invoice_draft)

def test_out_invoice_is_move_sent(self):
invoice = self.init_invoice(move_type='out_invoice', amounts=[1000.0], post=True)
wizard = self.create_send_and_print(invoice)

self.assertEqual(invoice.state, 'posted')
self.assertFalse(invoice.is_move_sent)

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

invoice.button_draft()
self.assertEqual(invoice.state, 'draft')
self.assertTrue(invoice.is_move_sent)

0 comments on commit 7d29132

Please sign in to comment.