From fd31627fa64d4390fe855aa2fae84f1a9f05ba80 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 16 May 2023 19:43:40 +0200 Subject: [PATCH] account_usability: add link from/to reverse journal entry in chatter --- account_usability/models/account_move.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/account_usability/models/account_move.py b/account_usability/models/account_move.py index 76954c4..39752da 100644 --- a/account_usability/models/account_move.py +++ b/account_usability/models/account_move.py @@ -112,6 +112,16 @@ class AccountMove(models.Model): # self.invalidate_cache() # return res + def _reverse_moves(self, default_values_list=None, cancel=False): + reverse_moves = super()._reverse_moves( + default_values_list=default_values_list, cancel=cancel) + # In the simple scenario 1 invoice -> 1 refund, we add a message in the chatter + # of the invoice and in the chatter of the refund + if len(self) == 1 and len(reverse_moves) == 1: + self.message_post(body=_("A reverse journal entry %s has been generated.") % (reverse_moves.id, reverse_moves.display_name)) + reverse_moves.message_post(body=_("This journal entry has been generated as the reverse of %s.") % (self.id, self.display_name)) + return reverse_moves + def delete_lines_qty_zero(self): lines = self.env['account.move.line'].search([ ('display_type', '=', False),