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

When I try to save a form it raises an error AttributeError: 'NoneType' object has no attribute 'ids' [Closed]

By
Odoo
on 8/28/14, 4:33 AM 1,096 views

The Question has been closed for reason: duplicate question

by
Odoo
on 08/29/2014 00:34:17

I want to fetch some values from res.partner use browse method.But i got this error why need a help,Here I attached my code sample

 

 class res_partner(osv.osv):
    
    _inherit='res.partner'
    
    _columns={
               'total':fields.char('First Name'),

}

def create(self, cr, uid, ids, context=None):
        for i in self.browse(cr,uid,ids):
            val_name=i.name
            val_email=i.email
            val_total=val_name+val_email
        return super(res_partner, self).create(cr, uid, ids,{'total':'val_total'}, context=context)

Need a help...

 

 


 

0
Kazim Mirza
On 8/28/14, 10:36 AM

Hello Libu Koshy,

Def Create method is used for create a new record into the database.

so in create() method you have not specify the id because there is no id for record because there is no record.

If there is a ny record you want to update it so you have to use write() methods with perticular id.

but Create() doesnt contain any ids. you are about to create a new record .

 

def create(self, cr, uid,vals, context=None):

        if context is None:
            context = {}

        for i in self.browse(cr,uid,ids):

            for record in i:
               val_name=record.name
               val_email=record.email
               val_total=val_name+val_email

            vals = {'total':val_total}
        return super(res_partner, self).create(cr, uid, vals, context=context)

Please use abow  code.

I tried your code but still have same problem...####ERROR File "/opt/openerp/server/openerp/addons/partner_custom/cust_invoice_info.py", line 61, in create val_name=i.name AttributeError: 'NoneType' object has no attribute 'name'

Odoo
on 8/29/14, 12:31 AM

check it

Kazim Mirza
on 8/29/14, 1:21 AM

File "/opt/openerp/server/openerp/addons/partner_custom/cust_invoice_info.py", line 1016, in create for record in i: TypeError: 'NoneType' object is not iterable

Odoo
on 8/29/14, 3:35 AM
2

René Schuster

--René Schuster--
1560
| 5 5 8
Weinheim, Germany
--René Schuster--

Challenge Everything!

René Schuster
On 8/28/14, 5:06 AM

The create() method works only for a single record.

The function signature is: create(cr, user, vals, context=None)

EDIT:

When either name or mail are not entered on creation, their value will become False (though I thougt they wouldn't be in the value dict). So make sure both fields are filled, using required=True, or change the code to catch the missing field values.

For the latter, change your function to:

def create(self, cr, uid, values, context=None):
    name = values.get('name','');
    mail = values.get('email','');
    total =  '';
    if name:
        total += name;
    if mail:
        total += ', ' + 'mail;
    values['total'] = total;
    return super(res_partner, self).create(cr, uid, values, context=context);

Regards.
 

self is required ? inside create( uid, values, context=None) ?

Odoo
on 8/28/14, 5:38 AM

I tried your code but error occurs####### TypeError: cannot concatenate 'str' and 'bool' objects

Odoo
on 8/28/14, 5:41 AM

Ofcourse. Sorry. I will fix it immediately!

René Schuster
on 8/28/14, 5:41 AM

Thank you Rene..its working

Odoo
on 8/28/14, 7:19 AM

About This Community

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

Question tools

1 follower(s)

Stats

Asked: 8/28/14, 4:33 AM
Seen: 1096 times
Last updated: 3/16/15, 8:10 AM