diff options
| author | Romain Derie <rde@odoo.com> | 2019-12-19 16:05:29 +0000 |
|---|---|---|
| committer | Romain Derie <rde@odoo.com> | 2020-01-07 16:11:52 +0000 |
| commit | c86bff6a02617ca1f06a3dadf21924e7e38f5877 (patch) | |
| tree | 41d5d119bb1393358221aec4a5fe2374eb4546f5 /addons/website/models/ir_module_module.py | |
| parent | 387f199ee7234e25c52c9d6c5900eeb6286751f4 (diff) | |
[IMP] website: load theme images also when module install through CLI
Themes image would not be shown correctly in the theme selection if the
`website` module was installed in CLI.
Indeed, the code supposed to load the theme images was done in the kanban view
during theme selection after installing module through apps screen.
Now, this code is encapsulated and called in post_init hook of website.
This was also needed for an improvement on `test_themes` module, see
https://github.com/odoo/design-themes/pull/195.
closes odoo/odoo#42206
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
Diffstat (limited to 'addons/website/models/ir_module_module.py')
| -rw-r--r-- | addons/website/models/ir_module_module.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/addons/website/models/ir_module_module.py b/addons/website/models/ir_module_module.py index 1e8ec1fe5e9..86286a9fd2c 100644 --- a/addons/website/models/ir_module_module.py +++ b/addons/website/models/ir_module_module.py @@ -373,16 +373,24 @@ class IrModuleModule(models.Model): @api.model def update_list(self): res = super(IrModuleModule, self).update_list() + self.update_theme_images() + return res + @api.model + def update_theme_images(self): IrAttachment = self.env['ir.attachment'] existing_urls = IrAttachment.search_read([['res_model', '=', self._name], ['type', '=', 'url']], ['url']) existing_urls = [url_wrapped['url'] for url_wrapped in existing_urls] - for app in self.search([]): - terp = self.get_module_info(app.name) + themes = self.env['ir.module.module'].with_context(active_test=False).search([ + ('category_id', 'child_of', self.env.ref('base.module_category_theme').id), + ], order='name') + + for theme in themes: + terp = self.get_module_info(theme.name) images = terp.get('images', []) for image in images: - image_path = os.path.join(app.name, image) + image_path = os.path.join(theme.name, image) if image_path not in existing_urls: image_name = os.path.basename(image_path) IrAttachment.create({ @@ -390,6 +398,5 @@ class IrModuleModule(models.Model): 'name': image_name, 'url': image_path, 'res_model': self._name, - 'res_id': app.id, + 'res_id': theme.id, }) - return res |
