Commit Graph
8 Commits
Author SHA1 Message Date
qsm-odoo f7ff02b0fb [FIX] website_theme_install: properly reset config on theme change
Before this commit, some code was resetting some default website config
on theme change.

Problem 1:
This was not done when *removing* a theme. Thus when you wanted to go
back to a default website theme, you were not properly reset to the
default theme config. This could actually crash: some themes define
more fonts than others; so if you selected font 13 in one theme then
removed the theme, the default one would crash if not properly reset
as font 13 would not exist.

Problem 2:
It was done for every theme dependency, making theme change slower for
no reason.

Problem 3 (theorically, not tested):
The current code worked by chance as it called the website
'make_scss_customization' method without giving any website to it. It
actually worked by fallback on the right website in normal user cases
(user in the context of installing a theme on a specific website) but
may not be working when trying to install a theme on a different website
calling those functions from custom code.

Now, a dedicated method is there for config reset and is called at the
correct place with the right website in the context.

closes odoo/odoo#53743

X-original-commit: 7307d696449ea2b7a231b0b9087e64f6bbf65d26
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-06-26 14:00:44 +00:00
Denis Ledoux 7b8d12e6dc "[REVERT] website_theme_install: do not mark theme views as arch_updated when loaded from data files"
This reverts commit fdd4a143f2148ec5f4aeea80fecd3138fea95dc6.

See discussion in #51969

closes odoo/odoo#52028

X-original-commit: 0e602cc0ac295621864b50509f78bd5de1e61718
Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2020-05-27 19:59:30 +00:00
Denis Ledoux 4fc0f2c042 [FIX] website_theme_install: do not mark theme views as arch_updated when loaded from data files
A view is marked as `arch_updated` if `arch` is being written on it
and `install_filename` is not in the context:
https://github.com/odoo/odoo/blob/7b1a6c00663239fbbab3d8ea5028e0825f4eb0dd/odoo/addons/base/models/ir_ui_view.py#L460-L461

When a view is being updated from a `theme.ir.ui.view` through `_update_records`
https://github.com/odoo/odoo/blob/7b1a6c00663239fbbab3d8ea5028e0825f4eb0dd/addons/website_theme_install/models/ir_module_module.py#L29
https://github.com/odoo/odoo/blob/7b1a6c00663239fbbab3d8ea5028e0825f4eb0dd/addons/website_theme_install/models/ir_module_module.py#L92
https://github.com/odoo/odoo/blob/7b1a6c00663239fbbab3d8ea5028e0825f4eb0dd/addons/website_theme_install/models/ir_module_module.py#L208
https://github.com/odoo/odoo/blob/7b1a6c00663239fbbab3d8ea5028e0825f4eb0dd/addons/website_theme_install/models/ir_module_module.py#L168

we can basically consider it comes from a data file,
the template is updated, and its copies as well if the copies are "unchanged"
and therefore the `arch_updated` should not be set to `True` in such as case,
as the goal of this flag is to mark the view as `arch_updated` if it was updated by the user,
not from a data file loading.

Because the views are marked as `arch_updated`,
in 13.0, when updating the theme view "templates" (`theme.ir.ui.view`),
the copies are not being updated even if they have been left untouched:
https://github.com/odoo/odoo/blob/23511dffb9e3f597a7df9bb834d008f74abb07b8/addons/website_theme_install/models/ir_module_module.py#L165-L166

This is really problematic for upgrades, as the "copies" (the themes views) are not updated
according to the latest changes in the xml files, even if the views have been left untouched by the user.

For instance, this change in the common theme:
odoo/design-themes@29da153784
is never updated in databases, resulting in the below traceback
```
ValueError: Element '<xpath expr="//div[@data-js='content']">' cannot be located in parent view

Fout context:
Weergave`s_badge_options`
[view_id: 2103, xml_id: n/b, model: n/b, parent_id: 901]

load could not load template
ValueError: Element '<xpath expr="//div[@data-js='content']">' cannot be located in parent view
```

opw-2255753

closes odoo/odoo#51969

X-original-commit: 614214a08b7e19605228c96fbdef1a60752ba575
Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2020-05-27 10:42:06 +00:00
Jeremy Kersten 3e4b6f939d [FIX] website: use absolute url for theme image
Before this commit, url preview of a theme was theme_xx/static/yyy.png
Now we make this url absolue /theme_xx/static/yyy.png

It was the expected behavior, and since werkeug 15.0 utils.redirect() don't use
'/' anymore as root but the current path.

Without this fix, theme selector uses /web/image/<id>, and the location become
/web/image/theme_xx/static/yyy.png instead of /theme_xx/static/yyy.png

closes odoo/odoo#51018

Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2020-05-11 13:04:39 +00:00
Romain DerieandKishan Gajjar babbe363b6 [FIX] website_theme_install: do not write view arch if it was modified
During theme install, theme.ir.ui.view are copied as ir.ui.view for the
requested website.
During theme update, those already created ir.ui.view will receive the
theme.ir.ui.view modifications, including the `arch`, even if it was changed by
the user, meaning the user changes would be lost.

Here are some examples which will be wiped away when the theme
is updated (only if the view is loaded from the theme module):

- Changes made from website HTML/CSS/JS editor.
- Changes made from website builder e.g. Theme modify footer with XPath
  and user make changes in footer then user changes will be gone on theme update
- Changes made directly in the arch of ir.ui.view in the backend.

This commit fixes that behavior by not updating views which were modified by
the user.

closes odoo/odoo#49224

X-original-commit: 9906e1d403c4e9137a0313c342a455f425e95b8e
Signed-off-by: Romain Derie <rdeodoo@users.noreply.github.com>
Co-authored-by: Romain Derie <rde@odoo.com>
Co-authored-by: Kishan Gajjar <kishanegajjar@gmail.com>
2020-04-08 12:15:25 +00:00
Romain Derie c86bff6a02 [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>
2020-01-07 16:11:52 +00:00
qsm-odoo 322d5768a7 [REF] website: call _post_copy with website in the context directly
Before this commit, the website was given as a parameter of the
_post_copy function which is called after theme install. It was then
transfered through the context when calling the theme sub' post_copy
function.

It makes actually more sense to directly call the _post_copy function
with the right website in the context instead of a parameter. This will
also allow to call enable_view/disable_view in the default post_copy
common to all theme, with the right website.

closes odoo/odoo#41312

Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2019-12-05 16:32:39 +00:00
qsm-odoo 88e910e187 [REF] website, *: merge website_theme_install into website
* theme_bootswatch, theme_default, website_theme_install
2019-11-12 15:53:13 +00:00