在 invoice_line 中扩展 on_change 方法时出错
Error when extend on_change method in invoice_line
我尝试从模型 account.invoice.line 扩展方法 product_id_change :
class account_invoice_line(models.Model):
_inherit = 'account.invoice.line'
@api.multi
def product_id_change(self, product, uom_id, qty=0, name='', type_x='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(self,product, uom_id, qty, name, type_x, partner_id, fposition_id, price_unit, currency_id, company_id)
return res.
但是当我用 super 调用 product_id_change 时出现这个错误:TypeError: product_id_change() takes at most 11 arguments (12 given) .
你有想法吗?
从超级方法调用行中删除 self。
res = super(account_invoice_line, self).product_id_change(product, uom_id, qty=0, name='', type_x='out_invoice',partner_id=False, fposition_id=False, price_unit=False, currency_id=False,
company_id=None)
无需将self显式传递给任何方法,调用此参数中自动设置的对象。
我尝试从模型 account.invoice.line 扩展方法 product_id_change :
class account_invoice_line(models.Model):
_inherit = 'account.invoice.line'
@api.multi
def product_id_change(self, product, uom_id, qty=0, name='', type_x='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(self,product, uom_id, qty, name, type_x, partner_id, fposition_id, price_unit, currency_id, company_id)
return res.
但是当我用 super 调用 product_id_change 时出现这个错误:TypeError: product_id_change() takes at most 11 arguments (12 given) .
你有想法吗?
从超级方法调用行中删除 self。
res = super(account_invoice_line, self).product_id_change(product, uom_id, qty=0, name='', type_x='out_invoice',partner_id=False, fposition_id=False, price_unit=False, currency_id=False,
company_id=None)
无需将self显式传递给任何方法,调用此参数中自动设置的对象。