This commit introduces a mechanism to add information into the session from a different module, without having to fetch it manually with a rpc. This is intended to be used with small pieces of info required at the start of the web client, such as currency informations. To add information to the session, one can simply inherit from ir.http and modify the session_info method.
25 lines
801 B
Python
25 lines
801 B
Python
# -*- coding: utf-8 -*-
|
|
import json
|
|
import logging
|
|
import werkzeug.utils
|
|
|
|
from odoo import http
|
|
from odoo.http import request
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
|
|
class PosController(http.Controller):
|
|
|
|
@http.route('/pos/web', type='http', auth='user')
|
|
def pos_web(self, debug=False, **k):
|
|
# if user not logged in, log him in
|
|
pos_sessions = request.env['pos.session'].search([('state', '=', 'opened'), ('user_id', '=', request.session.uid)])
|
|
if not pos_sessions:
|
|
return werkzeug.utils.redirect('/web#action=point_of_sale.action_client_pos_menu')
|
|
pos_sessions.login()
|
|
context = {
|
|
'session_info': json.dumps(request.env['ir.http'].session_info())
|
|
}
|
|
return request.render('point_of_sale.index', qcontext=context)
|