Odoo Help


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 1,190 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
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 :)

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 ..

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


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