Odoo Help

2

0
4 Answers
2
Avatar

Kazim Mirza | Founder at TechUltra Solutions India

--Kazim Mirza | Founder at TechUltra Solutions --
866
| 3 3 7
Ahmedabad, India
--Kazim Mirza | Founder at TechUltra Solutions --
 
Kazim Mirza | Founder at TechUltra Solutions India
1/15/15, 12:56 PM

Hello Michael

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

Example:

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 :

@api.v8

def btn_send(self):

     self.write({name:'AAAA'}) 

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

@api.v8

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

 

 

 

2
aci aisha India
1/16/15, 5:16 AM

 Try this,

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

 

0
Michael Berg Germany
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):

to:

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

Problem solved. best regards Michael

0
Avatar

Ivan Indonesia

--Ivan--

3440
| 6 3 9
Jakarta, Indonesia
--Ivan--
Ivan Indonesia
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.

Ask a Question
Writer
Keep Informed
2 follower(s)
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.

Register
Odoo Training Center

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

Test it now