From 2dc5bf555f1cc96e3faa04563af2e0051489ed29 Mon Sep 17 00:00:00 2001 From: Valentin Chevalier Date: Wed, 14 Sep 2022 15:56:15 +0000 Subject: [PATCH] [IMP] account_payment, sale: log messages with superuser When payment providers receive a notification from a webhooks and log something in the chatter of transactions, sale orders or invoices, the message is shown as from 'Public User'. Now, all messages will be logged as 'OdooBot'. Part-of: odoo/odoo#100186 --- addons/account_payment/models/payment_transaction.py | 3 ++- addons/sale/models/payment_transaction.py | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/account_payment/models/payment_transaction.py b/addons/account_payment/models/payment_transaction.py index 1018cb61e95..48e7e04a65b 100644 --- a/addons/account_payment/models/payment_transaction.py +++ b/addons/account_payment/models/payment_transaction.py @@ -1,6 +1,6 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import api, fields, models, _ +from odoo import api, fields, models, SUPERUSER_ID, _ class PaymentTransaction(models.Model): @@ -180,6 +180,7 @@ class PaymentTransaction(models.Model): :return: None """ self.ensure_one() + self = self.with_user(SUPERUSER_ID) # Log messages as 'OdooBot' if self.source_transaction_id.payment_id: self.source_transaction_id.payment_id.message_post(body=message) for invoice in self.source_transaction_id.invoice_ids: diff --git a/addons/sale/models/payment_transaction.py b/addons/sale/models/payment_transaction.py index ef8f89e0634..78c24dcd0e0 100644 --- a/addons/sale/models/payment_transaction.py +++ b/addons/sale/models/payment_transaction.py @@ -98,6 +98,7 @@ class PaymentTransaction(models.Model): :return: None """ super()._log_message_on_linked_documents(message) + self = self.with_user(SUPERUSER_ID) # Log messages as 'OdooBot' for order in self.sale_order_ids: order.message_post(body=message)