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

Error on argument list when extend onchange method

By
Victor Godayer
on 3/25/15, 12:51 PM 994 views

Hi,


I try to extend the method product_id_change from the model account.invoice.line as follow :



from openerp.osv import osv, fields

from openerp import api

import openerp.addons.decimal_precision as dp

class account_invoice_line(osv.osv):

     _inherit = 'account.invoice.line'

         _columns = {

         'price_unit_with_tax':fields.float(string='Prix Unitaire TTC', digits= dp.get_precision('Product Price'), readonly=True,),

}

     @api.multi

     def product_id_change(self, product, uom_id, qty=0, name='', type='out_invoice',

             partner_id=False, fposition_id=False, price_unit=False, currency_id=False,

             company_id=None):

         res = super(account_invoice_line, self).product_id_change(product, uom_id, qty=qty, name=name, type=type,

         partner_id=partner_id, fposition_id=fposition_id, price_unit=price_unit, currency_id=currency_id,company_id=company_id)

         if res == 0:

              return res

         context = self._context

        ...

        return res


But when I change the product on an invoice line, I get an error saying that I provide too much arguments :

TypeError: product_id_change() takes at most 11 arguments (15 given)

But the definition of my method product_id_change respect the same number of argument !

I can't get what's wrong in my code!

Thank you for your help

Cheers


1

zbik

--zbik--
5941
| 6 4 7
Lodz, Poland
--zbik--


zbik
On 3/25/15, 3:17 PM

You mix new and old api. Relpace

class account_invoice_line(osv.osv): 

by

class account_invoice_line(models.Model):


Thank you for your reply. But if I change to models.Model, then I get another error which make no sense to me : File ".../openerp-server/lib.linux-x86_64-2.7/openerp/models.py", line 5668, in onchange if field_name and field_name not in self._fields: TypeError: unhashable type: 'list'

Victor Godayer
on 3/26/15, 3:57 AM

In new api line 'price_unit_with_tax':fields.float(string='Prix Unitaire TTC', digits= dp.get_precision('Product Price'), readonly=True,) must like this: price_unit_with_tax = fields.Float(string='Prix Unitaire TTC', digits= dp.get_precision('Product Price'), readonly=True,) without _column definition. Or... other isssue.

zbik
on 3/26/15, 6:03 AM

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

1 follower(s)

Stats

Asked: 3/25/15, 12:51 PM
Seen: 994 times
Last updated: 3/25/15, 3:17 PM