This question has been flagged
1 Reply
3732 Views

Hi ! I'm on Odoo (v8).

I have two models, declared like this:

class bar(models.Model):
    _name = 'foo.bar'
    _order = 'name'

    name = fields.Char()
    quz = fields.Many2many(comodel_name='foo.quz')

    @api.model
    def get_records(self, bar_id):

        bar_record = self.browse(bar_id)
        return bar_record.quz

class quz(models.Model):
    _name = 'foo.quz'
    _order = 'name'

    name = fields.Char(

Whenever I call the function foo.bar.get_records(1), I get the error I wrote in the title.

Any idea how to solve this ?

Obviously, this is a simplified code, but the real code is not bigger.

I tried self.browse(1).quz, self.env['foo.bar'].browse(1).quz, with no more luck.

The records are in the database, I checked using psql. I really don't know how to access to these records.

I also tried change the name of the relational field. But that doesn't work neither.

Another idea, explanation ?

Avatar
Discard
Author Best Answer

You know what, I thing I'm tired. The answer was in the title.

I tried to access a browse record by passing a damned string to it.

The ID was right, but in the wrong format. That helps if you call int(bar_id) first...

Avatar
Discard