fix: Remove duplicate code from accounting dimension

This commit is contained in:
Deepesh Garg 2020-04-28 20:19:26 +05:30
parent cb8ea6643e
commit 7889ca564c

View File

@ -46,17 +46,19 @@ doctypes_with_dimensions.forEach((doctype) => {
if(frm.doc.company && Object.keys(default_dimensions || {}).length > 0
&& default_dimensions[frm.doc.company]) {
let default_dimension = default_dimensions[frm.doc.company][dimension['document_type']];
if(default_dimension) {
if (frappe.meta.has_field(doctype, dimension['fieldname'])) {
frm.set_value(dimension['fieldname'],
default_dimensions[frm.doc.company][dimension['document_type']]);
frm.set_value(dimension['fieldname'], default_dimension);
}
$.each(frm.doc.items || frm.doc.accounts || [], function(i, row) {
frappe.model.set_value(row.doctype, row.name, dimension['fieldname'],
default_dimensions[frm.doc.company][dimension['document_type']])
frappe.model.set_value(row.doctype, row.name, dimension['fieldname'], default_dimension);
});
}
}
}
});
}
});
@ -71,20 +73,6 @@ child_docs.forEach((doctype) => {
});
},
accounts_add: function(frm, cdt, cdn) {
erpnext.dimension_filters.forEach((dimension) => {
var row = frappe.get_doc(cdt, cdn);
frm.script_manager.copy_from_first_row("accounts", row, [dimension['fieldname']]);
});
},
items_add: function(frm, cdt, cdn) {
erpnext.dimension_filters.forEach((dimension) => {
var row = frappe.get_doc(cdt, cdn);
frm.script_manager.copy_from_first_row("items", row, [dimension['fieldname']]);
});
},
accounts_add: function(frm, cdt, cdn) {
erpnext.dimension_filters.forEach((dimension) => {
var row = frappe.get_doc(cdt, cdn);