Before this commit, when we create a new object (e.g. task, product, ...), the part of the form for the chatter was blank. After this commit, it displays the chatter with a single temporary message 'Creating a new record...' This message is only visible by the user that is creating the task, and goes away when saving the newly created task. Any interaction with the chatter (buttons and widgets at the top of the chatter, including the message itself) are disabled, so that no interaction from the user is possible.
48 lines
2.1 KiB
Python
48 lines
2.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
import json
|
|
|
|
from odoo import models
|
|
from odoo.http import request
|
|
|
|
import odoo
|
|
|
|
|
|
class Http(models.AbstractModel):
|
|
_inherit = 'ir.http'
|
|
|
|
def webclient_rendering_context(self):
|
|
return {
|
|
'menu_data': request.env['ir.ui.menu'].load_menus(request.debug),
|
|
'session_info': json.dumps(self.session_info()),
|
|
}
|
|
|
|
def session_info(self):
|
|
user = request.env.user
|
|
display_switch_company_menu = user.has_group('base.group_multi_company') and len(user.company_ids) > 1
|
|
version_info = odoo.service.common.exp_version()
|
|
return {
|
|
"session_id": request.session.sid,
|
|
"uid": request.session.uid,
|
|
"is_system": request.env.user._is_system(),
|
|
"is_superuser": request.env.user._is_superuser(),
|
|
"user_context": request.session.get_context() if request.session.uid else {},
|
|
"db": request.session.db,
|
|
"server_version": version_info.get('server_version'),
|
|
"server_version_info": version_info.get('server_version_info'),
|
|
"name": user.name,
|
|
"username": user.login,
|
|
"partner_display_name": user.partner_id.display_name,
|
|
"company_id": request.env.user.company_id.id if request.session.uid else None,
|
|
"partner_id": request.env.user.partner_id.id if request.session.uid and request.env.user.partner_id else None,
|
|
"user_companies": {'current_company': (user.company_id.id, user.company_id.name), 'allowed_companies': [(comp.id, comp.name) for comp in user.company_ids]} if display_switch_company_menu else False,
|
|
"currencies": self.get_currencies(),
|
|
"web.base.url": self.env['ir.config_parameter'].sudo().get_param('web.base.url', default=''),
|
|
}
|
|
|
|
def get_currencies(self):
|
|
Currency = request.env['res.currency']
|
|
currencies = Currency.search([]).read(['symbol', 'position', 'decimal_places'])
|
|
return { c['id']: {'symbol': c['symbol'], 'position': c['position'], 'digits': [69,c['decimal_places']]} for c in currencies}
|