[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) <dbo@odoo.com>
Co-authored-by: Damien Bouvy <dbo@odoo.com>
This commit is contained in:
Tonow-c2c
2020-04-14 08:44:38 +00:00
committed by Damien Bouvy
co-authored by Damien Bouvy
parent de322086eb
commit 2038ff2f26
+8 -6
View File
@@ -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,