I'm trying to override an onchange function of account move line model in order to update the value of a custom field I've added in account.move model:
class SoftOneInvoiceLine(models.Model):
_inherit= "account.move.line"
change_from_user=fields.Boolean('Change by user',default=True)
@api.onchange('quantity', 'discount', 'price_unit', 'tax_ids')
def _onchange_price_subtotal(self):
super(SoftOneInvoiceLine,self)._onchange_price_subtotal()
for rec in self:
if (rec.change_from_user):rec.move_id.global_discount=0
rec.move_id.update({'global_discount':0})
print (rec.move_id," ",rec.move_id.global_discount)
rec.change_from_user=True
When above code runs, the change doesn't reflect on the form field.
Print command displays: account.move(,) 0.0
What is the problem and the field isn't updated on the form?
There is no code.
I somehow erased code before posting. Here is the code:
class SoftOneInvoiceLine(models.Model):
_inherit= "account.move.line"
change_from_user=fields.Boolean('Change by user',default=True)
@api.onchange('quantity', 'discount', 'price_unit', 'tax_ids')
def _onchange_price_subtotal(self):
super(SoftOneInvoiceLine,self)._onchange_price_subtotal()
for rec in self:
if (rec.change_from_user):
rec.move_id.global_discount=0;
rec.move_id.update({'global_discount':0})
print (rec.move_id," ",rec.move_id.global_discount)
rec.change_from_user=True
I was getting error 403 forbidden when I was posting the code. Managed to post the code in a comment but it is displayed messed up.