0
votes

i have an Problem with Openerp 7.0. I want to loop over a one2many Field. Here is my Model class:

class my_class(osv.osv):
        _name = "my.name"
        _inherit = 'mail.thread'
        _columns = {
                    'partners' : fields.one2many('my.other.class', 'other_id' , 'partner'),
        }
my_class()

class my_other_class(osv.osv)
       _name = 'my.other.class'
       _columns = {
             'type' : fields.char( .... ),
             ....
             'other_id' : fields.many2one('my.class')
      }
my_other_class()

And the XML Part File:

<t t-foreach="record.partners.raw_value" t-as="p">
        <div>
                Out:
                <t t-esc="p" />
                <t t-esc="p.type" />
                <t t-esc="p.cid" />
                <t t-esc="p.notification" />
        </div>
</t>

I have multible Partners:

  • ID TYPE NOTIFICATION
  • 1 Customer True
  • 2 Installer True
  • 3 Employee False

If i run the Code, it only prints: Out: 12 Out: 13

12,13 are the internal IDs

How can i loop correctly over my one2many Field? I found many solutions for Odoo 8, but they dont work at Openerp 7 :/

Thank you, AntiMuffin

1
Qweb is not available in OpenERP 7.0 its available only in odoo 8.0 or later versionDASADIYA CHAITANYA
Yes, i have read that in other posts before. But i can use the most of Qweb without problems :\kpalatzky

1 Answers

0
votes

You should define a name column in your my.other.class model. If you don't need such a column, you should at least define a _rec_name variable to the column you want to be used instead of name: that's because when you write

<t t-esc="p" />

odoo tries to write the object, but no default is defined, then it writes the internal id.

In your case, try to explicit

<t t-esc="p.id" />

maybe there are some problem in odoo 7 and it doesn't show the other fields.

If this doesn't work you could also try instead:

<t t-esc="p.id +' '+p.type+' '+p.cid+' '+p.notification" />