Created
March 20, 2019 07:05
-
-
Save netchampfaris/4031fa222f0c8bf6634bccff53712c47 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
frappe.ui.form.on('Sales Invoice', { | |
onload(frm) { | |
console.log('onload') | |
frm.add_fetch('customer', 'car_model', 'car_model') | |
frappe.db.get_value('Company', 'Facebook', 'abbr').then(function(value) { | |
console.log(value.message.abbr) | |
}) | |
}, | |
cost_center(frm) { | |
frm.doc.items.forEach(function(row) { | |
frappe.model.set_value(row.doctype, row.name, 'cost_center', frm.doc.cost_center) | |
}) | |
} | |
}) | |
frappe.ui.form.on('Sales Invoice Item', { | |
qty: function(frm, cdt, cdn) { | |
let total_qty = 0 | |
frm.doc.items.forEach(function(row) { | |
total_qty = total_qty + row.qty | |
}) | |
console.log(total_qty) | |
frm.set_value('my_total_quantity', total_qty + 2) | |
console.log(cdt, cdn) | |
// const row = frappe.get_doc(cdt, cdn) | |
// row.rate = total_qty | |
frappe.model.set_value(cdt, cdn, 'rate', total_qty) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment