on_detail_changed(item, detail)

domain: client

language: javascript

class Item class


Occurs after changes to detail record has been posted. It uses the clearTimeout and setTimeout Javascript functions so if records have been changed in a cycle it is triggered only when last record change occurs.

The item parameter is an item that triggered the event. The detail parameter is a detail that has been changed.

Write an on_detail_changed event handler to calculate, by using calc_summary method, sums for fields of a detail and save these values in fields of its master.


function on_detail_changed(item, detail) {
    var fields;
    if (detail.item_name === 'invoice_table') {
        fields = [
            {"total": "total"},
            {"tax": "tax"},
            {"subtotal": "amount"}
        item.calc_summary(detail, fields);

See also

Details calc_summary