summaryrefslogtreecommitdiff
path: root/addons/website/controllers/main.py
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2019-02-26 16:39:30 +0100
committerChristophe Simonis <chs@odoo.com>2019-02-26 16:39:30 +0100
commitff9c9341d6ed4e9ab18a0aa02e79441999d658f1 (patch)
tree47ffd01e071d3783cff6013cfc4b6c3d8e47a841 /addons/website/controllers/main.py
parentbc84fdf71b15ad419f8693861aea682ee751f85c (diff)
parentfcb972db9dc778eeaf7d6b6ba3638c78d93998ad (diff)
[MERGE] forward port branch saas-12.2 up to fcb972db9dc
Diffstat (limited to 'addons/website/controllers/main.py')
-rw-r--r--addons/website/controllers/main.py36
1 files changed, 24 insertions, 12 deletions
diff --git a/addons/website/controllers/main.py b/addons/website/controllers/main.py
index a2d1d332f80..13e82dc5c12 100644
--- a/addons/website/controllers/main.py
+++ b/addons/website/controllers/main.py
@@ -283,24 +283,36 @@ class Website(Home):
views = views.sorted(key=lambda v: (v.inherit_id.id, v.name))
return views.read(['name', 'id', 'key', 'xml_id', 'arch', 'active', 'inherit_id'])
- @http.route('/website/reset_templates', type='http', auth='user', methods=['POST'], website=True)
+ @http.route('/website/reset_templates', type='http', auth='user', methods=['POST'], website=True, csrf=False)
def reset_template(self, templates, redirect='/', **kwargs):
+ """ This method will try to reset a list of broken views ids.
+ It will read the original `arch` from the view's XML file (arch_fs).
+ Views without an `arch_fs` can't be reset, except views created when
+ dropping a snippet in specific oe_structure that create an inherited
+ view doing an xpath.
+ Note: The `arch_fs` field is automatically erased when there is a
+ write on the `arch` field.
+
+ This method is typically useful to reset specific views. In that case we
+ read the XML file from the generic view.
+ """
templates = request.httprequest.form.getlist('templates')
- modules_to_update = []
for temp_id in templates:
view = request.env['ir.ui.view'].browse(int(temp_id))
- if view.page:
+ if 'oe_structure' in view.key:
+ # Particular xpathing view created in edit mode
+ view.unlink()
continue
- view.model_data_id.write({
- 'noupdate': False
- })
- if view.model_data_id.module not in modules_to_update:
- modules_to_update.append(view.model_data_id.module)
+ xml_view = view._get_original_view() # view might already be the xml_view
+ if xml_view.arch_fs:
+ view_file_arch = xml_view.with_context(read_arch_from_file=True).arch
+ # Deactivate COW to not fix a generic view by creating a specific
+ view.with_context(website_id=None).arch_db = view_file_arch
+ if view == xml_view:
+ view.model_data_id.write({
+ 'noupdate': False
+ })
- if modules_to_update:
- modules = request.env['ir.module.module'].sudo().search([('name', 'in', modules_to_update)])
- if modules:
- modules.button_immediate_upgrade()
return request.redirect(redirect)
@http.route(['/website/publish'], type='json', auth="public", website=True)