Files
odoo_source/addons/hr_timesheet/models/ir_http.py
T
Nicolas Bayet 344d82ca25 [IMP] web_editor: add collaborative feature
This commit allows to use the editor collaboratively for any html
field in peer to peer using webRTC.

task-2497931

closes odoo/odoo#75768

Signed-off-by: Antony Lesuisse (al) <al@openerp.com>
2021-09-06 19:42:56 +00:00

45 lines
1.6 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, models
from odoo.http import request
class Http(models.AbstractModel):
_inherit = 'ir.http'
def session_info(self):
""" The widget 'timesheet_uom' needs to know which UoM conversion factor and which javascript
widget to apply, depending on the current company.
"""
result = super(Http, self).session_info()
if request.env.user.has_group('base.group_user'):
company_ids = request.env.user.company_ids
for company in company_ids:
result["user_companies"]["allowed_companies"][company.id].update({
"timesheet_uom_id": company.timesheet_encode_uom_id.id,
"timesheet_uom_factor": company.project_time_mode_id._compute_quantity(
1.0,
company.timesheet_encode_uom_id,
round=False
),
})
result["uom_ids"] = self.get_timesheet_uoms()
return result
@api.model
def get_timesheet_uoms(self):
company_ids = request.env.user.company_ids
uom_ids = company_ids.mapped('timesheet_encode_uom_id') | \
company_ids.mapped('project_time_mode_id')
return {
uom.id:
{
'id': uom.id,
'name': uom.name,
'rounding': uom.rounding,
'timesheet_widget': uom.timesheet_widget,
} for uom in uom_ids
}