跳至内容
菜单
此问题已终结
1 回复
4009 查看

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'?

形象
丢弃
最佳答案

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?

形象
丢弃
相关帖文 回复 查看 活动
5
12月 19
8052
3
7月 25
8649
1
5月 25
938
2
2月 25
5793
1
12月 24
1374