我尝试从模型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()最多需要11个参数(给定12个)。
有你的想法吗?
答案 0 :(得分:0)
从超级方法调用行中删除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显式传递给任何方法,在此参数中自动调用对象集。