Merge branch 'develop' of https://github.com/frappe/erpnext into erpnext-refactoring

This commit is contained in:
Nabin Hait
2026-06-03 15:20:49 +05:30
26 changed files with 326 additions and 255 deletions

View File

@@ -198,21 +198,9 @@ def add_dimension_to_budget_doctype(df, doc):
def delete_accounting_dimension(doc):
doclist = get_doctypes_with_dimensions()
frappe.db.sql(
"""
DELETE FROM `tabCustom Field`
WHERE fieldname = {}
AND dt IN ({})""".format("%s", ", ".join(["%s"] * len(doclist))), # nosec
tuple([doc.fieldname, *doclist]),
)
frappe.db.delete("Custom Field", filters={"fieldname": doc.fieldname, "dt": ["in", doclist]})
frappe.db.sql(
"""
DELETE FROM `tabProperty Setter`
WHERE field_name = {}
AND doc_type IN ({})""".format("%s", ", ".join(["%s"] * len(doclist))), # nosec
tuple([doc.fieldname, *doclist]),
)
frappe.db.delete("Property Setter", filters={"field_name": doc.fieldname, "doc_type": ["in", doclist]})
budget_against_property = frappe.get_doc("Property Setter", "Budget-budget_against-options")
value_list = budget_against_property.value.split("\n")[3:]
@@ -273,13 +261,27 @@ def get_accounting_dimensions(as_list=True):
def get_checks_for_pl_and_bs_accounts():
return frappe.db.sql(
"""SELECT p.label, p.disabled, p.fieldname, c.default_dimension, c.company, c.mandatory_for_pl, c.mandatory_for_bs
FROM `tabAccounting Dimension`p ,`tabAccounting Dimension Detail` c
WHERE p.name = c.parent AND p.disabled = 0""",
as_dict=1,
AccountingDimension = frappe.qb.DocType("Accounting Dimension")
AccountingDimensionDetail = frappe.qb.DocType("Accounting Dimension Detail")
query = (
frappe.qb.from_(AccountingDimension)
.join(AccountingDimensionDetail)
.on(AccountingDimension.name == AccountingDimensionDetail.parent)
.select(
AccountingDimension.label,
AccountingDimension.disabled,
AccountingDimension.fieldname,
AccountingDimensionDetail.default_dimension,
AccountingDimensionDetail.company,
AccountingDimensionDetail.mandatory_for_pl,
AccountingDimensionDetail.mandatory_for_bs,
)
.where(AccountingDimension.disabled == 0)
)
return query.run(as_dict=1)
def get_dimension_with_children(doctype, dimensions):
if isinstance(dimensions, str):

View File

@@ -43,18 +43,19 @@ class AccountingDimensionFilter(Document):
self.validate_applicable_accounts()
def validate_applicable_accounts(self):
accounts = frappe.db.sql(
"""
SELECT a.applicable_on_account as account
FROM `tabApplicable On Account` a, `tabAccounting Dimension Filter` d
WHERE d.name = a.parent
and d.name != %s
and d.accounting_dimension = %s
""",
(self.name, self.accounting_dimension),
as_dict=1,
ApplicableOnAccount = frappe.qb.DocType("Applicable On Account")
AccountingDimensionFilter = frappe.qb.DocType("Accounting Dimension Filter")
query = (
frappe.qb.from_(ApplicableOnAccount)
.join(AccountingDimensionFilter)
.on(AccountingDimensionFilter.name == ApplicableOnAccount.parent)
.select(ApplicableOnAccount.applicable_on_account.as_("account"))
.where(AccountingDimensionFilter.name != self.name)
.where(AccountingDimensionFilter.accounting_dimension == self.accounting_dimension)
)
accounts = query.run(as_dict=1)
account_list = [d.account for d in accounts]
for account in self.get("accounts"):
@@ -69,22 +70,28 @@ class AccountingDimensionFilter(Document):
def get_dimension_filter_map():
filters = frappe.db.sql(
"""
SELECT
a.applicable_on_account, d.dimension_value, p.accounting_dimension,
p.allow_or_restrict, p.fieldname, a.is_mandatory
FROM
`tabApplicable On Account` a,
`tabAccounting Dimension Filter` p
LEFT JOIN `tabAllowed Dimension` d ON d.parent = p.name
WHERE
p.name = a.parent
AND p.disabled = 0
""",
as_dict=1,
ApplicableOnAccount = frappe.qb.DocType("Applicable On Account")
AccountingDimensionFilter = frappe.qb.DocType("Accounting Dimension Filter")
AllowedDimension = frappe.qb.DocType("Allowed Dimension")
query = (
frappe.qb.from_(AccountingDimensionFilter)
.join(ApplicableOnAccount)
.on(AccountingDimensionFilter.name == ApplicableOnAccount.parent)
.left_join(AllowedDimension)
.on(AllowedDimension.parent == AccountingDimensionFilter.name)
.select(
ApplicableOnAccount.applicable_on_account,
AllowedDimension.dimension_value,
AccountingDimensionFilter.accounting_dimension,
AccountingDimensionFilter.allow_or_restrict,
AccountingDimensionFilter.fieldname,
ApplicableOnAccount.is_mandatory,
)
.where(AccountingDimensionFilter.disabled == 0)
)
filters = query.run(as_dict=1)
dimension_filter_map = {}
for f in filters:

View File

@@ -46,23 +46,19 @@ class AccountingPeriod(Document):
self.name = " - ".join([self.period_name, company_abbr])
def validate_overlap(self):
existing_accounting_period = frappe.db.sql(
"""select name from `tabAccounting Period`
where (
(%(start_date)s between start_date and end_date)
or (%(end_date)s between start_date and end_date)
or (start_date between %(start_date)s and %(end_date)s)
or (end_date between %(start_date)s and %(end_date)s)
) and name!=%(name)s and company=%(company)s""",
{
"start_date": self.start_date,
"end_date": self.end_date,
"name": self.name,
"company": self.company,
},
as_dict=True,
AccountingPeriod = frappe.qb.DocType("Accounting Period")
query = (
frappe.qb.from_(AccountingPeriod)
.select(AccountingPeriod.name)
.where(AccountingPeriod.start_date <= self.end_date)
.where(AccountingPeriod.end_date >= self.start_date)
.where(AccountingPeriod.name != self.name)
.where(AccountingPeriod.company == self.company)
)
existing_accounting_period = query.run(as_dict=True)
if len(existing_accounting_period) > 0:
frappe.throw(
_("Accounting Period overlaps with {0}").format(existing_accounting_period[0].get("name")),

View File

@@ -629,15 +629,16 @@ class PurchaseInvoice(BuyingController):
throw(msg, title=_("Mandatory Purchase Order"))
def pr_required(self):
stock_items = self.get_stock_items()
if frappe.db.get_single_value("Buying Settings", "pr_required") == "Yes":
stock_and_asset_items = self.get_stock_items()
stock_and_asset_items.extend(self.get_asset_items())
if frappe.get_value(
"Supplier", self.supplier, "allow_purchase_invoice_creation_without_purchase_receipt"
):
return
for d in self.get("items"):
if not d.purchase_receipt and d.item_code in stock_items:
if not d.purchase_receipt and d.item_code in stock_and_asset_items:
msg = _("Purchase Receipt Required for item {}").format(frappe.bold(d.item_code))
msg += "<br><br>"
msg += _(

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,32 +1,37 @@
{
"add_total_row": 1,
"apply_user_permissions": 1,
"creation": "2013-04-22 16:16:03",
"disabled": 0,
"docstatus": 0,
"doctype": "Report",
"idx": 3,
"is_standard": "Yes",
"modified": "2017-02-24 20:09:46.150861",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Accounts Payable",
"owner": "Administrator",
"ref_doctype": "Purchase Invoice",
"report_name": "Accounts Payable",
"report_type": "Script Report",
"add_total_row": 1,
"add_translate_data": 0,
"columns": [],
"creation": "2013-04-22 16:16:03",
"default_print_format": "Accounts Payable Standard",
"disabled": 0,
"docstatus": 0,
"doctype": "Report",
"filters": [],
"idx": 3,
"is_standard": "Yes",
"modified": "2026-05-22 14:35:14.716933",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Accounts Payable",
"owner": "Administrator",
"prepared_report": 0,
"ref_doctype": "Purchase Invoice",
"report_name": "Accounts Payable",
"report_type": "Script Report",
"roles": [
{
"role": "Accounts User"
},
},
{
"role": "Purchase User"
},
},
{
"role": "Accounts Manager"
},
},
{
"role": "Auditor"
}
]
}
],
"timeout": 0
}

View File

@@ -1,32 +1,37 @@
{
"add_total_row": 1,
"apply_user_permissions": 1,
"creation": "2014-11-04 12:09:59.672379",
"disabled": 0,
"docstatus": 0,
"doctype": "Report",
"idx": 2,
"is_standard": "Yes",
"modified": "2017-02-24 20:11:35.655834",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Accounts Payable Summary",
"owner": "Administrator",
"ref_doctype": "Purchase Invoice",
"report_name": "Accounts Payable Summary",
"report_type": "Script Report",
"add_total_row": 1,
"add_translate_data": 0,
"columns": [],
"creation": "2014-11-04 12:09:59.672379",
"default_print_format": "Accounts Payable Summary Standard",
"disabled": 0,
"docstatus": 0,
"doctype": "Report",
"filters": [],
"idx": 2,
"is_standard": "Yes",
"modified": "2026-05-22 14:35:19.179799",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Accounts Payable Summary",
"owner": "Administrator",
"prepared_report": 0,
"ref_doctype": "Purchase Invoice",
"report_name": "Accounts Payable Summary",
"report_type": "Script Report",
"roles": [
{
"role": "Accounts User"
},
},
{
"role": "Purchase User"
},
},
{
"role": "Accounts Manager"
},
},
{
"role": "Auditor"
}
]
}
],
"timeout": 0
}

View File

@@ -1,26 +1,31 @@
{
"add_total_row": 1,
"apply_user_permissions": 1,
"creation": "2013-04-16 11:31:13",
"disabled": 0,
"docstatus": 0,
"doctype": "Report",
"idx": 3,
"is_standard": "Yes",
"modified": "2017-03-06 05:52:06.235584",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Accounts Receivable",
"owner": "Administrator",
"ref_doctype": "Sales Invoice",
"report_name": "Accounts Receivable",
"report_type": "Script Report",
"add_total_row": 1,
"add_translate_data": 0,
"columns": [],
"creation": "2013-04-16 11:31:13",
"default_print_format": "Accounts Receivable Standard",
"disabled": 0,
"docstatus": 0,
"doctype": "Report",
"filters": [],
"idx": 5,
"is_standard": "Yes",
"modified": "2026-05-22 14:34:57.666402",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Accounts Receivable",
"owner": "Administrator",
"prepared_report": 0,
"ref_doctype": "Sales Invoice",
"report_name": "Accounts Receivable",
"report_type": "Script Report",
"roles": [
{
"role": "Accounts Manager"
},
},
{
"role": "Accounts User"
}
]
}
],
"timeout": 0
}

View File

@@ -1,26 +1,31 @@
{
"add_total_row": 1,
"apply_user_permissions": 1,
"creation": "2014-10-17 15:45:00.694265",
"disabled": 0,
"docstatus": 0,
"doctype": "Report",
"idx": 2,
"is_standard": "Yes",
"modified": "2017-03-06 05:52:23.751082",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Accounts Receivable Summary",
"owner": "Administrator",
"ref_doctype": "Sales Invoice",
"report_name": "Accounts Receivable Summary",
"report_type": "Script Report",
"add_total_row": 1,
"add_translate_data": 0,
"columns": [],
"creation": "2014-10-17 15:45:00.694265",
"default_print_format": "Accounts Receivable Summary Standard",
"disabled": 0,
"docstatus": 0,
"doctype": "Report",
"filters": [],
"idx": 2,
"is_standard": "Yes",
"modified": "2026-05-22 14:35:10.656797",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Accounts Receivable Summary",
"owner": "Administrator",
"prepared_report": 0,
"ref_doctype": "Sales Invoice",
"report_name": "Accounts Receivable Summary",
"report_type": "Script Report",
"roles": [
{
"role": "Accounts Manager"
},
},
{
"role": "Accounts User"
}
]
}
],
"timeout": 0
}

View File

@@ -1,29 +1,34 @@
{
"add_total_row": 0,
"creation": "2014-07-14 05:24:20.385279",
"disabled": 0,
"docstatus": 0,
"doctype": "Report",
"idx": 2,
"is_standard": "Yes",
"modified": "2018-09-07 12:18:21.850851",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Balance Sheet",
"owner": "Administrator",
"prepared_report": 0,
"ref_doctype": "GL Entry",
"report_name": "Balance Sheet",
"report_type": "Script Report",
"add_total_row": 0,
"add_translate_data": 0,
"columns": [],
"creation": "2014-07-14 05:24:20.385279",
"default_print_format": "Balance Sheet Standard",
"disabled": 0,
"docstatus": 0,
"doctype": "Report",
"filters": [],
"idx": 3,
"is_standard": "Yes",
"modified": "2026-05-22 14:35:28.187799",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Balance Sheet",
"owner": "Administrator",
"prepared_report": 0,
"ref_doctype": "GL Entry",
"report_name": "Balance Sheet",
"report_type": "Script Report",
"roles": [
{
"role": "Accounts User"
},
},
{
"role": "Accounts Manager"
},
},
{
"role": "Auditor"
}
]
}
],
"timeout": 0
}

View File

@@ -1,29 +1,34 @@
{
"add_total_row": 0,
"apply_user_permissions": 1,
"creation": "2015-12-12 10:22:45.383203",
"disabled": 0,
"docstatus": 0,
"doctype": "Report",
"idx": 2,
"is_standard": "Yes",
"modified": "2017-02-24 20:09:19.748690",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Cash Flow",
"owner": "Administrator",
"ref_doctype": "GL Entry",
"report_name": "Cash Flow",
"report_type": "Script Report",
"add_total_row": 0,
"add_translate_data": 0,
"columns": [],
"creation": "2015-12-12 10:22:45.383203",
"default_print_format": "Cash Flow Statement Standard",
"disabled": 0,
"docstatus": 0,
"doctype": "Report",
"filters": [],
"idx": 3,
"is_standard": "Yes",
"modified": "2026-05-22 14:35:34.353508",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Cash Flow",
"owner": "Administrator",
"prepared_report": 0,
"ref_doctype": "GL Entry",
"report_name": "Cash Flow",
"report_type": "Script Report",
"roles": [
{
"role": "Accounts User"
},
},
{
"role": "Accounts Manager"
},
},
{
"role": "Auditor"
}
]
}
],
"timeout": 0
}

View File

@@ -3,14 +3,14 @@
"add_translate_data": 0,
"columns": [],
"creation": "2013-12-06 13:22:23",
"default_print_format": "General Ledger Standard",
"disabled": 0,
"docstatus": 0,
"doctype": "Report",
"filters": [],
"idx": 3,
"idx": 4,
"is_standard": "Yes",
"letterhead": null,
"modified": "2025-11-05 15:47:59.597853",
"modified": "2026-05-22 14:34:35.246000",
"modified_by": "Administrator",
"module": "Accounts",
"name": "General Ledger",

View File

@@ -1,9 +1,13 @@
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
frappe.query_reports["Gross and Net Profit Report"] = $.extend({}, erpnext.financial_statements);
const GNP_REPORT = "Gross and Net Profit Report";
frappe.query_reports["Gross and Net Profit Report"]["filters"].push({
frappe.query_reports[GNP_REPORT] = $.extend({}, erpnext.financial_statements);
erpnext.utils.add_dimensions(GNP_REPORT, 10);
frappe.query_reports[GNP_REPORT]["filters"].push({
fieldname: "accumulated_values",
label: __("Accumulated Values"),
fieldtype: "Check",

View File

@@ -1,29 +1,34 @@
{
"add_total_row": 0,
"apply_user_permissions": 1,
"creation": "2014-07-18 11:43:33.173207",
"disabled": 0,
"docstatus": 0,
"doctype": "Report",
"idx": 2,
"is_standard": "Yes",
"modified": "2017-02-24 20:12:40.282376",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Profit and Loss Statement",
"owner": "Administrator",
"ref_doctype": "GL Entry",
"report_name": "Profit and Loss Statement",
"report_type": "Script Report",
"add_total_row": 0,
"add_translate_data": 0,
"columns": [],
"creation": "2014-07-18 11:43:33.173207",
"default_print_format": "P&L Statement Standard",
"disabled": 0,
"docstatus": 0,
"doctype": "Report",
"filters": [],
"idx": 2,
"is_standard": "Yes",
"modified": "2026-05-22 14:36:04.544347",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Profit and Loss Statement",
"owner": "Administrator",
"prepared_report": 0,
"ref_doctype": "GL Entry",
"report_name": "Profit and Loss Statement",
"report_type": "Script Report",
"roles": [
{
"role": "Accounts User"
},
},
{
"role": "Accounts Manager"
},
},
{
"role": "Auditor"
}
]
}
],
"timeout": 0
}

View File

@@ -1,19 +1,23 @@
{
"add_total_row": 0,
"apply_user_permissions": 1,
"creation": "2014-07-22 11:41:23.743564",
"disabled": 0,
"docstatus": 0,
"doctype": "Report",
"idx": 2,
"is_standard": "Yes",
"modified": "2017-02-24 20:12:33.520866",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Trial Balance",
"owner": "Administrator",
"ref_doctype": "GL Entry",
"report_name": "Trial Balance",
"add_total_row": 0,
"add_translate_data": 0,
"columns": [],
"creation": "2014-07-22 11:41:23.743564",
"default_print_format": "Trial Balance Standard",
"disabled": 0,
"docstatus": 0,
"doctype": "Report",
"filters": [],
"idx": 2,
"is_standard": "Yes",
"modified": "2026-05-22 14:35:44.889062",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Trial Balance",
"owner": "Administrator",
"prepared_report": 0,
"ref_doctype": "GL Entry",
"report_name": "Trial Balance",
"report_type": "Script Report",
"roles": [
{
@@ -25,5 +29,6 @@
{
"role": "Auditor"
}
]
}
],
"timeout": 0
}

View File

@@ -262,7 +262,15 @@
},
"Belgium VAT 12%": {
"account_name": "VAT 12%",
"tax_rate": 12
"tax_rate": 12.00
},
"Belgium VAT 6%": {
"account_name": "VAT 6%",
"tax_rate": 6.00
},
"Belgium VAT 0%": {
"account_name": "VAT 0%",
"tax_rate": 0.00
}
},

View File

@@ -33,19 +33,21 @@ frappe.listview_settings["Item"] = {
},
onload: function (listview) {
listview.columns = listview.columns.map((col) => {
if (!col.df) return col;
const renames = {
is_fixed_asset: __("Item Type"),
is_sales_item: __("Purpose"),
stock_uom: __("UOM"),
};
if (col.df.fieldname in renames) {
return { ...col, df: { ...col.df, label: renames[col.df.fieldname] } };
}
return col;
});
listview.render_header(true);
if (listview.view === "List") {
listview.columns = listview.columns.map((col) => {
if (!col.df) return col;
const renames = {
is_fixed_asset: __("Item Type"),
is_sales_item: __("Purpose"),
stock_uom: __("UOM"),
};
if (col.df.fieldname in renames) {
return { ...col, df: { ...col.df, label: renames[col.df.fieldname] } };
}
return col;
});
listview.render_header(true);
}
},
get_indicator: function (doc) {

View File

@@ -558,10 +558,21 @@ def get_basic_details(ctx: ItemDetailsCtx, item, overwrite_warehouse=True) -> It
ctx.name, ctx.conversion_rate, item.name, out.conversion_factor
)
expense_account_field = "default_expense_account"
if (
item.is_stock_item
and erpnext.is_perpetual_inventory_enabled(ctx.company)
and (
ctx.doctype == "Purchase Receipt"
or (ctx.doctype == "Purchase Invoice" and ctx.get("update_stock"))
)
):
expense_account_field = "stock_received_but_not_billed"
# if default specified in item is for another company, fetch from company
for d in [
["Account", "income_account", "default_income_account"],
["Account", "expense_account", "default_expense_account"],
["Account", "expense_account", expense_account_field],
["Cost Center", "cost_center", "cost_center"],
["Warehouse", "warehouse", ""],
]: