Files
odoo_source/odoo/addons/base/tests/test_ir_module.py
T
Jairo Llopisandxmo-odoo 18b4902a19 [FIX] base: allow browsing form view of missing module
Before this patch, if you once had one module available and, later, remove it, you'd be getting an exception when browsing its form view and trying to get its icon image.

Now it gets the base module icon image, just like it should.

@moduon MT-1524

closes odoo/odoo#151870

X-original-commit: 4543f45e0066814d5722acfcac3c8bc8d09b8cb1
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
Co-authored-by: xmo-odoo <xmo@odoo.com>
2024-01-31 18:59:10 +00:00

23 lines
851 B
Python

from odoo.tests.common import TransactionCase
from odoo.tools import mute_logger
class IrModuleCase(TransactionCase):
@mute_logger("odoo.modules.module")
def test_missing_module_icon(self):
module = self.env["ir.module.module"].create({"name": "missing"})
base = self.env["ir.module.module"].search([("name", "=", "base")])
self.assertEqual(base.icon_image, module.icon_image)
@mute_logger("odoo.modules.module")
def test_new_module_icon(self):
module = self.env["ir.module.module"].new({"name": "missing"})
self.assertFalse(module.icon_image)
@mute_logger("odoo.modules.module")
def test_module_wrong_icon(self):
module = self.env["ir.module.module"].create(
{"name": "wrong_icon", "icon": "/not/valid.png"}
)
self.assertFalse(module.icon_image)