fix: Added default dimension and filter in bootinfo
diff --git a/erpnext/public/js/financial_statements.js b/erpnext/public/js/financial_statements.js
index 89cb13d..5feedd3 100644
--- a/erpnext/public/js/financial_statements.js
+++ b/erpnext/public/js/financial_statements.js
@@ -129,14 +129,12 @@
}
]
- erpnext.dimension_filters.then((dimensions) => {
- dimensions.forEach((dimension) => {
- filters.push({
- "fieldname": dimension["fieldname"],
- "label": __(dimension["label"]),
- "fieldtype": "Link",
- "options": dimension["document_type"]
- });
+ frappe.boot.dimension_filters.forEach((dimension) => {
+ filters.push({
+ "fieldname": dimension["fieldname"],
+ "label": __(dimension["label"]),
+ "fieldtype": "Link",
+ "options": dimension["document_type"]
});
});
diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js
index 1c5e98e..0a363a0 100755
--- a/erpnext/public/js/utils.js
+++ b/erpnext/public/js/utils.js
@@ -63,20 +63,6 @@
me.show_serial_batch_selector(grid_row.frm, grid_row.doc);
});
},
-
- get_dimension_filters: async function() {
- if (!frappe.model.can_read('Accounting Dimension')) {
- return [];
- }
- let dimensions = await frappe.db.get_list('Accounting Dimension', {
- fields: ['label', 'fieldname', 'document_type', 'default_dimension'],
- filters: {
- disabled: 0
- }
- });
-
- return dimensions;
- }
});
diff --git a/erpnext/public/js/utils/dimension_tree_filter.js b/erpnext/public/js/utils/dimension_tree_filter.js
index 4a82edd..22b4834 100644
--- a/erpnext/public/js/utils/dimension_tree_filter.js
+++ b/erpnext/public/js/utils/dimension_tree_filter.js
@@ -7,25 +7,40 @@
"Landed Cost Item", "Asset Value Adjustment", "Loyalty Program", "Fee Schedule", "Fee Structure", "Stock Reconciliation",
"Travel Request", "Fees", "POS Profile"];
-erpnext.dimension_filters = erpnext.get_dimension_filters();
-
erpnext.doctypes_with_dimensions.forEach((doctype) => {
frappe.ui.form.on(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.boot.dimension_filters.forEach((dimension) => {
+ frappe.model.with_doctype(dimension['document_type'], () => {
+ if (frappe.meta.has_field(dimension['document_type'], 'is_group')) {
+ frm.set_query(dimension['fieldname'], {
+ "is_group": 0
+ });
}
- frappe.model.with_doctype(dimension['document_type'], () => {
- if (frappe.meta.has_field(dimension['document_type'], 'is_group')) {
- frm.set_query(dimension['fieldname'], {
- "is_group": 0
- });
- }
- });
});
});
+ },
+
+ company: function(frm) {
+ if(frm.doc.company) {
+ frappe.boot.dimension_filters.forEach((dimension) => {
+ frm.set_value(dimension['fieldname'], frappe.boot.default_dimensions[frm.doc.company][dimension['document_type']]);
+ });
+ }
+ },
+
+ items_add: function(frm, cdt, cdn) {
+ frappe.boot.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) {
+ frappe.boot.dimension_filters.forEach((dimension) => {
+ var row = frappe.get_doc(cdt, cdn);
+ frm.script_manager.copy_from_first_row("accounts", row, [dimension['fieldname']]);
+ });
}
});
});
\ No newline at end of file