mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
Add web_fix_modules_load
This commit is contained in:
2
web_fix_modules_load/models/__init__.py
Normal file
2
web_fix_modules_load/models/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from . import ir_module
|
||||
from . import ir_translation
|
||||
20
web_fix_modules_load/models/ir_module.py
Normal file
20
web_fix_modules_load/models/ir_module.py
Normal file
@@ -0,0 +1,20 @@
|
||||
# Copyright 2022 Camptocamp SA
|
||||
# @author Simone Orsi <simahawk@gmail.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
import json
|
||||
|
||||
from odoo import models
|
||||
|
||||
from odoo.addons.web.controllers.main import module_boot
|
||||
|
||||
|
||||
class IrModule(models.Model):
|
||||
_inherit = "ir.module.module"
|
||||
|
||||
def _session_modules_info(self):
|
||||
"""Load modules info and return their mapping."""
|
||||
module_names = module_boot(self.env.cr.dbname)
|
||||
modules = self.sudo().search([("name", "in", module_names)])
|
||||
data = {mod.name: {"id": mod.id} for mod in modules}
|
||||
return json.dumps(data)
|
||||
17
web_fix_modules_load/models/ir_translation.py
Normal file
17
web_fix_modules_load/models/ir_translation.py
Normal file
@@ -0,0 +1,17 @@
|
||||
# Copyright 2022 Camptocamp SA
|
||||
# @author Simone Orsi <simahawk@gmail.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
|
||||
from odoo import models
|
||||
|
||||
|
||||
class IrTranslation(models.Model):
|
||||
_inherit = "ir.translation"
|
||||
|
||||
def get_translations_for_webclient(self, mods, lang):
|
||||
# Intercept call to load translations from modules' ids instead of names.
|
||||
if mods and isinstance(mods[0], int):
|
||||
model = self.env["ir.module.module"].sudo()
|
||||
mods = model.browse(mods).mapped("name")
|
||||
return super().get_translations_for_webclient(mods, lang)
|
||||
Reference in New Issue
Block a user