Question

I have a class ordres_fabrication that contains a one2many field production that i show in the form view

enter image description here

I want that the operation's name to be displayed only once ,but as shown in the picture the operation_name isn't grouped by name.

here's the equivalent productions for the selected production order ('ordres_fabrication') (OF1) enter image description here

here's the code that i've wrote:

<record model="ir.ui.view" id="view_ordres_fabrication_form">
    <field name="name">ordres_fabrication.form</field>
    <field name="model">ordres_fabrication</field>
    <field name="type">form</field>
    <field name="arch" type="xml">
        <form string="ordres de fabrication">
            <field name="numero"/>
            <field name="commande_id" on_change="onchange_numero_bc(commande_id)" domain="[('etat','!=','Terminé')]"/> 
            <field name="quantite"/> 
            <field name="piece_id"/> 
            <field name="numero_lot"/> 
            <field name="delai"/> 
            <field name="etat"/>
            <separator string="Quantités produites par opération" colspan="4"/>
            <field name="production" colspan="4" nolabel="1" context="{'group_by': 'productions.operation_nom'}">
                <tree>
                    <field name="operation_nom"/>
                    <field name="quantite_op"/>
                </tree>
            </field>
        </form>
    </field>
</record>

Please,could someone help me to fix it.Thank you

Was it helpful?

Solution

If anyone is interested on how i solved my problem. Instead of using group by, i added a Boolean field,then in my one2many field "productions" i added a domain where i take only records with boolean value equal to true

'production': fields.one2many('productions','of_num','Productions',readonly=True,domain=[('repeat','=',True)]),
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top