fix: Multiple changes in dimension creation logic
This commit is contained in:
@@ -4,9 +4,11 @@
|
|||||||
frappe.ui.form.on('Accounting Dimension', {
|
frappe.ui.form.on('Accounting Dimension', {
|
||||||
|
|
||||||
refresh: function(frm) {
|
refresh: function(frm) {
|
||||||
frm.add_custom_button(__('Show {0} List', [frm.doc.document_type]), function () {
|
if (!frm.is_new()) {
|
||||||
|
frm.add_custom_button(__('Show {0}', [frm.doc.document_type]), function () {
|
||||||
frappe.set_route("List", frm.doc.document_type);
|
frappe.set_route("List", frm.doc.document_type);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
document_type: function(frm) {
|
document_type: function(frm) {
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
{
|
{
|
||||||
|
"_comments": "[]",
|
||||||
|
"_liked_by": "[]",
|
||||||
"autoname": "field:label",
|
"autoname": "field:label",
|
||||||
"creation": "2019-05-04 18:13:37.002352",
|
"creation": "2019-05-04 18:13:37.002352",
|
||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
@@ -8,25 +10,26 @@
|
|||||||
"label",
|
"label",
|
||||||
"fieldname",
|
"fieldname",
|
||||||
"is_mandatory",
|
"is_mandatory",
|
||||||
"disable"
|
"disabled"
|
||||||
],
|
],
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"fieldname": "label",
|
"fieldname": "label",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Label",
|
"label": "Dimension Name",
|
||||||
"unique": 1
|
"unique": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "fieldname",
|
"fieldname": "fieldname",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
|
"hidden": 1,
|
||||||
"label": "Fieldname"
|
"label": "Fieldname"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "document_type",
|
"fieldname": "document_type",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"label": "Document Type",
|
"label": "Reference Document Type",
|
||||||
"options": "DocType",
|
"options": "DocType",
|
||||||
"reqd": 1
|
"reqd": 1
|
||||||
},
|
},
|
||||||
@@ -38,12 +41,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"default": "0",
|
"default": "0",
|
||||||
"fieldname": "disable",
|
"fieldname": "disabled",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"label": "Disable"
|
"label": "Disable"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"modified": "2019-05-17 20:35:31.014495",
|
"modified": "2019-05-25 19:18:11.718209",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Accounting Dimension",
|
"name": "Accounting Dimension",
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ class AccountingDimension(Document):
|
|||||||
|
|
||||||
def make_dimension_in_accounting_doctypes(doc):
|
def make_dimension_in_accounting_doctypes(doc):
|
||||||
doclist = get_doclist()
|
doclist = get_doclist()
|
||||||
|
doc_count = len(get_accounting_dimensions())
|
||||||
|
|
||||||
if doc.is_mandatory:
|
if doc.is_mandatory:
|
||||||
df.update({
|
df.update({
|
||||||
@@ -39,16 +40,22 @@ def make_dimension_in_accounting_doctypes(doc):
|
|||||||
|
|
||||||
for doctype in doclist:
|
for doctype in doclist:
|
||||||
|
|
||||||
|
if (doc_count + 1) % 2 == 0:
|
||||||
|
insert_after_field = 'dimension_col_break'
|
||||||
|
else:
|
||||||
|
insert_after_field = 'accounting_dimensions_section'
|
||||||
|
|
||||||
df = {
|
df = {
|
||||||
"fieldname": doc.fieldname,
|
"fieldname": doc.fieldname,
|
||||||
"label": doc.label,
|
"label": doc.label,
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"options": doc.document_type,
|
"options": doc.document_type,
|
||||||
"insert_after": "cost_center"
|
"insert_after": insert_after_field
|
||||||
}
|
}
|
||||||
|
|
||||||
if doctype == "Budget":
|
if doctype == "Budget":
|
||||||
df.update({
|
df.update({
|
||||||
|
"insert_after": "cost_center",
|
||||||
"depends_on": "eval:doc.budget_against == '{0}'".format(doc.document_type)
|
"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)
|
frappe.clear_cache(doctype=doctype)
|
||||||
|
|
||||||
def disable_dimension(doc):
|
def disable_dimension(doc):
|
||||||
if doc.disable:
|
if doc.disabled:
|
||||||
df = {"read_only": 1}
|
df = {"read_only": 1}
|
||||||
else:
|
else:
|
||||||
df = {"read_only": 0}
|
df = {"read_only": 0}
|
||||||
@@ -123,7 +130,9 @@ def get_doclist():
|
|||||||
doclist = ["GL Entry", "Sales Invoice", "Purchase Invoice", "Payment Entry", "Asset",
|
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",
|
"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",
|
"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
|
return doclist
|
||||||
|
|
||||||
|
|||||||
@@ -67,6 +67,9 @@ $.extend(erpnext, {
|
|||||||
get_dimension_filters: async function() {
|
get_dimension_filters: async function() {
|
||||||
let dimensions = await frappe.db.get_list('Accounting Dimension', {
|
let dimensions = await frappe.db.get_list('Accounting Dimension', {
|
||||||
fields: ['label', 'fieldname', 'document_type'],
|
fields: ['label', 'fieldname', 'document_type'],
|
||||||
|
filters: {
|
||||||
|
disabled: 0
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return dimensions;
|
return dimensions;
|
||||||
|
|||||||
Reference in New Issue
Block a user