fix: Multiple changes in dimension creation logic

This commit is contained in:
deepeshgarg007 2019-05-26 12:34:13 +05:30
parent 6f6636abfe
commit e9c6e644f7
4 changed files with 28 additions and 11 deletions

View File

@ -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) {

View File

@ -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",

View File

@ -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

View File

@ -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;