Openerp隐藏了一些one2many字段的行

时间:2022-12-05 20:24:27

I have a one2many field named line_ids in my view:

我在视图中有一个名为line_ids的one2many字段:

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

我想显示一些行而不是其他行,但我需要计算所有行。问题是如何在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.

我需要只显示字段“display”值为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


1  

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.

如果您不希望one2many树可编辑,只需创建类型为one2many的功能字段以返回所需的行并在树中使用它。

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.

如果你确实希望one2many可编辑,就像你上面那样,它会变得更加困难。基本上,您将需要另一个子模型,您可以使用行进行编辑,然后保持此模型并使主子模型同步。

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.

一个更简单的解决方案是使用attrs在您不想编辑的行上创建字段。它们仍会显示,但至少它们无法改变。

#1


1  

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.

如果您不希望one2many树可编辑,只需创建类型为one2many的功能字段以返回所需的行并在树中使用它。

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.

如果你确实希望one2many可编辑,就像你上面那样,它会变得更加困难。基本上,您将需要另一个子模型,您可以使用行进行编辑,然后保持此模型并使主子模型同步。

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.

一个更简单的解决方案是使用attrs在您不想编辑的行上创建字段。它们仍会显示,但至少它们无法改变。