From 2038ff2f26b1454ae0c8a44c8a03ece0ee945998 Mon Sep 17 00:00:00 2001 From: Tonow-c2c Date: Wed, 4 Dec 2019 12:35:54 +0000 Subject: [PATCH] [FIX] sale: change the date to isoformat to be serializable Avoid posting message if we are still on the same date closes odoo/odoo#49486 X-original-commit: 5bd98159878501a8d1d3af336c1f895ed342268e Signed-off-by: Damien Bouvy (dbo) Co-authored-by: Damien Bouvy --- addons/sale/controllers/portal.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/addons/sale/controllers/portal.py b/addons/sale/controllers/portal.py index e951dce54b2..1c7ce875081 100644 --- a/addons/sale/controllers/portal.py +++ b/addons/sale/controllers/portal.py @@ -153,13 +153,15 @@ class CustomerPortal(CustomerPortal): # use sudo to allow accessing/viewing orders for public user # only if he knows the private token - now = fields.Date.today() - # Log only once a day - if order_sudo and request.session.get('view_quote_%s' % order_sudo.id) != 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 - _message_post_helper('sale.order', order_sudo.id, body, token=order_sudo.access_token, message_type='notification', subtype_xmlid="mail.mt_note") + if order_sudo: + # store the date as a string in the session to allow serialization + now = fields.Date.today().isoformat() + 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 + _message_post_helper('sale.order', order_sudo.id, body, token=order_sudo.access_token, message_type='notification', subtype_xmlid="mail.mt_note") values = { 'sale_order': order_sudo,