1
votes

I have a one2many field named line_ids in my view:

i want to display some rows and not others but i need them all in a calculation. the question is how to hide some rows in one2many

because i need all the rows for the calculation and i don't want to bother the user with all of the rows

I need to display just the rows with a field "display" value as True.

<field name="line_ids"   >
    <tree string="Lignes de Rubriques" editable="bottom">
        <field name="category_id"/>
        <field name="code"   invisible="1"/>
        <field name="a_afficher" />
        <field name="sequence" />
        <field name="display" />
        <field name="total" invisible="1" />
        <field name="soumise_CNSS" string="CNSS"  invisible="1"/>
        <field name="soumise_AMO" string="AMO"  invisible="1"/>
        <field name="soumise_IR" string="IR" invisible="1"/>
    </tree>
</field>

How do I achieve this? Thank you :)

1

1 Answers

1
votes

If you don't want the one2many tree to be editable, just create a functional field of type one2many to return the rows you want and use that in your tree.

If you do want the one2many editable, as you have above, it gets much harder. Basically you will need another child model that you populate with the rows to edit and then keep this and the main child model synchronised.

A simpler solution is to use attrs to make the fields on the row you don't want to edit readonly. They will still show but at least they can't be changed.