Before this commit: 1. If we were editing a template with no xml_id, typically the case when editing a specific view (COW'd), the 'Template ID' label would be left empty as the view does not have an xml_id but only a key. 2. If we were editing a generic view, the template would be COW'd and replaced by the specific one created during the save. After the save, the page would be reload and will try to reopen the edited template (stored in url `res=123`). But as this template would be replaced by the COW'd view, the JS would crash trying to access an inexisting view. The HTML editor would then open in a very thin modal, barely editable. Now: 1. Display the template's key instead of its xml_id. The key is basically a duplicate of the xml_id, mainly used in website. 2. If we are saving a generic view, we search for its newly created specific view to upload the URL hash before reloading. task-1934279 Fix #30447
39 lines
1.4 KiB
Python
39 lines
1.4 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
from odoo.addons.web_editor.controllers.main import Web_Editor
|
|
from odoo.http import request
|
|
|
|
|
|
class Web_Editor(Web_Editor):
|
|
|
|
def _get_view_fields_to_read(self):
|
|
res = super(Web_Editor, self)._get_view_fields_to_read()
|
|
res.append('website_id')
|
|
return res
|
|
|
|
def save_scss_view_hook(self):
|
|
res = super(Web_Editor, self).save_scss_view_hook()
|
|
|
|
website = request.env['website'].get_current_website()
|
|
if website:
|
|
res['website_id'] = website.id
|
|
return res
|
|
|
|
def save_scss_attachment_hook(self):
|
|
res = super(Web_Editor, self).save_scss_attachment_hook()
|
|
|
|
website = request.env['website'].get_current_website()
|
|
if website:
|
|
res['website_id'] = website.id
|
|
return res
|
|
|
|
def get_custom_attachment(self, custom_url, op='='):
|
|
website = request.env['website'].get_current_website()
|
|
res = super(Web_Editor, self).get_custom_attachment(custom_url, op=op)
|
|
return res.with_context(website_id=website.id).filtered(lambda x: not x.website_id or x.website_id == website)
|
|
|
|
def get_custom_view(self, custom_url, op='='):
|
|
website = request.env['website'].get_current_website()
|
|
res = super(Web_Editor, self).get_custom_view(custom_url, op=op)
|
|
return res.with_context(website_id=website.id).filter_duplicate()
|