Merge pull request #16339 from alyf-de/use-local-refresh-field
refactor: Form.update_in_all_rows
This commit is contained in:
commit
58aa8a27e9
1 changed files with 11 additions and 7 deletions
|
|
@ -1701,13 +1701,17 @@ frappe.ui.form.Form = class FrappeForm {
|
|||
}
|
||||
|
||||
update_in_all_rows(table_fieldname, fieldname, value) {
|
||||
// update the child value in all tables where it is missing
|
||||
if(!value) return;
|
||||
var cl = this.doc[table_fieldname] || [];
|
||||
for(var i = 0; i < cl.length; i++){
|
||||
if(!cl[i][fieldname]) cl[i][fieldname] = value;
|
||||
}
|
||||
refresh_field("items");
|
||||
// Update the `value` of the field named `fieldname` in all rows of the
|
||||
// child table named `table_fieldname`.
|
||||
// Do not overwrite existing values.
|
||||
if (value === undefined) return;
|
||||
|
||||
frappe.model
|
||||
.get_children(this.doc, table_fieldname)
|
||||
.filter(child => !frappe.model.has_value(child.doctype, child.name, fieldname))
|
||||
.forEach(child =>
|
||||
frappe.model.set_value(child.doctype, child.name, fieldname, value)
|
||||
);
|
||||
}
|
||||
|
||||
get_sum(table_fieldname, fieldname) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue