From e9c6e644f7d6a6060c550c05e0d673b042b73465 Mon Sep 17 00:00:00 2001 From: deepeshgarg007 Date: Sun, 26 May 2019 12:34:13 +0530 Subject: [PATCH] fix: Multiple changes in dimension creation logic --- .../accounting_dimension/accounting_dimension.js | 8 +++++--- .../accounting_dimension.json | 13 ++++++++----- .../accounting_dimension/accounting_dimension.py | 15 ++++++++++++--- erpnext/public/js/utils.js | 3 +++ 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.js b/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.js index 34d17ec92a9..00a9d72bde3 100644 --- a/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.js +++ b/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.js @@ -4,9 +4,11 @@ frappe.ui.form.on('Accounting Dimension', { refresh: function(frm) { - frm.add_custom_button(__('Show {0} List', [frm.doc.document_type]), function () { - frappe.set_route("List", frm.doc.document_type); - }); + if (!frm.is_new()) { + frm.add_custom_button(__('Show {0}', [frm.doc.document_type]), function () { + frappe.set_route("List", frm.doc.document_type); + }); + } }, document_type: function(frm) { diff --git a/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.json b/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.json index daa100422b4..9405e73a03f 100644 --- a/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.json +++ b/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.json @@ -1,4 +1,6 @@ { + "_comments": "[]", + "_liked_by": "[]", "autoname": "field:label", "creation": "2019-05-04 18:13:37.002352", "doctype": "DocType", @@ -8,25 +10,26 @@ "label", "fieldname", "is_mandatory", - "disable" + "disabled" ], "fields": [ { "fieldname": "label", "fieldtype": "Data", "in_list_view": 1, - "label": "Label", + "label": "Dimension Name", "unique": 1 }, { "fieldname": "fieldname", "fieldtype": "Data", + "hidden": 1, "label": "Fieldname" }, { "fieldname": "document_type", "fieldtype": "Link", - "label": "Document Type", + "label": "Reference Document Type", "options": "DocType", "reqd": 1 }, @@ -38,12 +41,12 @@ }, { "default": "0", - "fieldname": "disable", + "fieldname": "disabled", "fieldtype": "Check", "label": "Disable" } ], - "modified": "2019-05-17 20:35:31.014495", + "modified": "2019-05-25 19:18:11.718209", "modified_by": "Administrator", "module": "Accounts", "name": "Accounting Dimension", diff --git a/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.py b/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.py index 565d2439dad..d51bd7f5c74 100644 --- a/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.py +++ b/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.py @@ -31,6 +31,7 @@ class AccountingDimension(Document): def make_dimension_in_accounting_doctypes(doc): doclist = get_doclist() + doc_count = len(get_accounting_dimensions()) if doc.is_mandatory: df.update({ @@ -39,16 +40,22 @@ def make_dimension_in_accounting_doctypes(doc): for doctype in doclist: + if (doc_count + 1) % 2 == 0: + insert_after_field = 'dimension_col_break' + else: + insert_after_field = 'accounting_dimensions_section' + df = { "fieldname": doc.fieldname, "label": doc.label, "fieldtype": "Link", "options": doc.document_type, - "insert_after": "cost_center" + "insert_after": insert_after_field } if doctype == "Budget": df.update({ + "insert_after": "cost_center", "depends_on": "eval:doc.budget_against == '{0}'".format(doc.document_type) }) @@ -103,7 +110,7 @@ def delete_accounting_dimension(doc): frappe.clear_cache(doctype=doctype) def disable_dimension(doc): - if doc.disable: + if doc.disabled: df = {"read_only": 1} else: df = {"read_only": 0} @@ -123,7 +130,9 @@ def get_doclist(): doclist = ["GL Entry", "Sales Invoice", "Purchase Invoice", "Payment Entry", "Asset", "Expense Claim", "Stock Entry", "Budget", "Payroll Entry", "Delivery Note", "Sales Invoice Item", "Purchase Invoice Item", "Purchase Order Item", "Journal Entry Account", "Material Request Item", "Delivery Note Item", "Purchase Receipt Item", - "Stock Entry Detail", "Payment Entry Deduction"] + "Stock Entry Detail", "Payment Entry Deduction", "Sales Taxes and Charges", "Purchase Taxes and Charges", "Shipping Rule", + "Landed Cost Item", "Asset Value Adjustment", "Loyalty Program", "Fee Schedule", "Fee Structure", "Stock Reconciliation", + "Travel Request", "Fees", "POS Profile"] return doclist diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js index 540b5ea0ec4..f44fb0c1a67 100755 --- a/erpnext/public/js/utils.js +++ b/erpnext/public/js/utils.js @@ -67,6 +67,9 @@ $.extend(erpnext, { get_dimension_filters: async function() { let dimensions = await frappe.db.get_list('Accounting Dimension', { fields: ['label', 'fieldname', 'document_type'], + filters: { + disabled: 0 + } }); return dimensions;