From 42f254425068071124f878823df21d8d04cfec9c Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 22 Oct 2013 15:06:08 +0200 Subject: [PATCH] [FIX] cleanup modified arch sections before reinserting them in source arch otherwise there are leftovers data-* attributes stored in the DB bzr revid: xmo@openerp.com-20131022130608-jccohqlmbzvxhnzv --- addons/website/models/ir_ui_view.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/addons/website/models/ir_ui_view.py b/addons/website/models/ir_ui_view.py index 955ca4f758b..0a14d23d12e 100644 --- a/addons/website/models/ir_ui_view.py +++ b/addons/website/models/ir_ui_view.py @@ -1,9 +1,10 @@ # -*- coding: utf-8 -*- - -from lxml import etree, html -from openerp.osv import osv, fields from urlparse import urlparse +from lxml import etree, html + +from openerp.osv import osv, fields +from openerp.addons.base import ir class view(osv.osv): _inherit = "ir.ui.view" @@ -83,13 +84,20 @@ class view(osv.osv): return out def replace_arch_section(self, cr, uid, view_id, section_xpath, replacement, context=None): - arch = replacement - if section_xpath: - previous_arch = etree.fromstring(self.browse(cr, uid, view_id, context=context).arch.encode('utf-8')) + # remove branding from replacement section + for att in ir.ir_ui_view.MOVABLE_BRANDING: + replacement.attrib.pop(att, None) + + if not section_xpath: + # replace all of the arch, not just a fragment + arch = replacement + else: + arch = etree.fromstring(self.browse(cr, uid, view_id, context=context).arch.encode('utf-8')) # ensure there's only one match - [previous_section] = previous_arch.xpath(section_xpath) + [previous_section] = arch.xpath(section_xpath) + previous_section.getparent().replace(previous_section, replacement) - arch = previous_arch + return arch def _normalize_urls(self, element):