diff --git a/addons/website/models/website.py b/addons/website/models/website.py index 64b9934c126..1cc7472f8e3 100644 --- a/addons/website/models/website.py +++ b/addons/website/models/website.py @@ -119,6 +119,10 @@ class Website(models.Model): 'arch': template_record.arch.replace(template, key), 'name': name, }) + + if view.arch_fs: + view.arch_fs = False + if ispage: page = self.env['website.page'].create({ 'url': page_url, diff --git a/odoo/addons/base/ir/ir_ui_view.py b/odoo/addons/base/ir/ir_ui_view.py index c3ca7e7ce35..386abda72f8 100644 --- a/odoo/addons/base/ir/ir_ui_view.py +++ b/odoo/addons/base/ir/ir_ui_view.py @@ -115,33 +115,31 @@ def _hasclass(context, *cls): def get_view_arch_from_file(filename, xmlid): doc = etree.parse(filename) - node = None - for n in doc.xpath('//*[@id="%s"]' % (xmlid)): - if n.tag in ('template', 'record'): - node = n - break - if node is None: - # fallback search on template with implicit module name - for n in doc.xpath('//*[@id="%s"]' % (xmlid.split('.')[1])): - if n.tag in ('template', 'record'): - node = n - break - if node is not None: - if node.tag == 'record': - field = node.find('field[@name="arch"]') - _fix_multiple_roots(field) - inner = u''.join([etree.tostring(child, encoding='unicode') for child in field.iterchildren()]) - return field.text + inner - elif node.tag == 'template': - # The following dom operations has been copied from convert.py's _tag_template() - if not node.get('inherit_id'): - node.set('t-name', xmlid) - node.tag = 't' - else: - node.tag = 'data' - node.attrib.pop('id', None) - return etree.tostring(node, encoding='unicode') - _logger.warning("Could not find view arch definition in file '%s' for xmlid '%s'", filename, xmlid) + + xmlid_search = (xmlid, xmlid.split('.')[1]) + + # when view is created from model with inheritS of ir_ui_view, the xml id has been suffixed by '_ir_ui_view' + suffix = '_ir_ui_view' + if xmlid.endswith(suffix): + xmlid_search += (xmlid.rsplit(suffix, 1)[0], xmlid.split('.')[1].rsplit(suffix, 1)[0]) + + for node in doc.xpath('//*[%s]' % ' or '.join(["@id='%s'" % _id for _id in xmlid_search])): + if node.tag in ('template', 'record'): + if node.tag == 'record': + field = node.find('field[@name="arch"]') + _fix_multiple_roots(field) + inner = u''.join([etree.tostring(child, encoding='unicode') for child in field.iterchildren()]) + return field.text + inner + elif node.tag == 'template': + # The following dom operations has been copied from convert.py's _tag_template() + if not node.get('inherit_id'): + node.set('t-name', xmlid) + node.tag = 't' + else: + node.tag = 'data' + node.attrib.pop('id', None) + return etree.tostring(node, encoding='unicode') + _logger.warning("Could not find view arch definition in file '%s' for xmlid '%s'", filename, xmlid_search) return None def add_text_before(node, text): @@ -258,14 +256,12 @@ actual arch. data = dict(arch_db=view.arch) if 'install_mode_data' in self._context: imd = self._context['install_mode_data'] - if '.' not in imd['xml_id']: - imd['xml_id'] = '%s.%s' % (imd['module'], imd['xml_id']) - if self._name == imd['model'] and (not view.xml_id or view.xml_id == imd['xml_id']): - # we store the relative path to the resource instead of the absolute path, if found - # (it will be missing e.g. when importing data-only modules using base_import_module) - path_info = get_resource_from_path(imd['xml_file']) - if path_info: - data['arch_fs'] = '/'.join(path_info[0:2]) + + # we store the relative path to the resource instead of the absolute path, if found + # (it will be missing e.g. when importing data-only modules using base_import_module) + path_info = get_resource_from_path(imd['xml_file']) + if path_info: + data['arch_fs'] = '/'.join(path_info[0:2]) view.write(data) @api.depends('arch') diff --git a/odoo/addons/base/res/res_users.py b/odoo/addons/base/res/res_users.py index 53a3438b21a..ac65e3bf1d2 100644 --- a/odoo/addons/base/res/res_users.py +++ b/odoo/addons/base/res/res_users.py @@ -752,7 +752,11 @@ class GroupsView(models.Model): xml = E.field(E.group(*(xml1), col="2"), E.group(*(xml2), col="4"), name="groups_id", position="replace") xml.addprevious(etree.Comment("GENERATED AUTOMATICALLY BY GROUPS")) xml_content = etree.tostring(xml, pretty_print=True, encoding="unicode") - view.with_context(lang=None).write({'arch': xml_content, 'arch_fs': False}) + + new_context = dict(view._context) + new_context.pop('install_mode_data', None) # don't set arch_fs for this computed view + new_context['lang'] = None + view.with_context(new_context).write({'arch': xml_content}) def get_application_groups(self, domain): """ Return the non-share groups that satisfy ``domain``. """