From a1c7a6a83862aa6027f10bdd03efb970ff642094 Mon Sep 17 00:00:00 2001 From: kpt-odoo Date: Fri, 12 Apr 2024 10:17:47 +0530 Subject: [PATCH] [FIX] payment: enhance log message for payment requests Before this commit, the log message did not clearly indicate who attempted to request a payment. After this commit, the message specifies whether the payment request was initiated by the customer or by the system. task-3864521 closes odoo/odoo#161252 Signed-off-by: Victor Feyens (vfe) --- addons/account_payment/models/payment_transaction.py | 8 ++++---- addons/sale/models/payment_transaction.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/addons/account_payment/models/payment_transaction.py b/addons/account_payment/models/payment_transaction.py index 8d0b6de63e3..62f2fa7fae8 100644 --- a/addons/account_payment/models/payment_transaction.py +++ b/addons/account_payment/models/payment_transaction.py @@ -196,15 +196,15 @@ class PaymentTransaction(models.Model): :return: None """ self.ensure_one() - self = self.with_user(SUPERUSER_ID) # Log messages as 'OdooBot' + author = self.env.user.partner_id if self.env.uid == SUPERUSER_ID else self.partner_id if self.source_transaction_id: for invoice in self.source_transaction_id.invoice_ids: - invoice.message_post(body=message) + invoice.message_post(body=message, author_id=author.id) payment_id = self.source_transaction_id.payment_id if payment_id: - payment_id.message_post(body=message) + payment_id.message_post(body=message, author_id=author.id) for invoice in self.invoice_ids: - invoice.message_post(body=message) + invoice.message_post(body=message, author_id=author.id) #=== BUSINESS METHODS - POST-PROCESSING ===# diff --git a/addons/sale/models/payment_transaction.py b/addons/sale/models/payment_transaction.py index cccb02941a2..28a0e44c0c4 100644 --- a/addons/sale/models/payment_transaction.py +++ b/addons/sale/models/payment_transaction.py @@ -106,9 +106,9 @@ class PaymentTransaction(models.Model): :return: None """ super()._log_message_on_linked_documents(message) - self = self.with_user(SUPERUSER_ID) # Log messages as 'OdooBot' + author = self.env.user.partner_id if self.env.uid == SUPERUSER_ID else self.partner_id for order in self.sale_order_ids or self.source_transaction_id.sale_order_ids: - order.message_post(body=message) + order.message_post(body=message, author_id=author.id) def _reconcile_after_done(self): """ Override of payment to automatically confirm quotations and generate invoices. """