From 6fc58cd0c6e86ecd98ec2d4625158b2245f47270 Mon Sep 17 00:00:00 2001 From: "Valentin Vallaeys (vava)" Date: Wed, 14 Sep 2022 13:13:52 +0000 Subject: [PATCH] [IMP] payment: remove duplicate chatter message The confirmation message for the sale order appeared twice in the chatter: first with the confirmation and second with the posted payment. The second message is now rephrased in order to avoid any confusion for the user (no double payment). task-2965158 closes odoo/odoo#101921 X-original-commit: c1faff69db2a66e249bfbc5ea77644da0957d401 Signed-off-by: Antoine Vandevenne (anv) Signed-off-by: Vallaeys Valentin (vava) --- .../models/payment_transaction.py | 23 +++++++++---------- addons/payment/models/payment_transaction.py | 1 - 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/addons/account_payment/models/payment_transaction.py b/addons/account_payment/models/payment_transaction.py index 48e7e04a65b..7741839f00e 100644 --- a/addons/account_payment/models/payment_transaction.py +++ b/addons/account_payment/models/payment_transaction.py @@ -188,19 +188,18 @@ class PaymentTransaction(models.Model): for invoice in self.invoice_ids: invoice.message_post(body=message) - #=== BUSINESS METHODS - GETTERS ===# + #=== BUSINESS METHODS - POST-PROCESSING ===# - def _get_received_message(self): - """ Return the message stating that the transaction has been received by the provider. + def _finalize_post_processing(self): + """ Override of `payment` to write a message in the chatter with the payment and transaction + references. - Note: self.ensure_one() + :return: None """ - message = super()._get_received_message() - - if self.state == 'done' and self.payment_id: - message += "
" + _( - "The related payment is posted: %s", - self.payment_id._get_html_link() + super()._finalize_post_processing() + for tx in self.filtered('payment_id'): + message = _( + "The payment related to the transaction with reference %(ref)s has been posted: " + "%(link)s", ref=tx.reference, link=tx.payment_id._get_html_link() ) - - return message + tx._log_message_on_linked_documents(message) diff --git a/addons/payment/models/payment_transaction.py b/addons/payment/models/payment_transaction.py index 24e231baf62..b2f61bdbf31 100644 --- a/addons/payment/models/payment_transaction.py +++ b/addons/payment/models/payment_transaction.py @@ -839,7 +839,6 @@ class PaymentTransaction(models.Model): :return: None """ self._reconcile_after_done() - self._log_received_message() # 2nd call to link the created account.payment in the chatter self.is_post_processed = True def _cron_finalize_post_processing(self):