on_field_changed(field, lookup_item)
domain: client
language: javascript
class Item class
Write an on_field_changed event handler to respond to any changes in the
field’s data.
The field parameter is the field whose data has been changed. To get the
item that owns the field, use the
owner
attribute of the field.
The lookup_item parameter is not undefined when
the field is a
lookup field
and a change has occured
when a user selected a record from a lookup item dataset.
function on_field_changed(field, lookup_item) {
var item = field.owner;
if (field.field_name === 'quantity' || field.field_name === 'unitprice') {
item.owner.calc_total(item);
}
else if (field.field_name === 'track' && lookup_item) {
item.quantity.value = 1;
item.unitprice.value = lookup_item.unitprice.value;
}
}