콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
4346 화면

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
8356
3
9월 25
1779
3
7월 25
9174
1
5월 25
1411
2
2월 25
6273