fix: Remove dimensions from boot
This commit is contained in:
parent
ada1ac8013
commit
6dd5f74671
@ -1,6 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_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",
|
||||||
@ -10,8 +8,6 @@
|
|||||||
"label",
|
"label",
|
||||||
"fieldname",
|
"fieldname",
|
||||||
"dimension_defaults",
|
"dimension_defaults",
|
||||||
"mandatory_for_bs",
|
|
||||||
"mandatory_for_pl",
|
|
||||||
"disabled"
|
"disabled"
|
||||||
],
|
],
|
||||||
"fields": [
|
"fields": [
|
||||||
@ -43,18 +39,6 @@
|
|||||||
"label": "Disable",
|
"label": "Disable",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"default": "0",
|
|
||||||
"fieldname": "mandatory_for_bs",
|
|
||||||
"fieldtype": "Check",
|
|
||||||
"label": "Mandatory For Balance Sheet"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"default": "0",
|
|
||||||
"fieldname": "mandatory_for_pl",
|
|
||||||
"fieldtype": "Check",
|
|
||||||
"label": "Mandatory For Profit and Loss Account"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"fieldname": "dimension_defaults",
|
"fieldname": "dimension_defaults",
|
||||||
"fieldtype": "Table",
|
"fieldtype": "Table",
|
||||||
@ -62,7 +46,7 @@
|
|||||||
"options": "Accounting Dimension Detail"
|
"options": "Accounting Dimension Detail"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"modified": "2019-07-16 18:00:11.365510",
|
"modified": "2019-07-17 16:49:31.134385",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Accounting Dimension",
|
"name": "Accounting Dimension",
|
||||||
|
@ -144,14 +144,6 @@ def toggle_disabling(doc):
|
|||||||
|
|
||||||
frappe.clear_cache(doctype=doctype)
|
frappe.clear_cache(doctype=doctype)
|
||||||
|
|
||||||
dimension_filters = frappe.db.sql("""
|
|
||||||
SELECT label, fieldname, document_type
|
|
||||||
FROM `tabAccounting Dimension`
|
|
||||||
WHERE disabled = 0
|
|
||||||
""", as_dict=1)
|
|
||||||
|
|
||||||
return dimension_filters
|
|
||||||
|
|
||||||
def get_doctypes_with_dimensions():
|
def get_doctypes_with_dimensions():
|
||||||
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",
|
||||||
@ -163,9 +155,33 @@ def get_doctypes_with_dimensions():
|
|||||||
return doclist
|
return doclist
|
||||||
|
|
||||||
def get_accounting_dimensions(as_list=True):
|
def get_accounting_dimensions(as_list=True):
|
||||||
accounting_dimensions = frappe.get_all("Accounting Dimension", fields=["label", "fieldname", "mandatory_for_pl", "mandatory_for_bs", "disabled"], filters={"disabled": 0})
|
accounting_dimensions = frappe.get_all("Accounting Dimension", fields=["label", "fieldname", "disabled"])
|
||||||
|
|
||||||
if as_list:
|
if as_list:
|
||||||
return [d.fieldname for d in accounting_dimensions]
|
return [d.fieldname for d in accounting_dimensions]
|
||||||
else:
|
else:
|
||||||
return accounting_dimensions
|
return accounting_dimensions
|
||||||
|
|
||||||
|
def get_checks_for_pl_and_bs_accounts():
|
||||||
|
dimensions = frappe.db.sql("""SELECT parent, company, mandatory_for_pl, mandatory_for_bs
|
||||||
|
FROM `tabAccounting Dimension Detail`""", as_dict=1)
|
||||||
|
|
||||||
|
return dimensions
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def get_dimension_filters():
|
||||||
|
dimension_filters = frappe.db.sql("""
|
||||||
|
SELECT label, fieldname, document_type
|
||||||
|
FROM `tabAccounting Dimension`
|
||||||
|
WHERE disabled = 0
|
||||||
|
""", as_dict=1)
|
||||||
|
|
||||||
|
default_dimensions = frappe.db.sql("""SELECT parent, company, default_dimension
|
||||||
|
FROM `tabAccounting Dimension Detail`""", as_dict=1)
|
||||||
|
|
||||||
|
default_dimensions_map = {}
|
||||||
|
for dimension in default_dimensions:
|
||||||
|
default_dimensions_map.setdefault(dimension['company'], {})
|
||||||
|
default_dimensions_map[dimension['company']][dimension['parent']] = dimension['default_dimension']
|
||||||
|
|
||||||
|
return dimension_filters, default_dimensions_map
|
||||||
|
@ -6,10 +6,13 @@
|
|||||||
"field_order": [
|
"field_order": [
|
||||||
"company",
|
"company",
|
||||||
"reference_document",
|
"reference_document",
|
||||||
"default_dimension"
|
"default_dimension",
|
||||||
|
"mandatory_for_bs",
|
||||||
|
"mandatory_for_pl"
|
||||||
],
|
],
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
|
"columns": 2,
|
||||||
"fieldname": "company",
|
"fieldname": "company",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
@ -26,16 +29,33 @@
|
|||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"columns": 2,
|
||||||
"fieldname": "default_dimension",
|
"fieldname": "default_dimension",
|
||||||
"fieldtype": "Dynamic Link",
|
"fieldtype": "Dynamic Link",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Default Dimension",
|
"label": "Default Dimension",
|
||||||
"options": "reference_document",
|
"options": "reference_document",
|
||||||
"reqd": 1
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"columns": 3,
|
||||||
|
"default": "0",
|
||||||
|
"fieldname": "mandatory_for_bs",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Mandatory For Balance Sheet"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"columns": 3,
|
||||||
|
"default": "0",
|
||||||
|
"fieldname": "mandatory_for_pl",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Mandatory For Profit and Loss Account"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"modified": "2019-07-16 18:54:52.202378",
|
"modified": "2019-07-17 23:34:33.026883",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Accounting Dimension Detail",
|
"name": "Accounting Dimension Detail",
|
||||||
|
@ -12,7 +12,7 @@ from erpnext.accounts.party import validate_party_gle_currency, validate_party_f
|
|||||||
from erpnext.accounts.utils import get_account_currency
|
from erpnext.accounts.utils import get_account_currency
|
||||||
from erpnext.accounts.utils import get_fiscal_year
|
from erpnext.accounts.utils import get_fiscal_year
|
||||||
from erpnext.exceptions import InvalidAccountCurrency
|
from erpnext.exceptions import InvalidAccountCurrency
|
||||||
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_accounting_dimensions
|
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_checks_for_pl_and_bs_accounts
|
||||||
|
|
||||||
exclude_from_linked_with = True
|
exclude_from_linked_with = True
|
||||||
class GLEntry(Document):
|
class GLEntry(Document):
|
||||||
@ -86,19 +86,19 @@ class GLEntry(Document):
|
|||||||
|
|
||||||
account_type = frappe.db.get_value("Account", self.account, "report_type")
|
account_type = frappe.db.get_value("Account", self.account, "report_type")
|
||||||
|
|
||||||
for dimension in get_accounting_dimensions(as_list=False):
|
for dimension in get_checks_for_pl_and_bs_accounts():
|
||||||
|
|
||||||
if account_type == "Profit and Loss" \
|
if account_type == "Profit and Loss" \
|
||||||
and dimension.mandatory_for_pl and not dimension.disabled:
|
and self.company == dimension.company and dimension.mandatory_for_pl and not dimension.disabled:
|
||||||
if not self.get(dimension.fieldname):
|
if not self.get(frappe.scrub(dimension.parent)):
|
||||||
frappe.throw(_("Accounting Dimension <b>{0}</b> is required for 'Profit and Loss' account {1}.")
|
frappe.throw(_("Accounting Dimension <b>{0}</b> is required for 'Profit and Loss' account {1}.")
|
||||||
.format(dimension.label, self.account))
|
.format(dimension.parent, self.account))
|
||||||
|
|
||||||
if account_type == "Balance Sheet" \
|
if account_type == "Balance Sheet" \
|
||||||
and dimension.mandatory_for_bs and not dimension.disabled:
|
and self.company == dimension.company and dimension.mandatory_for_bs and not dimension.disabled:
|
||||||
if not self.get(dimension.fieldname):
|
if not self.get(frappe.scrub(dimension.parent)):
|
||||||
frappe.throw(_("Accounting Dimension <b>{0}</b> is required for 'Balance Sheet' account {1}.")
|
frappe.throw(_("Accounting Dimension <b>{0}</b> is required for 'Balance Sheet' account {1}.")
|
||||||
.format(dimension.label, self.account))
|
.format(dimension.parent, self.account))
|
||||||
|
|
||||||
|
|
||||||
def check_pl_account(self):
|
def check_pl_account(self):
|
||||||
|
@ -115,7 +115,7 @@ frappe.query_reports["Accounts Payable"] = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
frappe.boot.dimension_filters.forEach((dimension) => {
|
erpnext.dimension_filters.forEach((dimension) => {
|
||||||
frappe.query_reports["Accounts Payable"].filters.splice(9, 0 ,{
|
frappe.query_reports["Accounts Payable"].filters.splice(9, 0 ,{
|
||||||
"fieldname": dimension["fieldname"],
|
"fieldname": dimension["fieldname"],
|
||||||
"label": __(dimension["label"]),
|
"label": __(dimension["label"]),
|
||||||
|
@ -99,7 +99,7 @@ frappe.query_reports["Accounts Payable Summary"] = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
frappe.boot.dimension_filters.forEach((dimension) => {
|
erpnext.dimension_filters.forEach((dimension) => {
|
||||||
frappe.query_reports["Accounts Payable Summary"].filters.splice(9, 0 ,{
|
frappe.query_reports["Accounts Payable Summary"].filters.splice(9, 0 ,{
|
||||||
"fieldname": dimension["fieldname"],
|
"fieldname": dimension["fieldname"],
|
||||||
"label": __(dimension["label"]),
|
"label": __(dimension["label"]),
|
||||||
|
@ -173,7 +173,7 @@ frappe.query_reports["Accounts Receivable"] = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
frappe.boot.dimension_filters.forEach((dimension) => {
|
erpnext.dimension_filters.forEach((dimension) => {
|
||||||
frappe.query_reports["Accounts Receivable"].filters.splice(9, 0 ,{
|
frappe.query_reports["Accounts Receivable"].filters.splice(9, 0 ,{
|
||||||
"fieldname": dimension["fieldname"],
|
"fieldname": dimension["fieldname"],
|
||||||
"label": __(dimension["label"]),
|
"label": __(dimension["label"]),
|
||||||
|
@ -117,7 +117,7 @@ frappe.query_reports["Accounts Receivable Summary"] = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
frappe.boot.dimension_filters.forEach((dimension) => {
|
erpnext.dimension_filters.forEach((dimension) => {
|
||||||
frappe.query_reports["Accounts Receivable Summary"].filters.splice(9, 0 ,{
|
frappe.query_reports["Accounts Receivable Summary"].filters.splice(9, 0 ,{
|
||||||
"fieldname": dimension["fieldname"],
|
"fieldname": dimension["fieldname"],
|
||||||
"label": __(dimension["label"]),
|
"label": __(dimension["label"]),
|
||||||
|
@ -63,7 +63,7 @@ frappe.query_reports["Budget Variance Report"] = {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
frappe.boot.dimension_filters.forEach((dimension) => {
|
erpnext.dimension_filters.forEach((dimension) => {
|
||||||
frappe.query_reports["Budget Variance Report"].filters[4].options.push(dimension["document_type"]);
|
frappe.query_reports["Budget Variance Report"].filters[4].options.push(dimension["document_type"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ frappe.query_reports["General Ledger"] = {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
frappe.boot.dimension_filters.forEach((dimension) => {
|
erpnext.dimension_filters.forEach((dimension) => {
|
||||||
frappe.query_reports["General Ledger"].filters.splice(15, 0 ,{
|
frappe.query_reports["General Ledger"].filters.splice(15, 0 ,{
|
||||||
"fieldname": dimension["fieldname"],
|
"fieldname": dimension["fieldname"],
|
||||||
"label": __(dimension["label"]),
|
"label": __(dimension["label"]),
|
||||||
|
@ -105,7 +105,7 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
|
|||||||
"initial_depth": 3
|
"initial_depth": 3
|
||||||
}
|
}
|
||||||
|
|
||||||
frappe.boot.dimension_filters.forEach((dimension) => {
|
erpnext.dimension_filters.forEach((dimension) => {
|
||||||
frappe.query_reports["Profitability Analysis"].filters[1].options.push(dimension["document_type"]);
|
frappe.query_reports["Profitability Analysis"].filters[1].options.push(dimension["document_type"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ frappe.query_reports["Sales Register"] = {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
frappe.boot.dimension_filters.forEach((dimension) => {
|
erpnext.dimension_filters.forEach((dimension) => {
|
||||||
frappe.query_reports["Sales Register"].filters.splice(7, 0 ,{
|
frappe.query_reports["Sales Register"].filters.splice(7, 0 ,{
|
||||||
"fieldname": dimension["fieldname"],
|
"fieldname": dimension["fieldname"],
|
||||||
"label": __(dimension["label"]),
|
"label": __(dimension["label"]),
|
||||||
|
@ -95,7 +95,7 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
|
|||||||
"initial_depth": 3
|
"initial_depth": 3
|
||||||
}
|
}
|
||||||
|
|
||||||
frappe.boot.dimension_filters.forEach((dimension) => {
|
erpnext.dimension_filters.forEach((dimension) => {
|
||||||
frappe.query_reports["Trial Balance"].filters.splice(5, 0 ,{
|
frappe.query_reports["Trial Balance"].filters.splice(5, 0 ,{
|
||||||
"fieldname": dimension["fieldname"],
|
"fieldname": dimension["fieldname"],
|
||||||
"label": __(dimension["label"]),
|
"label": __(dimension["label"]),
|
||||||
|
@ -129,7 +129,7 @@ function get_filters(){
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
frappe.boot.dimension_filters.forEach((dimension) => {
|
erpnext.dimension_filters.forEach((dimension) => {
|
||||||
filters.push({
|
filters.push({
|
||||||
"fieldname": dimension["fieldname"],
|
"fieldname": dimension["fieldname"],
|
||||||
"label": __(dimension["label"]),
|
"label": __(dimension["label"]),
|
||||||
|
@ -7,10 +7,18 @@ erpnext.doctypes_with_dimensions = ["GL Entry", "Sales Invoice", "Purchase Invoi
|
|||||||
"Landed Cost Item", "Asset Value Adjustment", "Loyalty Program", "Fee Schedule", "Fee Structure", "Stock Reconciliation",
|
"Landed Cost Item", "Asset Value Adjustment", "Loyalty Program", "Fee Schedule", "Fee Structure", "Stock Reconciliation",
|
||||||
"Travel Request", "Fees", "POS Profile"];
|
"Travel Request", "Fees", "POS Profile"];
|
||||||
|
|
||||||
|
frappe.call({
|
||||||
|
method: "erpnext.accounts.doctype.accounting_dimension.accounting_dimension.get_dimension_filters",
|
||||||
|
callback: function(r){
|
||||||
|
erpnext.dimension_filters = r.message[0];
|
||||||
|
erpnext.default_dimensions = r.message[1];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
erpnext.doctypes_with_dimensions.forEach((doctype) => {
|
erpnext.doctypes_with_dimensions.forEach((doctype) => {
|
||||||
frappe.ui.form.on(doctype, {
|
frappe.ui.form.on(doctype, {
|
||||||
onload: function(frm) {
|
onload: function(frm) {
|
||||||
frappe.boot.dimension_filters.forEach((dimension) => {
|
erpnext.dimension_filters.forEach((dimension) => {
|
||||||
frappe.model.with_doctype(dimension['document_type'], () => {
|
frappe.model.with_doctype(dimension['document_type'], () => {
|
||||||
if (frappe.meta.has_field(dimension['document_type'], 'is_group')) {
|
if (frappe.meta.has_field(dimension['document_type'], 'is_group')) {
|
||||||
frm.set_query(dimension['fieldname'], {
|
frm.set_query(dimension['fieldname'], {
|
||||||
@ -23,21 +31,21 @@ erpnext.doctypes_with_dimensions.forEach((doctype) => {
|
|||||||
|
|
||||||
company: function(frm) {
|
company: function(frm) {
|
||||||
if(frm.doc.company) {
|
if(frm.doc.company) {
|
||||||
frappe.boot.dimension_filters.forEach((dimension) => {
|
erpnext.dimension_filters.forEach((dimension) => {
|
||||||
frm.set_value(dimension['fieldname'], frappe.boot.default_dimensions[frm.doc.company][dimension['document_type']]);
|
frm.set_value(dimension['fieldname'], erpnext.default_dimensions[frm.doc.company][dimension['document_type']]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
items_add: function(frm, cdt, cdn) {
|
items_add: function(frm, cdt, cdn) {
|
||||||
frappe.boot.dimension_filters.forEach((dimension) => {
|
erpnext.dimension_filters.forEach((dimension) => {
|
||||||
var row = frappe.get_doc(cdt, cdn);
|
var row = frappe.get_doc(cdt, cdn);
|
||||||
frm.script_manager.copy_from_first_row("items", row, [dimension['fieldname']]);
|
frm.script_manager.copy_from_first_row("items", row, [dimension['fieldname']]);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
accounts_add: function(frm, cdt, cdn) {
|
accounts_add: function(frm, cdt, cdn) {
|
||||||
frappe.boot.dimension_filters.forEach((dimension) => {
|
erpnext.dimension_filters.forEach((dimension) => {
|
||||||
var row = frappe.get_doc(cdt, cdn);
|
var row = frappe.get_doc(cdt, cdn);
|
||||||
frm.script_manager.copy_from_first_row("accounts", row, [dimension['fieldname']]);
|
frm.script_manager.copy_from_first_row("accounts", row, [dimension['fieldname']]);
|
||||||
});
|
});
|
||||||
|
@ -39,8 +39,6 @@ def boot_session(bootinfo):
|
|||||||
|
|
||||||
party_account_types = frappe.db.sql(""" select name, ifnull(account_type, '') from `tabParty Type`""")
|
party_account_types = frappe.db.sql(""" select name, ifnull(account_type, '') from `tabParty Type`""")
|
||||||
bootinfo.party_account_types = frappe._dict(party_account_types)
|
bootinfo.party_account_types = frappe._dict(party_account_types)
|
||||||
load_dimension_filters(bootinfo)
|
|
||||||
load_default_dimensions(bootinfo)
|
|
||||||
|
|
||||||
def load_country_and_currency(bootinfo):
|
def load_country_and_currency(bootinfo):
|
||||||
country = frappe.db.get_default("country")
|
country = frappe.db.get_default("country")
|
||||||
@ -51,22 +49,6 @@ def load_country_and_currency(bootinfo):
|
|||||||
number_format, smallest_currency_fraction_value, symbol from tabCurrency
|
number_format, smallest_currency_fraction_value, symbol from tabCurrency
|
||||||
where enabled=1""", as_dict=1, update={"doctype":":Currency"})
|
where enabled=1""", as_dict=1, update={"doctype":":Currency"})
|
||||||
|
|
||||||
def load_dimension_filters(bootinfo):
|
|
||||||
bootinfo.dimension_filters = frappe.db.sql("""
|
|
||||||
SELECT label, fieldname, document_type
|
|
||||||
FROM `tabAccounting Dimension`
|
|
||||||
WHERE disabled = 0
|
|
||||||
""", as_dict=1)
|
|
||||||
|
|
||||||
def load_default_dimensions(bootinfo):
|
|
||||||
default_dimensions = frappe.db.sql("""SELECT parent, company, default_dimension
|
|
||||||
FROM `tabAccounting Dimension Detail`""", as_dict=1)
|
|
||||||
|
|
||||||
bootinfo.default_dimensions = {}
|
|
||||||
for dimension in default_dimensions:
|
|
||||||
bootinfo.default_dimensions.setdefault(dimension['company'], {})
|
|
||||||
bootinfo.default_dimensions[dimension['company']][dimension['parent']] = dimension['default_dimension']
|
|
||||||
|
|
||||||
def update_page_info(bootinfo):
|
def update_page_info(bootinfo):
|
||||||
bootinfo.page_info.update({
|
bootinfo.page_info.update({
|
||||||
"Chart of Accounts": {
|
"Chart of Accounts": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user