Odoo Help


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.


I want to save a field as Upper case ,I got this error AttributeError: 'NoneType' object has no attribute 'account_name'

on 10/28/14, 3:23 AM 837 views

class hotel_account(osv.osv):
              'account_name': fields.char('Account Name',required=True),


def create(self, cr, uid, vals, context=None):
         for record in self.browse(cr,uid,vals,context=context):
             lower = record.account_name
             return super(hotel_account,self).create(cr,uid,vals,context=context)

On 10/28/14, 5:47 AM

Yes Libu, Ludo is right.

for you case you should write your create method as below.

def create(self, cr, uid, vals, context=None):
         if vals.get('account_name', False):
             lower = vals.get('account_name', False)
         return super(hotel_account,self).create(cr,uid,vals,context=context)


Hi Ajay ,Thanks for your valuable replay..

on 10/28/14, 8:42 AM

Ludo - Neobis

--Ludo - Neobis--
| 2 2 5
Hoogvliet, Netherlands
--Ludo - Neobis--


Ludo - Neobis
On 10/28/14, 5:10 AM

You are using a self browse in a create, trying to go over all existing records when creating a new record and you are using "vals" when browsing as the ids. This does not make sense to me?

Anyway, the result of that browse will most likely by an empty list and a Nonetype actually has no account_name :)



| 5 4 6
Zagreb | Karlovac, Croatia

there is only 10 kind of people the ones that understand binary ... and others

On 10/28/14, 5:33 AM

Actualy, Ludo gave half precise answer :) 
that self.browse method will do apsolutly nothing, you did not send ids to it so it will always return null... 

when you are createing record, you are apssing a lis of values (vals) in dictionaly form {'key':value}
now if you need uppercase name saved... 
probably the easiest way is to remove complete browse  part and instead just update vals:
vals['account_name'] = vals['account_name'] and vals['account_name'].upper or False
and then return super call to create......
also might be useful to think about write method.. (and converting to upper while writing...not only on create) 

hope it helps ..

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)


Asked: 10/28/14, 3:23 AM
Seen: 837 times
Last updated: 3/16/15, 8:10 AM