odoo - How can I delete the "sheet" node keeping its content intact? -


i remove node <sheet></sheet> form view. instance, have view:

<record id="view_account_period_form" model="ir.ui.view">     <field name="name">account.period.form</field>     <field name="model">account.period</field>     <field name="arch" type="xml">         <form string="account period">             <header>                 [...]             </header>             <sheet>                 <group>                     <group>                         <field name="name"/>                         <field name="fiscalyear_id" widget="selection"/>                         <label for="date_start" string="duration"/>                         <div>                             <field name="date_start" class="oe_inline" nolabel="1"/> -                             <field name="date_stop" nolabel="1" class="oe_inline"/>                         </div>                     </group>                     <group>                         <field name="code"/>                         <field name="special"/>                         <field name="company_id" widget="selection" groups="base.group_multi_company"/>                     </group>                 </group>             </sheet>         </form>     </field> </record> 

i convert in other view without node, keeping elements within it:

<record id="view_account_period_form" model="ir.ui.view">     <field name="name">account.period.form</field>     <field name="model">account.period</field>     <field name="arch" type="xml">         <form string="account period">             <header>                 [...]             </header>              <group>                 <group>                     <field name="name"/>                     <field name="fiscalyear_id" widget="selection"/>                     <label for="date_start" string="duration"/>                     <div>                         <field name="date_start" class="oe_inline" nolabel="1"/> -                         <field name="date_stop" nolabel="1" class="oe_inline"/>                     </div>                 </group>                 <group>                     <field name="code"/>                     <field name="special"/>                     <field name="company_id" widget="selection" groups="base.group_multi_company"/>                 </group>             </group>          </form>     </field> </record> 

is possible or need override complete code again?

maybe similar to:

<xpath expr="//form/sheet" position="replace">     <!-- [...] --> </xpath> 

there open issue in git hub asking solving here, think maybe knows how without programming new feature in odoo.

just use fields_view_get:

    lxml import etree     def fields_view_get(self, cr, uid, view_id=none, view_type='form', context=none, toolbar=false, submenu=false):         res = models.model.fields_view_get(self, cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu)         if view_type == 'form':             doc = etree.xml(res['arch'])             sheet in doc.xpath("//sheet"):                 parent = sheet.getparent()                 index = parent.index(sheet)                 child in sheet:                     parent.insert(index, child)                     index += 1                 parent.remove(sheet)             res['arch'] = etree.tostring(doc)         return res 

improved in case of oe_chatting presence


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -