From 3489fd169f30d645f048d3cf627f3ba4752f8058 Mon Sep 17 00:00:00 2001
From: David Tran <david.tran@tvtmarine.com>
Date: Tue, 16 May 2023 07:32:26 +0000
Subject: [PATCH] [FIX] sale: log notes with wrong quotation viewer

The note "Quotation viewed by customer" posted when a public/portal user
access an order came with the order's partner name instead of the actual
user's partner name

This made confused for internal users to see something in internal note
like **Colleen Diaz** with a message **Quotation viewed by customer
Nicole Ford**

This commit makes sure to use the right partner name except the
quotation is viewed anonymously (with access token)

closes odoo/odoo#121490

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
---
 addons/sale/controllers/portal.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/addons/sale/controllers/portal.py b/addons/sale/controllers/portal.py
index 2b37f58b1266..5f7f5f511025 100644
--- a/addons/sale/controllers/portal.py
+++ b/addons/sale/controllers/portal.py
@@ -189,7 +189,7 @@ class CustomerPortal(CustomerPortal):
             session_obj_date = request.session.get('view_quote_%s' % order_sudo.id)
             if session_obj_date != now and request.env.user.share and access_token:
                 request.session['view_quote_%s' % order_sudo.id] = now
-                body = _('Quotation viewed by customer %s', order_sudo.partner_id.name)
+                body = _('Quotation viewed by customer %s', order_sudo.partner_id.name if request.env.user._is_public() else request.env.user.partner_id.name)
                 _message_post_helper(
                     "sale.order",
                     order_sudo.id,
-- 
GitLab