Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions addons/sale/controllers/portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

class CustomerPortal(payment_portal.PaymentPortal):

def _get_message_author(self, order):
return order.partner_id if request.env.user._is_public() else request.env.user.partner_id

def _prepare_home_portal_values(self, counters):
values = super()._prepare_home_portal_values(counters)
partner = request.env.user.partner_id
Expand Down Expand Up @@ -154,7 +157,7 @@ def portal_order_page(
msg = _('Quotation viewed by customer %s', author.name)
del context
order_sudo.message_post(
author_id=author.id,
author_id=self._get_message_author(order_sudo).id,
body=msg,
message_type="notification",
subtype_xmlid="sale.mt_order_viewed",
Expand Down Expand Up @@ -296,11 +299,7 @@ def portal_quote_accept(self, order_id, access_token=None, name=None, signature=

order_sudo.message_post(
attachments=[('%s.pdf' % order_sudo.name, pdf)],
author_id=(
order_sudo.partner_id.id
if request.env.user._is_public()
else request.env.user.partner_id.id
),
author_id=self._get_message_author(order_sudo).id,
body=_('Order signed by %s', name),
message_type='comment',
subtype_xmlid='mail.mt_comment',
Expand Down Expand Up @@ -331,11 +330,7 @@ def portal_quote_decline(self, order_id, access_token=None, decline_message=None
order_sudo.order_line.currency_id

order_sudo.message_post(
author_id=(
order_sudo.partner_id.id
if request.env.user._is_public()
else request.env.user.partner_id.id
),
author_id=self._get_message_author(order_sudo).id,
body=decline_message,
message_type='comment',
subtype_xmlid='mail.mt_comment',
Expand Down