This question has been flagged
2 Replies
7511 Views

Hi,

I am trying to add a tree to res.partner form displaying all the non-paid invoices.

I managed to display the tree but I don't know how to filter rows : I want to show only the invoices that are not paid (state = open).

I tried to add a "domain" on the tree but it didn't work.

Here is my code :

<record id="view_partner_inherit_followup_form" model="ir.ui.view">
    <field name="name">res.partner.followup.form.inherit</field>
    <field name="inherit_id" ref="base.view_partner_form"/>
    <field name="model">res.partner</field>
    <field name="groups_id" eval="[(4, ref('account.group_account_invoice'))]"/>
    <field name="arch" type="xml" >
        <page string="Accounting" position="before" version="7.0">
            <page string="Relances paiement" groups="account.group_account_invoice" name="followup_tab">
                <field name="invoices" string="Factures">
                  <tree colors="red:state == 'open'; green:state == 'paid';" domain="[('state', '==', 'open')]">
                    <field name="number" />
                    <field name="date_invoice"/>
                    <field name="colonne_due1" sum="Total 1-30" />
                    <field name="colonne_due2" sum="Total 31-45"/>
                    <field name="colonne_due3" sum="Total 46-50"/>
                    <field name="colonne_due4" sum="Total 51-60"/>
                    <field name="colonne_due5" sum="Total 61+"/>
                    <field name="amount_total" sum="Total"/>
                    <field name="state" invisible="True" />
                  </tree>
                </field>
            </page>
        </page>
    </field>
</record>

Can anyone give me a way to show only open invoices?

Avatar
Discard
Author Best Answer

I just solved my problem by adding the domain in the python code :

'factures': fields.one2many('account.invoice', 'partner_id', 'Invoices', domain=[('state','=','open')], readonly=True),

It works this way but if anyone knows why it did not work in the xml, please tell me.

Thanks

Avatar
Discard
Best Answer

You need the domain on the field invoices.

Try something like:

<field name="invoices" string="Factures" domain="[('state', '=', 'open')]">
Avatar
Discard
Author

I already tried it but it doesn't seems to work... Thanks anyway