fix: Added dashboard and module links for accounting dimensions

This commit is contained in:
deepeshgarg007 2019-05-17 10:23:00 +05:30
parent 073f36b766
commit 705c03c093
5 changed files with 56 additions and 28 deletions

View File

@ -2,7 +2,9 @@
// For license information, please see license.txt
frappe.ui.form.on('Accounting Dimension', {
// refresh: function(frm) {
// }
document_type: function(frm){
frm.set_value('label', frm.doc.document_type);
frm.set_value('fieldname', frappe.scrub(frm.doc.document_type))
}
});

View File

@ -6,7 +6,8 @@
"field_order": [
"document_type",
"label",
"fieldname"
"fieldname",
"is_mandatory"
],
"fields": [
{
@ -27,9 +28,14 @@
"label": "Document Type",
"options": "DocType",
"reqd": 1
},
{
"fieldname": "is_mandatory",
"fieldtype": "Check",
"label": "Is Mandatory"
}
],
"modified": "2019-05-09 15:30:55.339917",
"modified": "2019-05-16 13:37:04.240148",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Accounting Dimension",

View File

@ -13,8 +13,6 @@ class AccountingDimension(Document):
def before_insert(self):
self.set_fieldname_and_label()
def after_insert(self):
self.make_accounting_dimension_in_accounting_doctypes()
def on_trash(self):
@ -28,21 +26,27 @@ class AccountingDimension(Document):
self.fieldname = scrub(self.label)
def make_accounting_dimension_in_accounting_doctypes(self):
last_created_accounting_dimension = get_last_created_accounting_dimension()
doclist = ["GL Entry", "Sales Invoice", "Purchase Invoice", "Payment Entry", "BOM", "Sales Order", "Purchase Order",
"Stock Entry", "Budget", "Payroll Entry", "Delivery Note"]
doclist = ["GL Entry", "Sales Invoice", "Purchase Invoice", "Payment Entry", "BOM", "Sales Order", "Purchase Order", "Asset",
"Stock Entry", "Budget", "Payroll Entry", "Delivery Note", "Sales Invoice Item", "Purchase Invoice Item", "Sales Order Item",
"Purchase Order Item", "Journal Entry Account", "Material Request Item", "Delivery Note Item", "Purchase Receipt Item",
"Purchase Order Item"]
df = {
"fieldname": self.fieldname,
"label": self.label,
"fieldtype": "Link",
"options": self.document_type,
"insert_after": last_created_accounting_dimension if last_created_accounting_dimension else "project"
}
if self.is_mandatory:
df.update({
"reqd": 1
})
for doctype in doclist:
df = {
"fieldname": self.fieldname,
"label": self.label,
"fieldtype": "Link",
"options": self.document_type,
"insert_after": "cost_center"
}
if doctype == "Budget":
df.update({
"depends_on": "eval:doc.budget_against == '{0}'".format(self.document_type)
@ -73,12 +77,16 @@ class AccountingDimension(Document):
"property_type": "Text",
"value": "\nCost Center\nProject\n" + self.document_type
}).insert(ignore_permissions=True)
frappe.clear_cache(doctype=doctype)
else:
create_custom_field(doctype, df)
frappe.clear_cache(doctype=doctype)
def delete_accounting_dimension(self):
doclist = ["GL Entry", "Sales Invoice", "Purchase Invoice", "Payment Entry", "BOM", "Sales Order", "Purchase Order",
"Stock Entry", "Budget", "Payroll Entry", "Delivery Note"]
doclist = ["GL Entry", "Sales Invoice", "Purchase Invoice", "Payment Entry", "BOM", "Sales Order", "Purchase Order", "Asset",
"Stock Entry", "Budget", "Payroll Entry", "Delivery Note", "Sales Invoice Item", "Purchase Invoice Item", "Sales Order Item",
"Purchase Order Item", "Journal Entry Account", "Material Request Item", "Delivery Note Item", "Purchase Receipt Item",
"Purchase Order Item"]
frappe.db.sql("""
DELETE FROM `tabCustom Field`
@ -92,21 +100,16 @@ class AccountingDimension(Document):
AND doc_type IN (%s)""" %
('%s', ', '.join(['%s']* len(doclist))), tuple([self.fieldname] + doclist))
# budget_against_property = frappe.get_doc("Property Setter", "Budget-budget_against-options")
# value_list = budget_against_property.value.split('\n')[3:]
# value_list.remove(self.document_type)
budget_against_property = frappe.get_doc("Property Setter", "Budget-budget_against-options")
value_list = budget_against_property.value.split('\n')[3:]
value_list.remove(self.document_type)
# budget_against_property.value = "\nCost Center\nProject\n" + "\n".join(value_list)
budget_against_property.value = "\nCost Center\nProject\n" + "\n".join(value_list)
budget_against_property.save()
for doc in doclist:
frappe.clear_cache(doctype=doc)
def get_last_created_accounting_dimension():
last_created_accounting_dimension = frappe.db.sql("select fieldname, max(creation) from `tabAccounting Dimension`", as_dict=1)
if last_created_accounting_dimension[0]:
return last_created_accounting_dimension[0].fieldname
def get_accounting_dimensions():
accounting_dimensions = frappe.get_all("Accounting Dimension", fields=["fieldname"])

View File

@ -0,0 +1,12 @@
from __future__ import unicode_literals
from frappe import _
def get_data():
return {
'transactions': [
{
'label': _('Accounting Doctypes')
}
]
}

View File

@ -174,6 +174,11 @@ def get_data():
"name": "Cheque Print Template",
"description": _("Setup cheque dimensions for printing")
},
{
"type": "doctype",
"name": "Accounting Dimension",
"description": _("Setup custom dimensions for accounting")
},
]
},
{