flectra/addons/website_sale_wishlist/models/res_users.py
flectra-admin 769eafb483 [INIT] Inception of Flectra from Odoo
Flectra is Forked from Odoo v11 commit : (6135e82d73)
2018-01-16 11:45:59 +05:30

25 lines
825 B
Python

from odoo import api, fields, models
from odoo.http import request
class ResUsers(models.Model):
_inherit = "res.users"
current_session = fields.Char(compute="_compute_current_session")
@api.multi
def _compute_current_session(self):
"""Know current session for this user."""
for one in self:
try:
one.current_session = request.session.sid
except (AttributeError, RuntimeError):
pass # Unbound session, value is already False, nothing to do
@api.model
def check_credentials(self, password):
"""Make all this session's wishlists belong to its owner user."""
result = super(ResUsers, self).check_credentials(password)
self.env["product.wishlist"]._join_current_user_and_session()
return result