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.


Odoo v8: Create new Record with self.create(val) throws error

Michael Berg
on 1/15/15, 12:22 PM 4,190 views


I'm trying to insert a new record. Following guide i need to call self.create({'name':'Value'}) within the model. But on try, i get following error:

TypeError: old_api() takes at least 3 arguments (2 given)

I dont unterstand the system of the old api mapping. Please help to find the error.

Best regards


Kazim Mirza
On 1/15/15, 12:56 PM

Hello Michael

I guess the method inside which you use create call have old api argument.


def btn_send(self,cr,uid,ids,context=None):

     self.create({name:'AAAA'}) #you cant use new api call in old api like this

This is wrong

Now, what you have to do is :


def btn_send(self):


You can use any method but you cant use create method because you are trying to create the record in which you are already in.

Complete Example:

class a(models.Model)

_name = 'a.a'

con = fields.Char('Country')


class B(models.Model)

_name = 'b.b'

lnam = fields.Char('lnam')


def btn_join(self):

  self.env['a.a'].create({con:self.lnam}) #result : value_of_Lnam in Country


You can refer guidline of How to use Environment in new api click here 

Hope that this answer will help you.

Please don't hesitate to ask any question regarding this.

Thank You




aci aisha
On 1/16/15, 5:16 AM

 Try this,

            new_id = phonecall.create(cr, uid, vals, context=context)


Michael Berg
On 1/16/15, 5:13 AM

Thx for the nice answer. I got it. I needed to rewrite the button function from:

def btn_send(self,cr,uid,ids,context=None):


@api.multi #otherwise the form view cant access this function
def btn_send(self):

Problem solved. best regards Michael



| 5 3 6
Jakarta, Indonesia
On 1/15/15, 1:06 PM

AFAIK, Not all of v8.0 code has been migrated to new API.  So, you need to check what model that you are writing and if has supported new API.

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

2 follower(s)


Asked: 1/15/15, 12:22 PM
Seen: 4190 times
Last updated: 3/15/16, 2:39 AM