This question has been flagged
2 Replies
15911 Views

I had a module which I was creating in the v7 API.  However, now that the v8 API has been released I would like to migrate it to this.

I'm having trouble accessing a fields.One2many(related=...) column I've got however.

I've looked in the accounting_invoice module for an example, and it seems that I'm doing the same as shown there.

step_ids = fields.One2many(related='template_id.step_ids', store=True, auto_join=True)

And this shows up in the Database Stucture->Models view, however if I try to reference this in a view then it complains.  Throwing up a error when upgrading the module (or installing) saying:

'NoneType' object has no attribute '_fields'" while passing .... (name of my view.xml)

Is this possibly a bug with the new v8 API?  or am I doing something else wrong?  The template_id is a Many2one (in this class), and the step_ids One2many field does exist in the template class.  (it's been working before in v7 API before I changed the fields.one2many/relation etc items over to fields.One2many and such)

Avatar
Discard
Best Answer

Hi Bevan, I don't think the definition is completely wrong. Please keep it like this:

step_ids = fields.One2many(related='template_id.step_ids', string = "Steps") 

Also make sure you have included the import fields correctly for new api. I mean it should be like this:

from openerp import models, fields, api, exceptions, tools 

The fields import should not be there from osv, I mean:

from openerp.osv import osv, fields 
Avatar
Discard
Best Answer


Your field definition is missing the attribute `comodel_name` which is the first attribute between the parentheses. You must define your `step_ids` field's model first. I found this out thanks to PyCharm suggestions.

 

Avatar
Discard