fix: Default Accounting Dimensions in doctypes

This commit is contained in:
deepeshgarg007 2019-07-14 19:28:56 +05:30
parent 8c8b1f2da6
commit b590f89310
3 changed files with 12 additions and 2 deletions

View File

@ -9,6 +9,7 @@
"document_type",
"label",
"fieldname",
"default_dimension",
"mandatory_for_bs",
"mandatory_for_pl",
"disabled"
@ -53,9 +54,15 @@
"fieldname": "mandatory_for_pl",
"fieldtype": "Check",
"label": "Mandatory For Profit and Loss Account"
},
{
"fieldname": "default_dimension",
"fieldtype": "Dynamic Link",
"label": "Default Dimension",
"options": "document_type"
}
],
"modified": "2019-07-14 17:25:01.307948",
"modified": "2019-07-14 19:16:25.405924",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Accounting Dimension",

View File

@ -69,7 +69,7 @@ $.extend(erpnext, {
return [];
}
let dimensions = await frappe.db.get_list('Accounting Dimension', {
fields: ['label', 'fieldname', 'document_type'],
fields: ['label', 'fieldname', 'document_type', 'default_dimension'],
filters: {
disabled: 0
}

View File

@ -14,6 +14,9 @@ erpnext.doctypes_with_dimensions.forEach((doctype) => {
onload: function(frm) {
erpnext.dimension_filters.then((dimensions) => {
dimensions.forEach((dimension) => {
if (dimension['default_dimension']) {
frm.set_value(dimension['fieldname'], dimension['default_dimension']);
}
frappe.model.with_doctype(dimension['document_type'], () => {
if (frappe.meta.has_field(dimension['document_type'], 'is_group')) {
frm.set_query(dimension['fieldname'], {