(self, value, xpath=None)
Update a view section. The view section may embed fields to write

        Note that `self` record might not exist when saving an embed field

        :param str xpath: valid xpath to the tag to replace
Update a view section. The view section may embed fields to write
Update a view section . The view section may embed fields to write
def save(self, value, xpath=None):
        """ Update a view section. The view section may embed fields to write

        Note that `self` record might not exist when saving an embed field

        :param str xpath: valid xpath to the tag to replace
        """
        self.ensure_one()

        arch_section = html.fromstring(
            value, parser=html.HTMLParser(encoding='utf-8'))

        if xpath is None:
            # value is an embedded field on its own, not a view section
            self.save_embedded_field(arch_section)
            return

        for el in self.extract_embedded_fields(arch_section):
            self.save_embedded_field(el)

            # transform embedded field back to t-field
            el.getparent().replace(el, self.to_field_ref(el))

        for el in self.extract_oe_structures(arch_section):
            if self.save_oe_structure(el):
                # empty oe_structure in parent view
                empty = self.to_empty_oe_structure(el)
                if el == arch_section:
                    arch_section = empty
                else:
                    el.getparent().replace(el, empty)

        new_arch = self.replace_arch_section(xpath, arch_section)
        old_arch = etree.fromstring(self.arch.encode('utf-8'))
        if not self._are_archs_equal(old_arch, new_arch):
            self._set_noupdate()
            self.write({'arch': self._pretty_arch(new_arch)})
def save ( self , value , xpath = None ) : self . ensure_one ( ) arch_section = html . fromstring ( value , parser = html . HTMLParser ( encoding = 'utf-8' ) ) if xpath is None : # value is an embedded field on its own, not a view section self . save_embedded_field ( arch_section ) return for el in self . extract_embedded_fields ( arch_section ) : self . save_embedded_field ( el ) # transform embedded field back to t-field el . getparent ( ) . replace ( el , self . to_field_ref ( el ) ) for el in self . extract_oe_structures ( arch_section ) : if self . save_oe_structure ( el ) : # empty oe_structure in parent view empty = self . to_empty_oe_structure ( el ) if el == arch_section : arch_section = empty else : el . getparent ( ) . replace ( el , empty ) new_arch = self . replace_arch_section ( xpath , arch_section ) old_arch = etree . fromstring ( self . arch . encode ( 'utf-8' ) ) if not self . _are_archs_equal ( old_arch , new_arch ) : self . _set_noupdate ( ) self . write ( { 'arch' : self . _pretty_arch ( new_arch ) } )