Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
4027 Widoki

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

Awatar
Odrzuć
Najlepsza odpowiedź

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?

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
5
gru 19
8063
3
lip 25
8673
1
maj 25
1000
2
lut 25
5849
1
gru 24
1410