Merge pull request #21478 from deepeshgarg007/duplicate_code_v13

fix: Remove duplicate code from accounting dimension
This commit is contained in:
Deepesh Garg 2020-04-28 20:36:50 +05:30 committed by GitHub
commit e317b79361
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -46,17 +46,19 @@ doctypes_with_dimensions.forEach((doctype) => {
if(frm.doc.company && Object.keys(default_dimensions || {}).length > 0 if(frm.doc.company && Object.keys(default_dimensions || {}).length > 0
&& default_dimensions[frm.doc.company]) { && 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'])) { if (frappe.meta.has_field(doctype, dimension['fieldname'])) {
frm.set_value(dimension['fieldname'], frm.set_value(dimension['fieldname'], default_dimension);
default_dimensions[frm.doc.company][dimension['document_type']]);
} }
$.each(frm.doc.items || frm.doc.accounts || [], function(i, row) { $.each(frm.doc.items || frm.doc.accounts || [], function(i, row) {
frappe.model.set_value(row.doctype, row.name, dimension['fieldname'], frappe.model.set_value(row.doctype, row.name, dimension['fieldname'], default_dimension);
default_dimensions[frm.doc.company][dimension['document_type']])
}); });
} }
} }
}
}); });
} }
}); });
@ -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) { accounts_add: function(frm, cdt, cdn) {
erpnext.dimension_filters.forEach((dimension) => { erpnext.dimension_filters.forEach((dimension) => {
var row = frappe.get_doc(cdt, cdn); var row = frappe.get_doc(cdt, cdn);