Skip to Content
Menu
This question has been flagged
3 Replies
33070 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?

Avatar
Discard
Best Answer

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

Avatar
Discard
Best Answer

Hi Stepen,

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

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

Avatar
Discard
Best Answer

Where is the field "launch_year_volume_gross_versions" defined?

Avatar
Discard
Related Posts Replies Views Activity
1
Jun 22
13337
1
Jun 22
7282
0
Dec 16
5275
5
Sep 20
12731
1
Jun 15
4081