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

ChesuCR

I would like to remove the node <sheet></sheet> from a form view. For instance, I have this 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 would like to convert it in this other view without the node, but keeping all the 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 that possible or I need to override the complete code again?

Maybe something similar to:

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

There is an open issue in Git Hub asking for solving this here, but I think that maybe anyone knows how to do it without programming a new feature in Odoo.

Alessandro Ruffolo

Just use fields_view_get:

    from 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'])
            for sheet in doc.xpath("//sheet"):
                parent = sheet.getparent()
                index = parent.index(sheet)
                for 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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

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

From Dev

How to delete all files in a directory, keeping sub-directories intact

From Dev

How do I copy a folder keeping owners and permissions intact?

From Dev

How do I archive a folder keeping owners and permissions intact?

From Dev

How can I recursively find a directory by name and delete its contents (including all sub-directories and files) while keeping the directory itself?

From Dev

How can I recursively find a directory by name and delete its contents (including all sub-directories and files) while keeping the directory itself?

From Dev

How can I delete sheet B, but keep the forumula on sheet A that calls sheet B's data?

From Dev

How can I add it delete Node First and delete Node Last

From Dev

How can I delete exactly node in JTree?

From Dev

How to reinstall Ubuntu keeping my data intact?

From Dev

How to reinstall Ubuntu keeping my data intact?

From Dev

bash: how to source a file keeping backslashes intact

From Dev

How am I supposed to make my allocator rebindable? Can I do it while keeping its fields private?

From Dev

How am I supposed to make my allocator rebindable? Can I do it while keeping its fields private?

From Dev

How can I delete an ActiveX Button with VBA by its name?

From Dev

How can I upload a folder to Google Drive with keeping its directory structure?

From Dev

How can I write text to a file in bash while keeping its previous contents?

From Dev

How can I randomize an array while keeping its elements grouped together?

From Dev

How can I replace/substitute an attribute name, not its content

From Dev

How can I split a string depending on its content?

From Dev

How can I make the ul contain li in its content box?

From Dev

How can I replace/substitute an attribute name, not its content

From Dev

How can I get the extension(s) of a file based on its content?

From Dev

How can I select an element using its text content?

From Dev

How to make my system delete all the files in a certain directory older than a certain time while keeping the directory structure intact?

From Dev

How can I delete all duplicates keeping only 4 duplicates of that row?

From Dev

How can I remove a specific node based on its keyvalue?

From Dev

How can I get adjacent values from one sheet and sum them up based on the content of another cell in the current sheet?

From Dev

How can I delete a data node which is not empty in zookeeper?

Related Related

  1. 1

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

  2. 2

    How to delete all files in a directory, keeping sub-directories intact

  3. 3

    How do I copy a folder keeping owners and permissions intact?

  4. 4

    How do I archive a folder keeping owners and permissions intact?

  5. 5

    How can I recursively find a directory by name and delete its contents (including all sub-directories and files) while keeping the directory itself?

  6. 6

    How can I recursively find a directory by name and delete its contents (including all sub-directories and files) while keeping the directory itself?

  7. 7

    How can I delete sheet B, but keep the forumula on sheet A that calls sheet B's data?

  8. 8

    How can I add it delete Node First and delete Node Last

  9. 9

    How can I delete exactly node in JTree?

  10. 10

    How to reinstall Ubuntu keeping my data intact?

  11. 11

    How to reinstall Ubuntu keeping my data intact?

  12. 12

    bash: how to source a file keeping backslashes intact

  13. 13

    How am I supposed to make my allocator rebindable? Can I do it while keeping its fields private?

  14. 14

    How am I supposed to make my allocator rebindable? Can I do it while keeping its fields private?

  15. 15

    How can I delete an ActiveX Button with VBA by its name?

  16. 16

    How can I upload a folder to Google Drive with keeping its directory structure?

  17. 17

    How can I write text to a file in bash while keeping its previous contents?

  18. 18

    How can I randomize an array while keeping its elements grouped together?

  19. 19

    How can I replace/substitute an attribute name, not its content

  20. 20

    How can I split a string depending on its content?

  21. 21

    How can I make the ul contain li in its content box?

  22. 22

    How can I replace/substitute an attribute name, not its content

  23. 23

    How can I get the extension(s) of a file based on its content?

  24. 24

    How can I select an element using its text content?

  25. 25

    How to make my system delete all the files in a certain directory older than a certain time while keeping the directory structure intact?

  26. 26

    How can I delete all duplicates keeping only 4 duplicates of that row?

  27. 27

    How can I remove a specific node based on its keyvalue?

  28. 28

    How can I get adjacent values from one sheet and sum them up based on the content of another cell in the current sheet?

  29. 29

    How can I delete a data node which is not empty in zookeeper?

HotTag

Archive