Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
13802 Visualizzazioni

I am trying to write a basic module which takes in animal names from a user and displays them as a list.

But when I try to install the module in Odoo, I get the following error:

File "/home/shubhada/workspace/odoo/odoo/openerp/models.py", line 2919, in _inherits_reload cls._add_field(attr, column.to_field()) AttributeError: 'Char' object has no attribute 'to_field'

Here is my content of vetclinic.py file:


from openerp import models,fields

class vetclinic_animal(models.Model):
    _name="vetclinic.animal"
    _columns={
              'name':fields.Char('Name',size=64),
              'birthdate':fields.Date('Birth Date')}

I have tried writing the same file as:

     from openerp import models, fields

     class vetclinic_animal(models.Model):
         _name = "vetclinic.animal"
 
         name = fields.Char(string='Name', required=True) #Try this code
         birthdate = fields.Date('Birth Date')

I can't figure out what's gone wrong. Can someone please help me?

 

Avatar
Abbandona

Hi ...I changed your code please try with below code...

try with above code

Risposta migliore

Try this

from openerp import models, fields

     class vetclinic_animal(models.Model):
         _name = "vetclinic.animal"
 
         name = fields.Char(string='Name', required=True) #Try this code
         birthdate = fields.Date('Birth Date')

Avatar
Abbandona
Autore Risposta migliore

Hi LIBU, it worked! thanks for your answer.

Also, I had forgotten the square bracket in __openerp__.py around

'data':['vetclinic_view.xml'],

Avatar
Abbandona