Odoo Help

Welcome!

This community 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.

0

Filter many2one data in integrated tree view

By
Victor Godayer
on 3/3/15, 11:31 AM 1,063 views

Hi,

I have 2 models as follow :

    class releve(osv.osv):
    _name = 'cap.releve'
    _columns = {
        'name' : fields.char('Nom du relevé',required=True),
        'type':fields.selection((('NB','Noir&Blanc'),
                                 ('CO','Couleur'),),
                                'Type de relevé',required=True),
    }

    class contrat(osv.osv):
    _name = 'cap.contrat'
    _columns = {
        'name':fields.char('Nom du contrat',required=True),
        ...

    }

 

And a view for the model cap.equipement listing the cap.releve attached as follow :

 

     <record model="ir.ui.view" id="cap_alpbureautique.view_contrat_form">
      <field name="name">cap.contrat.form</field>
      <field name="model">cap.contrat</field>
      <field name="arch" type="xml">
        <form string="Contrat">
              .....
                <field name="releve_netb_ids" nolabel="1" domain="[('type','=','Noir&amp;Blanc')">
                  <tree>
                    <field name="name" />
                    <field name="date" />
                    <field name="old_index" />
                    <field name="new_index" />
                  </tree>
                </field>
                </group>
                <group string="Relevés Couleur">
                <field name="releve_couleur_ids" nolabel="1" domain="[('type','=','Couleur')]">
                  <tree>
                    <field name="name" />
                    <field name="date" />
                    <field name="old_index" />
                    <field name="new_index" />
                  </tree>
                </field>
                ...
      </field>
    </record>

 

As you can see I try to filter in each tree sub view the result by the type, but there is no effect.

I tried also with the key values of the selection, but it changed nothing.

Am i doing it the right way or is something missing ?

 

Thank you for your help

Cheers

 

 

1

zbik

--zbik--
5941
| 6 4 7
Lodz, Poland
--zbik--


zbik
On 3/3/15, 2:35 PM

Try this:

domain="[('type','=','NB')"
domain="[('type','=','CO')]"

field.selection is identified by selector key, not by selector value

UPDATE:

  1. Domain filters many2one - works only if type (used on the left in expression) is the field in xxxxx_ids model.
  2. In other case field with name=type must exist in view

Thank i tried this both in the 'field' node and 'tree' node, and also with attribute 'domain_filter', but nothing changed. No error either... Do you have any idea ? Thank you

Victor Godayer
on 3/4/15, 12:28 PM

answer updated

zbik
on 3/4/15, 1:38 PM

Thank you, i managed to work it out with your explanations.

Victor Godayer
on 3/5/15, 7:59 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 3/3/15, 11:31 AM
Seen: 1063 times
Last updated: 3/16/15, 8:10 AM