Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Help! 'Char' object has no attribute 'to_field'

By
Arjun Khode
on 1/23/15, 4:15 AM 2,816 views

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?

 

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

Odoo
on 1/23/15, 4:25 AM

try with above code

Odoo
on 1/23/15, 4:25 AM
1

Odoo

--Odoo --
1328
| 5 2 5
kerala, India
--Odoo --

Working as a Odoo Functional and Technical Expert

Odoo
On 1/23/15, 4:28 AM

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

0
Arjun Khode
On 1/23/15, 5:41 AM

Hi LIBU, it worked! thanks for your answer.

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

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 1/23/15, 4:15 AM
Seen: 2816 times
Last updated: 3/16/15, 8:10 AM