Open
Description
Hello,
Im trying to call the following onchange method:
@api.onchange('fiscal_category_id',
'fiscal_position',
'invoice_line_tax_id',
'quantity',
'price_unit',
'discount',
'insurance_value',
'freight_value',
'other_costs_value')
def onchange_fiscal(self):
ctx = dict(self.env.context)
if self.invoice_id.type in ('out_invoice', 'out_refund'):
ctx.update({'type_tax_use': 'sale'})
else:
ctx.update({'type_tax_use': 'purchase'})
partner_id = self.invoice_id.partner_id.id or ctx.get('partner_id')
company_id = self.invoice_id.company_id.id or ctx.get('company_id')
if company_id and partner_id and self.fiscal_category_id:
result = {'value': {}}
kwargs = {
'company_id': company_id,
'partner_id': partner_id,
'partner_invoice_id': self.invoice_id.partner_id.id,
'product_id': self.product_id.id,
'fiscal_category_id': self.fiscal_category_id.id,
'context': ctx
}
result = self.with_context(ctx)._fiscal_position_map(
result, **kwargs)
kwargs.update({
'invoice_line_tax_id': [
(6, 0, self.invoice_line_tax_id.ids)],
'quantity': self.quantity,
'price_unit': self.price_unit,
'discount': self.discount,
'fiscal_position': self.fiscal_position.id,
'insurance_value': self.insurance_value,
'freight_value': self.freight_value,
'other_costs_value': self.other_costs_value,
})
result['value'].update(self._validate_taxes(kwargs))
self.update(result['value'])
So i used the suggestion given in the docs:
def on_change(record, method, args=None, kwargs=None):
"""Update `record` with the result of the on_change `method`"""
res = record._odoo.execute_kw(record._name, method, args, kwargs)
for k, v in res['value'].iteritems():
setattr(record, k, v)
And called the function:
on_change(invoiceLine, 'onchange_fiscal', [],{})
But I'm getting the error:
onchange_fiscal() takes exactly 1 argument (3 given)
Metadata
Metadata
Assignees
Labels
No labels
Activity