This question has been flagged
1 Reply
2800 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'?

Avatar
Discard
Best Answer

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?

Avatar
Discard