Sign in
Try it free
  • Apps
    Websites
    Build great user experience
    • Website Builder
    • eCommerce
    • Blogs
    • Forums
    • Slides
    • Live Chat
    Sales
    Boost your success rate
    • Sales
    • CRM
    • Invoicing
    • Point of Sale
      • Shops
      • Restaurants
      • Hardware
    • Subscriptions
    • Sign
    Operations
    It's all about efficiency
    • Accounting
    • Project
    • Human Resources
      • Recruitment
      • Employees
      • Expenses
      • Appraisal
      • Fleet
      • Leaves
    • Inventory
    • Purchase
    • Manufacturing
      • MRP
      • PLM
      • Maintenance
      • Quality
    • Helpdesk
    Productivity Tools
    Great Tools = Happy People
    • Communication
      • Discuss
      • Mailing Lists
      • Notes
    • Timesheet
    • Email Marketing
    • Events
    • Survey
    • Appointments
    • Marketing Automation
    Third party apps | Odoo Studio | Odoo Cloud Platform NEW
  • Tour
  • Pricing
  • Community
  • Docs

Odoo Help


Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.

Take the tour
Help
  • Trending
  • Newest
  • People
  • Tags
  • Badges
Ask a Question
1

Using the new API.. how do I create a One2many related column?

v8 one2many
By
Bevan Weiss
on 7/29/14, 5:13 PM • 6,022 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)

  • Flag
  • Reply
  • Comment
  • Share
3

Akhil P Sivan

--Akhil P Sivan--

4233
| 5 4 7
Kochi, India
--Akhil P Sivan--

Interested in exploring Odoo both technically & functionality wise.

email-id : akhilpsivan01@gmail.com

Akhil P Sivan
On 5/7/15, 10:49 PM

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 
  • Comment
  • Flag
0
Miku Laitinen
On 5/7/15, 2:17 PM


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.

 

  • Comment
  • Flag

About This Community

This platform 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.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

Thanks for your subscription!
2 follower(s)

Stats

Asked: 7/29/14, 5:13 PM
Seen: 6022 times
Last updated: 5/7/15, 10:49 PM
Community
  • Github
  • Download
  • Runbot
  • Translations
  • Mailing Lists
  • Forum
Services
  • Odoo Cloud Platform
  • Support
  • Upgrade
  • Find a partner
  • Become a partner
  • Training center
  • Education
  • Security
About us
  • Our company
  • Contact
  • Events
  • Blog
  • Customers
  • Jobs
  • Legal | Privacy
  • English
    • 简体中文
    • Nederlands
    • Français
    • Deutsch
    • Italiano
    • Português (BR)
    • Español

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Live Webinar on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Watch now