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

How to apply domain filter in one2many field?

By
Stephen Raj
on 9/18/14, 7:55 AM 4,682 views

Hi,

I've been trying some possibilities to apply domain filter in one2many field. But it is not successful.

Python FIle:

class versions(osv.osv):
    _name = "versions"
    _description = "Versions"
    _columns = {
        'boca_no' : fields.char('BOCA #', size=64),
        'field_name' : fields.char('Field Name', size=64),
        'updated_date': fields.datetime('Updated Date'),
        'value': fields.float('Value'),
        'boca_id': fields.many2one('boca', 'BOCA'),
    } 
    
versions()

 

class boca(osv.osv):
    _name = "boca"
    _columns = {

        'launch_year_volume_gross_versions': fields.one2many('versions', 'boca_id', 'Version'),

}

 

XML File:

<field name="launch_year_volume_gross_versions" string="" domain="[('field_name','like','launch_year_volume_gross_versions')]">
                                        <form string="Launch Year Volume Gross" version="7.0">
                                            <field name="boca_no" />
                                            <field name="value" />
                                            <field name="updated_date" />
                                        </form>
                                        <tree string="Launch Year Volume Gross" editable="bottom">
                                            <field name="boca_no" />
                                            <field name="value" />
                                            <field name="updated_date" />
                                        </tree>
                                    </field>

 

Can someone please light my way in achieving this?

0
Jose Osuna
On 7/9/15, 8:15 PM

Hi Stephen,

   The way I have achieved to do this in v7 was using domain as a list in the python file, not as a string ( like is used in the many2many fields ). 

Python FIle:

class versions(osv.osv):

.....

.... 

class boca(osv.osv):
    _name = "boca"
    _columns = {

        'launch_year_volume_gross_versions': fields.one2many('versions', 'boca_id', string='Version', domain=[('field_name','like','launch_year_volume_gross_versions')] ),

}

I hope this helps.

The next error gave me the clue.

 

File ".... server/openerp/osv/fields.py", line 538, in get

ids2 = obj.pool.get(self._obj).search(cr, user, domain + [(self._fields_id, 'in', ids)], limit=self._limit, context=context)

TypeError: cannot concatenate 'str' and 'list' objects

0
Deviprasad V
On 9/19/14, 6:08 AM

Hi Stepen,

Here you can add domain like
<field name="launch_year_volume_gross_versions" string="" domain="[('boca_no','=','blabla')]">

....
....
</field>

0
Andreas Stauder
On 9/18/14, 8:09 AM

Where is the field "launch_year_volume_gross_versions" defined?

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: 9/18/14, 7:55 AM
Seen: 4682 times
Last updated: 7/9/15, 8:26 PM