Odoo Help

0

How to filter rows in internal tree?

By
Matt
on 5/29/13, 12:31 PM 2,310 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?

0
Matt
On 5/30/13, 10:27 AM

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

0
Ray Carnes
On 5/29/13, 3:46 PM

You need the domain on the field invoices.

Try something like:

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

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

Matt
on 5/30/13, 10:10 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)

Stats

Asked: 5/29/13, 12:31 PM
Seen: 2310 times
Last updated: 3/16/15, 8:10 AM