This question has been flagged
3 Replies
9269 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.

Avatar
Discard
Best Answer

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'


 


Avatar
Discard
Author Best Answer

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?

Avatar
Discard

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

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

Best Answer

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.

Avatar
Discard