diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py
index a4c826dddb370..a966db153a7ab 100644
--- a/addons/account/models/account_move.py
+++ b/addons/account/models/account_move.py
@@ -603,6 +603,16 @@ def _sequence_year_range_monthly_regex(self):
tracking=True,
help="It indicates that the invoice/payment has been sent or the PDF has been generated.",
)
+
+ move_sent_state = fields.Selection(
+ selection=[('not_sent', "Not Sent"), ('sent', "Sent")],
+ default='not_sent',
+ tracking=True,
+ copy=False,
+ readonly=True,
+ help="It indicates that the invoice/payment has been sent or the PDF has been generated.",
+ )
+
is_being_sent = fields.Boolean(
help="Is the move being sent asynchronously",
compute='_compute_is_being_sent'
diff --git a/addons/account/models/account_move_send.py b/addons/account/models/account_move_send.py
index 4cceccc5c6ec8..96bb82e54aa51 100644
--- a/addons/account/models/account_move_send.py
+++ b/addons/account/models/account_move_send.py
@@ -412,7 +412,7 @@ def _link_invoice_documents(self, invoices_data):
if attachment := res_id_to_attachment.get(invoice.id):
invoice.message_main_attachment_id = attachment
invoice.invalidate_recordset(fnames=['invoice_pdf_report_id', 'invoice_pdf_report_file'])
- invoice.is_move_sent = True
+ invoice.move_sent_state = 'sent'
@api.model
def _hook_if_errors(self, moves_data, allow_raising=True):
diff --git a/addons/account/tests/test_account_move_send.py b/addons/account/tests/test_account_move_send.py
index 033ac5c0ce6b9..fa720167c6aad 100644
--- a/addons/account/tests/test_account_move_send.py
+++ b/addons/account/tests/test_account_move_send.py
@@ -157,7 +157,7 @@ def test_move_composer_multi(self):
move_template = self.move_template.with_env(self.env)
for test_move in test_moves:
- self.assertFalse(test_move.is_move_sent)
+ self.assertEqual(test_move.move_sent_state, 'not_sent')
with self.mock_mail_gateway(mail_unlink_sent=False):
self.env['account.move.send']._generate_and_send_invoices(
@@ -214,7 +214,7 @@ def test_move_composer_multi(self):
# invoice update
for test_move in test_moves:
- self.assertTrue(test_move.is_move_sent)
+ self.assertEqual(test_move.move_sent_state, 'sent')
@users('user_account')
@warmup
@@ -256,10 +256,10 @@ def test_move_composer_single(self):
'Should take invoice_user_id email')
self.assertEqual(print_msg.notified_partner_ids, test_customer + self.user_accountman.partner_id)
self.assertEqual(print_msg.subject, f'{self.env.user.company_id.name} Invoice (Ref {test_move.name})')
- # tracking: is_move_sent
+ # tracking: move_sent_state
self.assertEqual(track_msg.author_id, self.env.user.partner_id)
self.assertEqual(track_msg.email_from, self.env.user.email_formatted)
- self.assertTrue('is_move_sent' in track_msg.tracking_value_ids.field_id.mapped('name'))
+ self.assertTrue('move_sent_state' in track_msg.tracking_value_ids.field_id.mapped('name'))
# sent email
self.assertMailMail(
test_customer,
@@ -301,7 +301,7 @@ def test_move_composer_single(self):
self.assertEqual(composer.mail_template_id, move_template)
# invoice update
- self.assertTrue(test_move.is_move_sent)
+ self.assertEqual(test_move.move_sent_state, 'sent')
@users('user_account')
@warmup
@@ -343,10 +343,10 @@ def test_move_composer_single_lang(self):
'Should take invoice_user_id email')
self.assertEqual(print_msg.notified_partner_ids, test_customer + self.user_accountman.partner_id)
self.assertEqual(print_msg.subject, f'SpanishSubject for {test_move.name}')
- # tracking: is_move_sent
+ # tracking: move_sent_state
self.assertEqual(track_msg.author_id, self.env.user.partner_id)
self.assertEqual(track_msg.email_from, self.env.user.email_formatted)
- self.assertTrue('is_move_sent' in track_msg.tracking_value_ids.field_id.mapped('name'))
+ self.assertTrue('move_sent_state' in track_msg.tracking_value_ids.field_id.mapped('name'))
# sent email
self.assertMailMail(
test_customer,
@@ -390,7 +390,7 @@ def test_move_composer_single_lang(self):
self.assertEqual(composer.mail_template_id, move_template)
# invoice update
- self.assertTrue(test_move.is_move_sent)
+ self.assertEqual(test_move.move_sent_state, 'sent')
@users('user_account')
@warmup
@@ -1061,22 +1061,22 @@ def _hook_invoice_document_before_pdf_report_render(self, invoice, invoice_data)
self.assertEqual(payload_2['type'], 'warning')
self.assertEqual(sorted(payload_2['action_button']['res_ids']), invoices_error.ids)
- def test_is_move_sent_state(self):
+ def test_move_sent_state(self):
# Post a move, nothing sent yet
invoice = self.init_invoice("out_invoice", amounts=[1000], post=True)
- self.assertFalse(invoice.is_move_sent)
+ self.assertEqual(invoice.move_sent_state, 'not_sent')
# Send via send & print
wizard = self.create_send_and_print(invoice)
wizard.action_send_and_print()
- self.assertTrue(invoice.is_move_sent)
+ self.assertEqual(invoice.move_sent_state, 'sent')
# Revert move to draft
invoice.button_draft()
- self.assertTrue(invoice.is_move_sent)
+ self.assertEqual(invoice.move_sent_state, 'sent')
# Unlink PDF
pdf_report = invoice.invoice_pdf_report_id
self.assertTrue(pdf_report)
invoice.invoice_pdf_report_id.unlink()
- self.assertTrue(invoice.is_move_sent)
+ self.assertEqual(invoice.move_sent_state, 'sent')
def test_no_sending_method_selected(self):
invoice = self.init_invoice("out_invoice", amounts=[1000], post=True)
@@ -1084,7 +1084,7 @@ def test_no_sending_method_selected(self):
wizard = self.create_send_and_print(invoice, sending_methods=[])
self.assertFalse(wizard.sending_methods)
wizard.action_send_and_print()
- self.assertTrue(invoice.is_move_sent)
+ self.assertEqual(invoice.move_sent_state, 'sent')
self.assertTrue(invoice.invoice_pdf_report_id)
def test_get_sending_settings(self):
diff --git a/addons/account/views/account_move_views.xml b/addons/account/views/account_move_views.xml
index 5ed5e8aa6eaeb..8cf9048873bf2 100644
--- a/addons/account/views/account_move_views.xml
+++ b/addons/account/views/account_move_views.xml
@@ -548,6 +548,12 @@
invisible="payment_state == 'invoicing_legacy' or move_type == 'entry'"
optional="show"
/>
+