[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
This commit is contained in:
parent
58f1b5ad02
commit
42f2544250
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue