Odoo Help

Welcome!

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

0

Implementing a many2one relationship

By
Arjun Khode
on 1/23/15, 7:19 AM 953 views

I have a program in which I'm trying to implement many2one relationship. But I think I'm not being able to create 'columns' in v8.

I am getting the following error when I try to save a classification for my animal in Odoo:

ProgrammingError: column "classification_id" of relation "vetclinic_animal" does not exist LINE 1: INSERT INTO "vetclinic_animal" ("id", "classification_id", "...

[a ^ arrow points to classification_id]

Here is my code:

from openerp import models,fields
class vetclinic_animal(models.Model):
    _name = "vetclinic.animal"
    name = fields.Char(string='Name', required=True)
    birthdate = fields.Date('Birth Date')
    classification_id = fields.Many2one('vetclinic.classification','Classification')
    
 
       #  _columns={'name' : fields.Char(string='Name', required=True),
      #   'birthdate' : fields.Date('Birth Date'),
       #  'classification_id' : fields.Many2one('vetclinic.classification','Classification')}


class vetclinic_classification(models.Model):
    _name="vetclinic.classification"
    name=fields.Char(string='Name' , required=True)
    

class vetclinic_breed(models.Model):
    _name="vetclinic.breed"
    name=fields.Char(string='Name' , required=True)

Can someone please help me create the required 'columns'?

0
Mind And Go
On 1/24/15, 6:12 PM

Hy arjun,

Di you try to specify options : http://odoo-new-api-guide-line.readthedocs.org/en/latest/fields.html#many2one

classification_id = fields.Many2one(comodel_name='vetclinic.classification', string='Classification')

Additionnaly, using Many2one this way implies that each animal will belongs to on classification, is it what you need? I'm not sure of what you meant by

try to save a classification for my animal in Odoo

How do you try to save the classification of your animal, by editing an animal? Do you use the proper widgetin your voew. From wich model do you try to save the record?

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 1/23/15, 7:19 AM
Seen: 953 times
Last updated: 3/16/15, 8:10 AM