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

TypeError: button_calculate_monthly_interest() takes exactly 1 argument (5 given)

By
Arjun Khode
on 3/24/15, 2:24 AM 2,126 views

I have written this button which does a simple operation, but Odoo says my arguments are wrong. Its an 'object' type button. Can you help me out?

UPDATE:

Here's my code:

PY:

from openerp.osv import fields, osv

from openerp import api

import openerp.addons.decimal_precision as dp

from openerp.osv import orm

from calendar import monthrange

from datetime import datetime, timedelta

from dateutil import relativedelta



class record(orm.Model):

_name="record"

@api.multi

def button_calculate_monthly_interest(self):

print 'hello Odoo'

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

print("hi")


XML:

<button name="button_calculate_monthly_interest" string="Calculate Monthly Interest" type="object"/>


When I use the old API, I get AttributeError: 'record' object has no attribute 'button_monthly_interest'

When I use new API, I get the error: 1 exact field expected, 5 given.

3

Jérémy Kersten (jke)

--Jérémy Kersten (jke)--
2983
| 3 2 5
Jodoigne, Belgium
--Jérémy Kersten (jke)--

Jérémy is a member of the core R&D team since september 2013. He developed several projects for OpenERP version 8 including the eCommerce, the Google Calendar synchronization and the new product variants/configurator. Now, he manages Odoo website and themes for saas.

Jérémy Kersten (jke)
On 3/24/15, 2:59 AM

Hello,


Should be 

def button_calculate_monthly_interest(self, cr, uid, ids, context=None):
print 'Hello World for current ids (%s)' % ids


or in new API


@api.multi
def button_calculate_monthly_interest(self):
        print 'hello Odoo'


 


0
Arjun Khode
On 3/24/15, 4:09 AM

Thank you Mariusz and Jeremy for your answers. But I'm still getting the same type error despite the changes made in the code. expecting 1 parameter but 5 given. What should I do?

Please update your question with full py code (including imports) so we do know what API do you use.

Currenda Sp. z o.o., Mariusz Mizgier
on 3/24/15, 5:32 AM

Thats bad - try it like http://pastebin.com/6zmG6Q9k . Try optimizing your imports as well.

Currenda Sp. z o.o., Mariusz Mizgier
on 3/24/15, 10:00 AM
0
Mariusz Mizgier
On 3/24/15, 2:56 AM

I guess you are using new api (your class is models.Model), then you should write before your method @api.multi

Take a look at http://odoo-new-api-guide-line.readthedocs.org/en/latest/ for further reference.

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)

Stats

Asked: 3/24/15, 2:24 AM
Seen: 2126 times
Last updated: 3/24/15, 5:49 AM