Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
5566 Lượt xem

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


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

You mix new and old api. Relpace

class account_invoice_line(osv.osv): 

by

class account_invoice_line(models.Model):


Ảnh đại diện
Huỷ bỏ
Tác giả

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'

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.

Bài viết liên quan Trả lời Lượt xem Hoạt động
5
thg 4 17
7611
0
thg 5 16
3301
2
thg 12 15
3482
1
thg 6 17
4653
3
thg 11 16
6569