Merge pull request #36151 from rohitwaghchaure/table-for-serial-and-batch
fix: Added report 'Serial and Batch Summary' to view serial / batch nos
diff --git a/.github/workflows/release_notes.yml b/.github/workflows/release_notes.yml
new file mode 100644
index 0000000..e765a66
--- /dev/null
+++ b/.github/workflows/release_notes.yml
@@ -0,0 +1,38 @@
+# This action:
+#
+# 1. Generates release notes using github API.
+# 2. Strips unnecessary info like chore/style etc from notes.
+# 3. Updates release info.
+
+# This action needs to be maintained on all branches that do releases.
+
+name: 'Release Notes'
+
+on:
+ workflow_dispatch:
+ inputs:
+ tag_name:
+ description: 'Tag of release like v13.0.0'
+ required: true
+ type: string
+ release:
+ types: [released]
+
+permissions:
+ contents: read
+
+jobs:
+ regen-notes:
+ name: 'Regenerate release notes'
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Update notes
+ run: |
+ NEW_NOTES=$(gh api --method POST -H "Accept: application/vnd.github+json" /repos/frappe/erpnext/releases/generate-notes -f tag_name=$RELEASE_TAG | jq -r '.body' | sed -E '/^\* (chore|ci|test|docs|style)/d' )
+ RELEASE_ID=$(gh api -H "Accept: application/vnd.github+json" /repos/frappe/erpnext/releases/tags/$RELEASE_TAG | jq -r '.id')
+ gh api --method PATCH -H "Accept: application/vnd.github+json" /repos/frappe/erpnext/releases/$RELEASE_ID -f body="$NEW_NOTES"
+
+ env:
+ GH_TOKEN: ${{ secrets.RELEASE_TOKEN }}
+ RELEASE_TAG: ${{ github.event.inputs.tag_name || github.event.release.tag_name }}
diff --git a/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.py b/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.py
index 81ff6a5..15c84d4 100644
--- a/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.py
+++ b/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.py
@@ -271,6 +271,12 @@
as_dict=1,
)
+ if isinstance(with_cost_center_and_project, str):
+ if with_cost_center_and_project.lower().strip() == "true":
+ with_cost_center_and_project = True
+ else:
+ with_cost_center_and_project = False
+
if with_cost_center_and_project:
dimension_filters.extend(
[
diff --git a/erpnext/accounts/doctype/bank/bank.js b/erpnext/accounts/doctype/bank/bank.js
index 35d606b..6667193 100644
--- a/erpnext/accounts/doctype/bank/bank.js
+++ b/erpnext/accounts/doctype/bank/bank.js
@@ -8,9 +8,6 @@
},
refresh: function(frm) {
add_fields_to_mapping_table(frm);
-
- frappe.dynamic_link = { doc: frm.doc, fieldname: 'name', doctype: 'Bank' };
-
frm.toggle_display(['address_html','contact_html'], !frm.doc.__islocal);
if (frm.doc.__islocal) {
diff --git a/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.py b/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.py
index c52ea24..3b5698b 100644
--- a/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.py
+++ b/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.py
@@ -258,8 +258,8 @@
new_balance_in_base_currency = 0
new_balance_in_account_currency = 0
- current_exchange_rate = calculate_exchange_rate_using_last_gle(
- company, d.account, d.party_type, d.party
+ current_exchange_rate = (
+ calculate_exchange_rate_using_last_gle(company, d.account, d.party_type, d.party) or 0.0
)
gain_loss = new_balance_in_account_currency - (
diff --git a/erpnext/accounts/doctype/fiscal_year/fiscal_year.js b/erpnext/accounts/doctype/fiscal_year/fiscal_year.js
index bc77dac..508b2ea 100644
--- a/erpnext/accounts/doctype/fiscal_year/fiscal_year.js
+++ b/erpnext/accounts/doctype/fiscal_year/fiscal_year.js
@@ -8,17 +8,6 @@
frappe.datetime.add_days(frappe.defaults.get_default("year_end_date"), 1));
}
},
- refresh: function (frm) {
- if (!frm.doc.__islocal && (frm.doc.name != frappe.sys_defaults.fiscal_year)) {
- frm.add_custom_button(__("Set as Default"), () => frm.events.set_as_default(frm));
- frm.set_intro(__("To set this Fiscal Year as Default, click on 'Set as Default'"));
- } else {
- frm.set_intro("");
- }
- },
- set_as_default: function(frm) {
- return frm.call('set_as_default');
- },
year_start_date: function(frm) {
if (!frm.doc.is_short_year) {
let year_end_date =
diff --git a/erpnext/accounts/doctype/fiscal_year/fiscal_year.py b/erpnext/accounts/doctype/fiscal_year/fiscal_year.py
index 9d1b99b..0dfe569 100644
--- a/erpnext/accounts/doctype/fiscal_year/fiscal_year.py
+++ b/erpnext/accounts/doctype/fiscal_year/fiscal_year.py
@@ -4,28 +4,12 @@
import frappe
from dateutil.relativedelta import relativedelta
-from frappe import _, msgprint
+from frappe import _
from frappe.model.document import Document
from frappe.utils import add_days, add_years, cstr, getdate
class FiscalYear(Document):
- @frappe.whitelist()
- def set_as_default(self):
- frappe.db.set_single_value("Global Defaults", "current_fiscal_year", self.name)
- global_defaults = frappe.get_doc("Global Defaults")
- global_defaults.check_permission("write")
- global_defaults.on_update()
-
- # clear cache
- frappe.clear_cache()
-
- msgprint(
- _(
- "{0} is now the default Fiscal Year. Please refresh your browser for the change to take effect."
- ).format(self.name)
- )
-
def validate(self):
self.validate_dates()
self.validate_overlap()
@@ -68,13 +52,6 @@
frappe.cache().delete_value("fiscal_years")
def on_trash(self):
- global_defaults = frappe.get_doc("Global Defaults")
- if global_defaults.current_fiscal_year == self.name:
- frappe.throw(
- _(
- "You cannot delete Fiscal Year {0}. Fiscal Year {0} is set as default in Global Settings"
- ).format(self.name)
- )
frappe.cache().delete_value("fiscal_years")
def validate_overlap(self):
diff --git a/erpnext/accounts/doctype/item_tax_template/item_tax_template.json b/erpnext/accounts/doctype/item_tax_template/item_tax_template.json
index b42d712..87f0ad1 100644
--- a/erpnext/accounts/doctype/item_tax_template/item_tax_template.json
+++ b/erpnext/accounts/doctype/item_tax_template/item_tax_template.json
@@ -35,6 +35,7 @@
{
"fieldname": "company",
"fieldtype": "Link",
+ "in_filter": 1,
"in_list_view": 1,
"label": "Company",
"options": "Company",
@@ -56,7 +57,7 @@
}
],
"links": [],
- "modified": "2022-01-18 21:11:23.105589",
+ "modified": "2023-07-09 18:11:23.105589",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Item Tax Template",
@@ -102,4 +103,4 @@
"states": [],
"title_field": "title",
"track_changes": 1
-}
\ No newline at end of file
+}
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py
index 65ed466..dcd7295 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.py
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py
@@ -237,10 +237,9 @@
_("{0} {1} has already been fully paid.").format(_(d.reference_doctype), d.reference_name)
)
# The reference has already been partly paid
- elif (
- latest.outstanding_amount < latest.invoice_amount
- and flt(d.outstanding_amount, d.precision("outstanding_amount")) != latest.outstanding_amount
- ):
+ elif latest.outstanding_amount < latest.invoice_amount and flt(
+ d.outstanding_amount, d.precision("outstanding_amount")
+ ) != flt(latest.outstanding_amount, d.precision("outstanding_amount")):
frappe.throw(
_(
"{0} {1} has already been partly paid. Please use the 'Get Outstanding Invoice' or the 'Get Outstanding Orders' button to get the latest outstanding amounts."
@@ -1433,6 +1432,9 @@
if args.get("party_type") == "Member":
return
+ if not args.get("get_outstanding_invoices") and not args.get("get_orders_to_be_billed"):
+ args["get_outstanding_invoices"] = True
+
ple = qb.DocType("Payment Ledger Entry")
common_filter = []
accounting_dimensions_filter = []
@@ -1627,60 +1629,59 @@
cost_center=None,
filters=None,
):
+ voucher_type = None
if party_type == "Customer":
voucher_type = "Sales Order"
elif party_type == "Supplier":
voucher_type = "Purchase Order"
- elif party_type == "Employee":
- voucher_type = None
+
+ if not voucher_type:
+ return []
# Add cost center condition
- if voucher_type:
- doc = frappe.get_doc({"doctype": voucher_type})
- condition = ""
- if doc and hasattr(doc, "cost_center") and doc.cost_center:
- condition = " and cost_center='%s'" % cost_center
+ doc = frappe.get_doc({"doctype": voucher_type})
+ condition = ""
+ if doc and hasattr(doc, "cost_center") and doc.cost_center:
+ condition = " and cost_center='%s'" % cost_center
- orders = []
- if voucher_type:
- if party_account_currency == company_currency:
- grand_total_field = "base_grand_total"
- rounded_total_field = "base_rounded_total"
- else:
- grand_total_field = "grand_total"
- rounded_total_field = "rounded_total"
+ if party_account_currency == company_currency:
+ grand_total_field = "base_grand_total"
+ rounded_total_field = "base_rounded_total"
+ else:
+ grand_total_field = "grand_total"
+ rounded_total_field = "rounded_total"
- orders = frappe.db.sql(
- """
- select
- name as voucher_no,
- if({rounded_total_field}, {rounded_total_field}, {grand_total_field}) as invoice_amount,
- (if({rounded_total_field}, {rounded_total_field}, {grand_total_field}) - advance_paid) as outstanding_amount,
- transaction_date as posting_date
- from
- `tab{voucher_type}`
- where
- {party_type} = %s
- and docstatus = 1
- and company = %s
- and ifnull(status, "") != "Closed"
- and if({rounded_total_field}, {rounded_total_field}, {grand_total_field}) > advance_paid
- and abs(100 - per_billed) > 0.01
- {condition}
- order by
- transaction_date, name
- """.format(
- **{
- "rounded_total_field": rounded_total_field,
- "grand_total_field": grand_total_field,
- "voucher_type": voucher_type,
- "party_type": scrub(party_type),
- "condition": condition,
- }
- ),
- (party, company),
- as_dict=True,
- )
+ orders = frappe.db.sql(
+ """
+ select
+ name as voucher_no,
+ if({rounded_total_field}, {rounded_total_field}, {grand_total_field}) as invoice_amount,
+ (if({rounded_total_field}, {rounded_total_field}, {grand_total_field}) - advance_paid) as outstanding_amount,
+ transaction_date as posting_date
+ from
+ `tab{voucher_type}`
+ where
+ {party_type} = %s
+ and docstatus = 1
+ and company = %s
+ and ifnull(status, "") != "Closed"
+ and if({rounded_total_field}, {rounded_total_field}, {grand_total_field}) > advance_paid
+ and abs(100 - per_billed) > 0.01
+ {condition}
+ order by
+ transaction_date, name
+ """.format(
+ **{
+ "rounded_total_field": rounded_total_field,
+ "grand_total_field": grand_total_field,
+ "voucher_type": voucher_type,
+ "party_type": scrub(party_type),
+ "condition": condition,
+ }
+ ),
+ (party, company),
+ as_dict=True,
+ )
order_list = []
for d in orders:
@@ -1713,6 +1714,8 @@
cost_center=None,
condition=None,
):
+ if party_type not in ["Customer", "Supplier"]:
+ return []
voucher_type = "Sales Invoice" if party_type == "Customer" else "Purchase Invoice"
account = "debit_to" if voucher_type == "Sales Invoice" else "credit_to"
supplier_condition = ""
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
index e247e80..d8759e9 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
@@ -549,6 +549,7 @@
"depends_on": "update_stock",
"fieldname": "rejected_warehouse",
"fieldtype": "Link",
+ "ignore_user_permissions": 1,
"label": "Rejected Warehouse",
"no_copy": 1,
"options": "Warehouse",
@@ -1576,7 +1577,7 @@
"idx": 204,
"is_submittable": 1,
"links": [],
- "modified": "2023-06-03 16:21:54.637245",
+ "modified": "2023-07-04 17:22:59.145031",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Purchase Invoice",
diff --git a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json
index c5187a2..4afc451 100644
--- a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json
+++ b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json
@@ -423,6 +423,7 @@
{
"fieldname": "rejected_warehouse",
"fieldtype": "Link",
+ "ignore_user_permissions": 1,
"label": "Rejected Warehouse",
"options": "Warehouse"
},
@@ -904,7 +905,7 @@
"idx": 1,
"istable": 1,
"links": [],
- "modified": "2023-07-02 18:39:41.495723",
+ "modified": "2023-07-04 17:22:21.501152",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Purchase Invoice Item",
diff --git a/erpnext/accounts/doctype/shareholder/shareholder.js b/erpnext/accounts/doctype/shareholder/shareholder.js
index c6f101e..544d417 100644
--- a/erpnext/accounts/doctype/shareholder/shareholder.js
+++ b/erpnext/accounts/doctype/shareholder/shareholder.js
@@ -3,8 +3,6 @@
frappe.ui.form.on('Shareholder', {
refresh: function(frm) {
- frappe.dynamic_link = { doc: frm.doc, fieldname: 'name', doctype: 'Shareholder' };
-
frm.toggle_display(['contact_html'], !frm.doc.__islocal);
if (frm.doc.__islocal) {
diff --git a/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.js b/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.js
index dd965a9..d58fd95 100644
--- a/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.js
+++ b/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.js
@@ -49,7 +49,7 @@
"label": __("Start Year"),
"fieldtype": "Link",
"options": "Fiscal Year",
- "default": frappe.defaults.get_user_default("fiscal_year"),
+ "default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today()),
"reqd": 1,
on_change: () => {
frappe.model.with_doc("Fiscal Year", frappe.query_report.get_filter_value('from_fiscal_year'), function(r) {
@@ -65,7 +65,7 @@
"label": __("End Year"),
"fieldtype": "Link",
"options": "Fiscal Year",
- "default": frappe.defaults.get_user_default("fiscal_year"),
+ "default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today()),
"reqd": 1,
on_change: () => {
frappe.model.with_doc("Fiscal Year", frappe.query_report.get_filter_value('to_fiscal_year'), function(r) {
@@ -139,7 +139,7 @@
return value;
},
onload: function() {
- let fiscal_year = frappe.defaults.get_user_default("fiscal_year")
+ let fiscal_year = erpnext.utils.get_fiscal_year(frappe.datetime.get_today());
frappe.model.with_doc("Fiscal Year", fiscal_year, function(r) {
var fy = frappe.model.get_doc("Fiscal Year", fiscal_year);
diff --git a/erpnext/accounts/report/deferred_revenue_and_expense/deferred_revenue_and_expense.js b/erpnext/accounts/report/deferred_revenue_and_expense/deferred_revenue_and_expense.js
index 0056b9e..96e0c84 100644
--- a/erpnext/accounts/report/deferred_revenue_and_expense/deferred_revenue_and_expense.js
+++ b/erpnext/accounts/report/deferred_revenue_and_expense/deferred_revenue_and_expense.js
@@ -48,7 +48,7 @@
"label": __("Start Year"),
"fieldtype": "Link",
"options": "Fiscal Year",
- "default": frappe.defaults.get_user_default("fiscal_year"),
+ "default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today()),
"reqd": 1
},
{
@@ -56,7 +56,7 @@
"label": __("End Year"),
"fieldtype": "Link",
"options": "Fiscal Year",
- "default": frappe.defaults.get_user_default("fiscal_year"),
+ "default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today()),
"reqd": 1
},
{
@@ -100,7 +100,7 @@
return default_formatter(value, row, column, data);
},
onload: function(report){
- let fiscal_year = frappe.defaults.get_user_default("fiscal_year");
+ let fiscal_year = erpnext.utils.get_fiscal_year(frappe.datetime.get_today());
frappe.model.with_doc("Fiscal Year", fiscal_year, function(r) {
var fy = frappe.model.get_doc("Fiscal Year", fiscal_year);
diff --git a/erpnext/accounts/report/deferred_revenue_and_expense/deferred_revenue_and_expense.py b/erpnext/accounts/report/deferred_revenue_and_expense/deferred_revenue_and_expense.py
index 3e11643..cad5325 100644
--- a/erpnext/accounts/report/deferred_revenue_and_expense/deferred_revenue_and_expense.py
+++ b/erpnext/accounts/report/deferred_revenue_and_expense/deferred_revenue_and_expense.py
@@ -4,9 +4,10 @@
import frappe
from frappe import _, qb
from frappe.query_builder import Column, functions
-from frappe.utils import add_days, date_diff, flt, get_first_day, get_last_day, rounded
+from frappe.utils import add_days, date_diff, flt, get_first_day, get_last_day, getdate, rounded
from erpnext.accounts.report.financial_statements import get_period_list
+from erpnext.accounts.utils import get_fiscal_year
class Deferred_Item(object):
@@ -226,7 +227,7 @@
# If no filters are provided, get user defaults
if not filters:
- fiscal_year = frappe.get_doc("Fiscal Year", frappe.defaults.get_user_default("fiscal_year"))
+ fiscal_year = frappe.get_doc("Fiscal Year", get_fiscal_year(date=getdate()))
self.filters = frappe._dict(
{
"company": frappe.defaults.get_user_default("Company"),
diff --git a/erpnext/accounts/report/deferred_revenue_and_expense/test_deferred_revenue_and_expense.py b/erpnext/accounts/report/deferred_revenue_and_expense/test_deferred_revenue_and_expense.py
index 023ff22..c84b843 100644
--- a/erpnext/accounts/report/deferred_revenue_and_expense/test_deferred_revenue_and_expense.py
+++ b/erpnext/accounts/report/deferred_revenue_and_expense/test_deferred_revenue_and_expense.py
@@ -10,6 +10,7 @@
from erpnext.accounts.report.deferred_revenue_and_expense.deferred_revenue_and_expense import (
Deferred_Revenue_and_Expense_Report,
)
+from erpnext.accounts.utils import get_fiscal_year
from erpnext.buying.doctype.supplier.test_supplier import create_supplier
from erpnext.stock.doctype.item.test_item import create_item
@@ -116,7 +117,7 @@
pda.submit()
# execute report
- fiscal_year = frappe.get_doc("Fiscal Year", frappe.defaults.get_user_default("fiscal_year"))
+ fiscal_year = frappe.get_doc("Fiscal Year", get_fiscal_year(date="2021-05-01"))
self.filters = frappe._dict(
{
"company": frappe.defaults.get_user_default("Company"),
@@ -209,7 +210,7 @@
pda.submit()
# execute report
- fiscal_year = frappe.get_doc("Fiscal Year", frappe.defaults.get_user_default("fiscal_year"))
+ fiscal_year = frappe.get_doc("Fiscal Year", get_fiscal_year(date="2021-05-01"))
self.filters = frappe._dict(
{
"company": frappe.defaults.get_user_default("Company"),
@@ -297,7 +298,7 @@
pda.submit()
# execute report
- fiscal_year = frappe.get_doc("Fiscal Year", frappe.defaults.get_user_default("fiscal_year"))
+ fiscal_year = frappe.get_doc("Fiscal Year", get_fiscal_year(date="2021-05-01"))
self.filters = frappe._dict(
{
"company": frappe.defaults.get_user_default("Company"),
diff --git a/erpnext/accounts/report/dimension_wise_accounts_balance_report/dimension_wise_accounts_balance_report.js b/erpnext/accounts/report/dimension_wise_accounts_balance_report/dimension_wise_accounts_balance_report.js
index ea05a35..9d416db 100644
--- a/erpnext/accounts/report/dimension_wise_accounts_balance_report/dimension_wise_accounts_balance_report.js
+++ b/erpnext/accounts/report/dimension_wise_accounts_balance_report/dimension_wise_accounts_balance_report.js
@@ -18,7 +18,7 @@
"label": __("Fiscal Year"),
"fieldtype": "Link",
"options": "Fiscal Year",
- "default": frappe.defaults.get_user_default("fiscal_year"),
+ "default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today()),
"reqd": 1,
"on_change": function(query_report) {
var fiscal_year = query_report.get_values().fiscal_year;
diff --git a/erpnext/accounts/report/financial_statements.py b/erpnext/accounts/report/financial_statements.py
index f3a892b..db9609d 100644
--- a/erpnext/accounts/report/financial_statements.py
+++ b/erpnext/accounts/report/financial_statements.py
@@ -416,6 +416,7 @@
filters,
gl_entries_by_account,
ignore_closing_entries=False,
+ ignore_opening_entries=False,
):
"""Returns a dict like { "account": [gl entries], ... }"""
gl_entries = []
@@ -426,7 +427,6 @@
pluck="name",
)
- ignore_opening_entries = False
if accounts_list:
# For balance sheet
if not from_date:
diff --git a/erpnext/accounts/report/gross_and_net_profit_report/gross_and_net_profit_report.js b/erpnext/accounts/report/gross_and_net_profit_report/gross_and_net_profit_report.js
index 8dc5ab3..92cf36e 100644
--- a/erpnext/accounts/report/gross_and_net_profit_report/gross_and_net_profit_report.js
+++ b/erpnext/accounts/report/gross_and_net_profit_report/gross_and_net_profit_report.js
@@ -13,14 +13,6 @@
frappe.query_reports["Gross and Net Profit Report"]["filters"].push(
{
- "fieldname": "project",
- "label": __("Project"),
- "fieldtype": "MultiSelectList",
- get_data: function(txt) {
- return frappe.db.get_link_options('Project', txt);
- }
- },
- {
"fieldname": "accumulated_values",
"label": __("Accumulated Values"),
"fieldtype": "Check"
diff --git a/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.js b/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.js
index 298d838..e794f27 100644
--- a/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.js
+++ b/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.js
@@ -10,16 +10,6 @@
frappe.query_reports["Profit and Loss Statement"]["filters"].push(
{
- "fieldname": "project",
- "label": __("Project"),
- "fieldtype": "MultiSelectList",
- get_data: function(txt) {
- return frappe.db.get_link_options('Project', txt, {
- company: frappe.query_report.get_filter_value("company")
- });
- },
- },
- {
"fieldname": "include_default_book_entries",
"label": __("Include Default Book Entries"),
"fieldtype": "Check",
diff --git a/erpnext/accounts/report/profitability_analysis/profitability_analysis.js b/erpnext/accounts/report/profitability_analysis/profitability_analysis.js
index 889ede5..6caebd3 100644
--- a/erpnext/accounts/report/profitability_analysis/profitability_analysis.js
+++ b/erpnext/accounts/report/profitability_analysis/profitability_analysis.js
@@ -25,7 +25,7 @@
"label": __("Fiscal Year"),
"fieldtype": "Link",
"options": "Fiscal Year",
- "default": frappe.defaults.get_user_default("fiscal_year"),
+ "default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today()),
"reqd": 1,
"on_change": function(query_report) {
var fiscal_year = query_report.get_values().fiscal_year;
diff --git a/erpnext/accounts/report/trial_balance/trial_balance.js b/erpnext/accounts/report/trial_balance/trial_balance.js
index 078b065..e45c3ad 100644
--- a/erpnext/accounts/report/trial_balance/trial_balance.js
+++ b/erpnext/accounts/report/trial_balance/trial_balance.js
@@ -17,7 +17,7 @@
"label": __("Fiscal Year"),
"fieldtype": "Link",
"options": "Fiscal Year",
- "default": frappe.defaults.get_user_default("fiscal_year"),
+ "default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today()),
"reqd": 1,
"on_change": function(query_report) {
var fiscal_year = query_report.get_values().fiscal_year;
diff --git a/erpnext/accounts/report/trial_balance/trial_balance.py b/erpnext/accounts/report/trial_balance/trial_balance.py
index d51c4c4..5176c31 100644
--- a/erpnext/accounts/report/trial_balance/trial_balance.py
+++ b/erpnext/accounts/report/trial_balance/trial_balance.py
@@ -117,6 +117,7 @@
filters,
gl_entries_by_account,
ignore_closing_entries=not flt(filters.with_period_closing_entry),
+ ignore_opening_entries=True,
)
calculate_values(accounts, gl_entries_by_account, opening_balances)
@@ -159,6 +160,8 @@
accounting_dimensions,
period_closing_voucher=last_period_closing_voucher[0].name,
)
+
+ # Report getting generate from the mid of a fiscal year
if getdate(last_period_closing_voucher[0].posting_date) < getdate(
add_days(filters.from_date, -1)
):
@@ -220,7 +223,10 @@
if start_date:
opening_balance = opening_balance.where(closing_balance.posting_date >= start_date)
opening_balance = opening_balance.where(closing_balance.is_opening == "No")
- opening_balance = opening_balance.where(closing_balance.posting_date < filters.from_date)
+ else:
+ opening_balance = opening_balance.where(
+ (closing_balance.posting_date < filters.from_date) | (closing_balance.is_opening == "Yes")
+ )
if (
not filters.show_unclosed_fy_pl_balances
diff --git a/erpnext/accounts/report/trial_balance_for_party/trial_balance_for_party.js b/erpnext/accounts/report/trial_balance_for_party/trial_balance_for_party.js
index 0e93035..0f7578c 100644
--- a/erpnext/accounts/report/trial_balance_for_party/trial_balance_for_party.js
+++ b/erpnext/accounts/report/trial_balance_for_party/trial_balance_for_party.js
@@ -16,7 +16,7 @@
"label": __("Fiscal Year"),
"fieldtype": "Link",
"options": "Fiscal Year",
- "default": frappe.defaults.get_user_default("fiscal_year"),
+ "default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today()),
"reqd": 1,
"on_change": function(query_report) {
var fiscal_year = query_report.get_values().fiscal_year;
diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py
index 31473db..4b54483 100644
--- a/erpnext/accounts/utils.py
+++ b/erpnext/accounts/utils.py
@@ -850,7 +850,7 @@
if party_type == "Supplier":
held_invoices = frappe.db.sql(
- "select name from `tabPurchase Invoice` where release_date IS NOT NULL and release_date > CURDATE()",
+ "select name from `tabPurchase Invoice` where on_hold = 1 and release_date IS NOT NULL and release_date > CURDATE()",
as_dict=1,
)
held_invoices = set(d["name"] for d in held_invoices)
@@ -1110,6 +1110,11 @@
return " - ".join(parts)
+def parse_naming_series_variable(doc, variable):
+ if variable == "FY":
+ return get_fiscal_year(date=doc.get("posting_date"), company=doc.get("company"))[0]
+
+
@frappe.whitelist()
def get_coa(doctype, parent, is_root, chart=None):
from erpnext.accounts.doctype.account.chart_of_accounts.chart_of_accounts import (
diff --git a/erpnext/assets/doctype/asset/depreciation.py b/erpnext/assets/doctype/asset/depreciation.py
index 259568a..e1431ea 100644
--- a/erpnext/assets/doctype/asset/depreciation.py
+++ b/erpnext/assets/doctype/asset/depreciation.py
@@ -40,6 +40,7 @@
date = today()
failed_asset_names = []
+ error_log_names = []
for asset_name in get_depreciable_assets(date):
asset_doc = frappe.get_doc("Asset", asset_name)
@@ -50,10 +51,12 @@
except Exception as e:
frappe.db.rollback()
failed_asset_names.append(asset_name)
+ error_log = frappe.log_error(e)
+ error_log_names.append(error_log.name)
if failed_asset_names:
set_depr_entry_posting_status_for_failed_assets(failed_asset_names)
- notify_depr_entry_posting_error(failed_asset_names)
+ notify_depr_entry_posting_error(failed_asset_names, error_log_names)
frappe.db.commit()
@@ -239,7 +242,7 @@
frappe.db.set_value("Asset", asset_name, "depr_entry_posting_status", "Failed")
-def notify_depr_entry_posting_error(failed_asset_names):
+def notify_depr_entry_posting_error(failed_asset_names, error_log_names):
recipients = get_users_with_role("Accounts Manager")
if not recipients:
@@ -247,7 +250,8 @@
subject = _("Error while posting depreciation entries")
- asset_links = get_comma_separated_asset_links(failed_asset_names)
+ asset_links = get_comma_separated_links(failed_asset_names, "Asset")
+ error_log_links = get_comma_separated_links(error_log_names, "Error Log")
message = (
_("Hello,")
@@ -257,23 +261,26 @@
)
+ "."
+ "<br><br>"
- + _(
- "Please raise a support ticket and share this email, or forward this email to your development team so that they can find the issue in the developer console by manually creating the depreciation entry via the asset's depreciation schedule table."
+ + _("Here are the error logs for the aforementioned failed depreciation entries: {0}").format(
+ error_log_links
)
+ + "."
+ + "<br><br>"
+ + _("Please share this email with your support team so that they can find and fix the issue.")
)
frappe.sendmail(recipients=recipients, subject=subject, message=message)
-def get_comma_separated_asset_links(asset_names):
- asset_links = []
+def get_comma_separated_links(names, doctype):
+ links = []
- for asset_name in asset_names:
- asset_links.append(get_link_to_form("Asset", asset_name))
+ for name in names:
+ links.append(get_link_to_form(doctype, name))
- asset_links = ", ".join(asset_links)
+ links = ", ".join(links)
- return asset_links
+ return links
@frappe.whitelist()
diff --git a/erpnext/assets/doctype/asset_movement/asset_movement.js b/erpnext/assets/doctype/asset_movement/asset_movement.js
index f9c6007..4ccc3f8 100644
--- a/erpnext/assets/doctype/asset_movement/asset_movement.js
+++ b/erpnext/assets/doctype/asset_movement/asset_movement.js
@@ -63,7 +63,7 @@
fieldnames_to_be_altered = {
target_location: { read_only: 0, reqd: 1 },
source_location: { read_only: 1, reqd: 0 },
- from_employee: { read_only: 0, reqd: 1 },
+ from_employee: { read_only: 0, reqd: 0 },
to_employee: { read_only: 1, reqd: 0 }
};
}
diff --git a/erpnext/assets/doctype/asset_movement/asset_movement.py b/erpnext/assets/doctype/asset_movement/asset_movement.py
index b58ca10..22055dc 100644
--- a/erpnext/assets/doctype/asset_movement/asset_movement.py
+++ b/erpnext/assets/doctype/asset_movement/asset_movement.py
@@ -62,29 +62,20 @@
frappe.throw(_("Source and Target Location cannot be same"))
if self.purpose == "Receipt":
- # only when asset is bought and first entry is made
- if not d.source_location and not (d.target_location or d.to_employee):
+ if not (d.source_location or d.from_employee) and not (d.target_location or d.to_employee):
frappe.throw(
_("Target Location or To Employee is required while receiving Asset {0}").format(d.asset)
)
- elif d.source_location:
- # when asset is received from an employee
- if d.target_location and not d.from_employee:
- frappe.throw(
- _("From employee is required while receiving Asset {0} to a target location").format(
- d.asset
- )
- )
- if d.from_employee and not d.target_location:
- frappe.throw(
- _("Target Location is required while receiving Asset {0} from an employee").format(d.asset)
- )
- if d.to_employee and d.target_location:
- frappe.throw(
- _(
- "Asset {0} cannot be received at a location and given to employee in a single movement"
- ).format(d.asset)
- )
+ elif d.from_employee and not d.target_location:
+ frappe.throw(
+ _("Target Location is required while receiving Asset {0} from an employee").format(d.asset)
+ )
+ elif d.to_employee and d.target_location:
+ frappe.throw(
+ _(
+ "Asset {0} cannot be received at a location and given to an employee in a single movement"
+ ).format(d.asset)
+ )
def validate_employee(self):
for d in self.assets:
diff --git a/erpnext/assets/report/fixed_asset_register/fixed_asset_register.js b/erpnext/assets/report/fixed_asset_register/fixed_asset_register.js
index b788a32..48b17f5 100644
--- a/erpnext/assets/report/fixed_asset_register/fixed_asset_register.js
+++ b/erpnext/assets/report/fixed_asset_register/fixed_asset_register.js
@@ -82,7 +82,7 @@
"label": __("Start Year"),
"fieldtype": "Link",
"options": "Fiscal Year",
- "default": frappe.defaults.get_user_default("fiscal_year"),
+ "default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today()),
"depends_on": "eval: doc.filter_based_on == 'Fiscal Year'",
},
{
@@ -90,7 +90,7 @@
"label": __("End Year"),
"fieldtype": "Link",
"options": "Fiscal Year",
- "default": frappe.defaults.get_user_default("fiscal_year"),
+ "default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today()),
"depends_on": "eval: doc.filter_based_on == 'Fiscal Year'",
},
{
diff --git a/erpnext/buying/doctype/supplier/supplier.js b/erpnext/buying/doctype/supplier/supplier.js
index 5b95d0f..372ca56 100644
--- a/erpnext/buying/doctype/supplier/supplier.js
+++ b/erpnext/buying/doctype/supplier/supplier.js
@@ -66,8 +66,6 @@
},
refresh: function (frm) {
- frappe.dynamic_link = { doc: frm.doc, fieldname: 'name', doctype: 'Supplier' }
-
if (frappe.defaults.get_default("supp_master_name") != "Naming Series") {
frm.toggle_display("naming_series", false);
} else {
diff --git a/erpnext/communication/doctype/communication_medium/communication_medium.json b/erpnext/communication/doctype/communication_medium/communication_medium.json
index 1e1fe3b..b6b9c7e 100644
--- a/erpnext/communication/doctype/communication_medium/communication_medium.json
+++ b/erpnext/communication/doctype/communication_medium/communication_medium.json
@@ -61,7 +61,7 @@
"fieldname": "communication_channel",
"fieldtype": "Select",
"label": "Communication Channel",
- "options": "\nExotel"
+ "options": ""
}
],
"links": [],
diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py
index fec494a..7b7c53e 100644
--- a/erpnext/controllers/buying_controller.py
+++ b/erpnext/controllers/buying_controller.py
@@ -437,18 +437,23 @@
# validate rate with ref PR
def validate_rejected_warehouse(self):
- for d in self.get("items"):
- if flt(d.rejected_qty) and not d.rejected_warehouse:
+ for item in self.get("items"):
+ if flt(item.rejected_qty) and not item.rejected_warehouse:
if self.rejected_warehouse:
- d.rejected_warehouse = self.rejected_warehouse
+ item.rejected_warehouse = self.rejected_warehouse
- if not d.rejected_warehouse:
+ if not item.rejected_warehouse:
frappe.throw(
- _("Row #{0}: Rejected Warehouse is mandatory against rejected Item {1}").format(
- d.idx, d.item_code
+ _("Row #{0}: Rejected Warehouse is mandatory for the rejected Item {1}").format(
+ item.idx, item.item_code
)
)
+ if item.get("rejected_warehouse") and (item.get("rejected_warehouse") == item.get("warehouse")):
+ frappe.throw(
+ _("Row #{0}: Accepted Warehouse and Rejected Warehouse cannot be same").format(item.idx)
+ )
+
# validate accepted and rejected qty
def validate_accepted_rejected_qty(self):
for d in self.get("items"):
diff --git a/erpnext/controllers/sales_and_purchase_return.py b/erpnext/controllers/sales_and_purchase_return.py
index 9546680..173e812 100644
--- a/erpnext/controllers/sales_and_purchase_return.py
+++ b/erpnext/controllers/sales_and_purchase_return.py
@@ -669,7 +669,11 @@
if reference_voucher_detail_no:
filters["voucher_detail_no"] = reference_voucher_detail_no
- if item_row and item_row.get("warehouse"):
+ if (
+ voucher_type in ["Purchase Receipt", "Purchase Invoice"]
+ and item_row
+ and item_row.get("warehouse")
+ ):
filters["warehouse"] = item_row.get("warehouse")
return filters
diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py
index 5137e03..caf4b6f 100644
--- a/erpnext/controllers/stock_controller.py
+++ b/erpnext/controllers/stock_controller.py
@@ -201,6 +201,12 @@
warehouse_asset_account = warehouse_account[item_row.get("warehouse")]["account"]
expense_account = frappe.get_cached_value("Company", self.company, "default_expense_account")
+ if not expense_account:
+ frappe.throw(
+ _(
+ "Please set default cost of goods sold account in company {0} for booking rounding gain and loss during stock transfer"
+ ).format(frappe.bold(self.company))
+ )
gl_list.append(
self.get_gl_dict(
diff --git a/erpnext/crm/doctype/lead/lead.js b/erpnext/crm/doctype/lead/lead.js
index b98a27e..9ac5418 100644
--- a/erpnext/crm/doctype/lead/lead.js
+++ b/erpnext/crm/doctype/lead/lead.js
@@ -30,11 +30,6 @@
var me = this;
let doc = this.frm.doc;
erpnext.toggle_naming_series();
- frappe.dynamic_link = {
- doc: doc,
- fieldname: 'name',
- doctype: 'Lead'
- };
if (!this.frm.is_new() && doc.__onload && !doc.__onload.is_customer) {
this.frm.add_custom_button(__("Customer"), this.make_customer, __("Create"));
diff --git a/erpnext/crm/doctype/prospect/prospect.js b/erpnext/crm/doctype/prospect/prospect.js
index 495ed29..c1a7ff5 100644
--- a/erpnext/crm/doctype/prospect/prospect.js
+++ b/erpnext/crm/doctype/prospect/prospect.js
@@ -3,8 +3,6 @@
frappe.ui.form.on('Prospect', {
refresh (frm) {
- frappe.dynamic_link = { doc: frm.doc, fieldname: "name", doctype: frm.doctype };
-
if (!frm.is_new() && frappe.boot.user.can_create.includes("Customer")) {
frm.add_custom_button(__("Customer"), function() {
frappe.model.open_mapped_doc({
diff --git a/erpnext/erpnext_integrations/doctype/exotel_settings/__init__.py b/erpnext/erpnext_integrations/doctype/exotel_settings/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/erpnext/erpnext_integrations/doctype/exotel_settings/__init__.py
+++ /dev/null
diff --git a/erpnext/erpnext_integrations/doctype/exotel_settings/exotel_settings.json b/erpnext/erpnext_integrations/doctype/exotel_settings/exotel_settings.json
deleted file mode 100644
index 0d42ca8..0000000
--- a/erpnext/erpnext_integrations/doctype/exotel_settings/exotel_settings.json
+++ /dev/null
@@ -1,89 +0,0 @@
-{
- "actions": [],
- "creation": "2019-05-21 07:41:53.536536",
- "doctype": "DocType",
- "engine": "InnoDB",
- "field_order": [
- "enabled",
- "section_break_2",
- "account_sid",
- "api_key",
- "api_token",
- "section_break_6",
- "map_custom_field_to_doctype",
- "target_doctype"
- ],
- "fields": [
- {
- "default": "0",
- "fieldname": "enabled",
- "fieldtype": "Check",
- "label": "Enabled"
- },
- {
- "depends_on": "enabled",
- "fieldname": "section_break_2",
- "fieldtype": "Section Break",
- "label": "Credentials"
- },
- {
- "fieldname": "account_sid",
- "fieldtype": "Data",
- "label": "Account SID"
- },
- {
- "fieldname": "api_token",
- "fieldtype": "Data",
- "label": "API Token"
- },
- {
- "fieldname": "api_key",
- "fieldtype": "Data",
- "label": "API Key"
- },
- {
- "depends_on": "enabled",
- "fieldname": "section_break_6",
- "fieldtype": "Section Break",
- "label": "Custom Field"
- },
- {
- "default": "0",
- "fieldname": "map_custom_field_to_doctype",
- "fieldtype": "Check",
- "label": "Map Custom Field to DocType"
- },
- {
- "depends_on": "map_custom_field_to_doctype",
- "fieldname": "target_doctype",
- "fieldtype": "Link",
- "label": "Target DocType",
- "mandatory_depends_on": "map_custom_field_to_doctype",
- "options": "DocType"
- }
- ],
- "issingle": 1,
- "links": [],
- "modified": "2022-12-14 17:24:50.176107",
- "modified_by": "Administrator",
- "module": "ERPNext Integrations",
- "name": "Exotel Settings",
- "owner": "Administrator",
- "permissions": [
- {
- "create": 1,
- "delete": 1,
- "email": 1,
- "print": 1,
- "read": 1,
- "role": "System Manager",
- "share": 1,
- "write": 1
- }
- ],
- "quick_entry": 1,
- "sort_field": "modified",
- "sort_order": "ASC",
- "states": [],
- "track_changes": 1
-}
\ No newline at end of file
diff --git a/erpnext/erpnext_integrations/doctype/exotel_settings/exotel_settings.py b/erpnext/erpnext_integrations/doctype/exotel_settings/exotel_settings.py
deleted file mode 100644
index 4879cb5..0000000
--- a/erpnext/erpnext_integrations/doctype/exotel_settings/exotel_settings.py
+++ /dev/null
@@ -1,22 +0,0 @@
-# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors
-# For license information, please see license.txt
-
-
-import frappe
-import requests
-from frappe import _
-from frappe.model.document import Document
-
-
-class ExotelSettings(Document):
- def validate(self):
- self.verify_credentials()
-
- def verify_credentials(self):
- if self.enabled:
- response = requests.get(
- "https://api.exotel.com/v1/Accounts/{sid}".format(sid=self.account_sid),
- auth=(self.api_key, self.api_token),
- )
- if response.status_code != 200:
- frappe.throw(_("Invalid credentials"))
diff --git a/erpnext/erpnext_integrations/exotel_integration.py b/erpnext/erpnext_integrations/exotel_integration.py
deleted file mode 100644
index 0d40667..0000000
--- a/erpnext/erpnext_integrations/exotel_integration.py
+++ /dev/null
@@ -1,151 +0,0 @@
-import frappe
-import requests
-
-# api/method/erpnext.erpnext_integrations.exotel_integration.handle_incoming_call
-# api/method/erpnext.erpnext_integrations.exotel_integration.handle_end_call
-# api/method/erpnext.erpnext_integrations.exotel_integration.handle_missed_call
-
-
-@frappe.whitelist(allow_guest=True)
-def handle_incoming_call(**kwargs):
- try:
- exotel_settings = get_exotel_settings()
- if not exotel_settings.enabled:
- return
-
- call_payload = kwargs
- status = call_payload.get("Status")
- if status == "free":
- return
-
- call_log = get_call_log(call_payload)
- if not call_log:
- create_call_log(call_payload)
- else:
- update_call_log(call_payload, call_log=call_log)
- except Exception as e:
- frappe.db.rollback()
- exotel_settings.log_error("Error in Exotel incoming call")
- frappe.db.commit()
-
-
-@frappe.whitelist(allow_guest=True)
-def handle_end_call(**kwargs):
- update_call_log(kwargs, "Completed")
-
-
-@frappe.whitelist(allow_guest=True)
-def handle_missed_call(**kwargs):
- status = ""
- call_type = kwargs.get("CallType")
- dial_call_status = kwargs.get("DialCallStatus")
-
- if call_type == "incomplete" and dial_call_status == "no-answer":
- status = "No Answer"
- elif call_type == "client-hangup" and dial_call_status == "canceled":
- status = "Canceled"
- elif call_type == "incomplete" and dial_call_status == "failed":
- status = "Failed"
-
- update_call_log(kwargs, status)
-
-
-def update_call_log(call_payload, status="Ringing", call_log=None):
- call_log = call_log or get_call_log(call_payload)
-
- # for a new sid, call_log and get_call_log will be empty so create a new log
- if not call_log:
- call_log = create_call_log(call_payload)
- if call_log:
- call_log.status = status
- call_log.to = call_payload.get("DialWhomNumber")
- call_log.duration = call_payload.get("DialCallDuration") or 0
- call_log.recording_url = call_payload.get("RecordingUrl")
- call_log.save(ignore_permissions=True)
- frappe.db.commit()
- return call_log
-
-
-def get_call_log(call_payload):
- call_log_id = call_payload.get("CallSid")
- if frappe.db.exists("Call Log", call_log_id):
- return frappe.get_doc("Call Log", call_log_id)
-
-
-def map_custom_field(call_payload, call_log):
- field_value = call_payload.get("CustomField")
-
- if not field_value:
- return call_log
-
- settings = get_exotel_settings()
- target_doctype = settings.target_doctype
- mapping_enabled = settings.map_custom_field_to_doctype
-
- if not mapping_enabled or not target_doctype:
- return call_log
-
- call_log.append("links", {"link_doctype": target_doctype, "link_name": field_value})
-
- return call_log
-
-
-def create_call_log(call_payload):
- call_log = frappe.new_doc("Call Log")
- call_log.id = call_payload.get("CallSid")
- call_log.to = call_payload.get("DialWhomNumber")
- call_log.medium = call_payload.get("To")
- call_log.status = "Ringing"
- setattr(call_log, "from", call_payload.get("CallFrom"))
- map_custom_field(call_payload, call_log)
- call_log.save(ignore_permissions=True)
- frappe.db.commit()
- return call_log
-
-
-@frappe.whitelist()
-def get_call_status(call_id):
- endpoint = get_exotel_endpoint("Calls/{call_id}.json".format(call_id=call_id))
- response = requests.get(endpoint)
- status = response.json().get("Call", {}).get("Status")
- return status
-
-
-@frappe.whitelist()
-def make_a_call(from_number, to_number, caller_id, **kwargs):
- endpoint = get_exotel_endpoint("Calls/connect.json?details=true")
- response = requests.post(
- endpoint, data={"From": from_number, "To": to_number, "CallerId": caller_id, **kwargs}
- )
-
- return response.json()
-
-
-def get_exotel_settings():
- return frappe.get_single("Exotel Settings")
-
-
-def whitelist_numbers(numbers, caller_id):
- endpoint = get_exotel_endpoint("CustomerWhitelist")
- response = requests.post(
- endpoint,
- data={
- "VirtualNumber": caller_id,
- "Number": numbers,
- },
- )
-
- return response
-
-
-def get_all_exophones():
- endpoint = get_exotel_endpoint("IncomingPhoneNumbers")
- response = requests.post(endpoint)
- return response
-
-
-def get_exotel_endpoint(action):
- settings = get_exotel_settings()
- return "https://{api_key}:{api_token}@api.exotel.com/v1/Accounts/{sid}/{action}".format(
- api_key=settings.api_key, api_token=settings.api_token, sid=settings.account_sid, action=action
- )
diff --git a/erpnext/erpnext_integrations/workspace/erpnext_integrations/erpnext_integrations.json b/erpnext/erpnext_integrations/workspace/erpnext_integrations/erpnext_integrations.json
index ccc46b7..5c4be6f 100644
--- a/erpnext/erpnext_integrations/workspace/erpnext_integrations/erpnext_integrations.json
+++ b/erpnext/erpnext_integrations/workspace/erpnext_integrations/erpnext_integrations.json
@@ -231,17 +231,6 @@
"type": "Card Break"
},
{
- "dependencies": "",
- "hidden": 0,
- "is_query_report": 0,
- "label": "Exotel Settings",
- "link_count": 0,
- "link_to": "Exotel Settings",
- "link_type": "DocType",
- "onboard": 0,
- "type": "Link"
- },
- {
"hidden": 0,
"is_query_report": 0,
"label": "Woocommerce Settings",
@@ -252,7 +241,7 @@
"type": "Link"
}
],
- "modified": "2023-05-24 14:47:25.984717",
+ "modified": "2023-05-24 14:47:26.984717",
"modified_by": "Administrator",
"module": "ERPNext Integrations",
"name": "ERPNext Integrations",
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index d02d318..66f3de4 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -354,6 +354,11 @@
},
}
+# function should expect the variable and doc as arguments
+naming_series_variables = {
+ "FY": "erpnext.accounts.utils.parse_naming_series_variable",
+}
+
# On cancel event Payment Entry will be exempted and all linked submittable doctype will get cancelled.
# to maintain data integrity we exempted payment entry. it will un-link when sales invoice get cancelled.
# if payment entry not in auto cancel exempted doctypes it will cancel payment entry.
@@ -611,3 +616,8 @@
additional_timeline_content = {
"*": ["erpnext.telephony.doctype.call_log.call_log.get_linked_call_logs"]
}
+
+
+extend_bootinfo = [
+ "erpnext.support.doctype.service_level_agreement.service_level_agreement.add_sla_doctypes",
+]
diff --git a/erpnext/manufacturing/doctype/production_plan/production_plan.py b/erpnext/manufacturing/doctype/production_plan/production_plan.py
index 6dc1ff6..a988bad 100644
--- a/erpnext/manufacturing/doctype/production_plan/production_plan.py
+++ b/erpnext/manufacturing/doctype/production_plan/production_plan.py
@@ -621,7 +621,7 @@
def create_work_order(self, item):
from erpnext.manufacturing.doctype.work_order.work_order import OverProductionError
- if item.get("qty") <= 0:
+ if flt(item.get("qty")) <= 0:
return
wo = frappe.new_doc("Work Order")
@@ -697,10 +697,9 @@
material_request.flags.ignore_permissions = 1
material_request.run_method("set_missing_values")
+ material_request.save()
if self.get("submit_material_request"):
material_request.submit()
- else:
- material_request.save()
frappe.flags.mute_messages = False
diff --git a/erpnext/manufacturing/doctype/work_order/work_order.py b/erpnext/manufacturing/doctype/work_order/work_order.py
index 79b1e79..7c15bf9 100644
--- a/erpnext/manufacturing/doctype/work_order/work_order.py
+++ b/erpnext/manufacturing/doctype/work_order/work_order.py
@@ -1026,7 +1026,7 @@
consumed_qty = frappe.db.sql(
"""
SELECT
- SUM(qty)
+ SUM(detail.qty)
FROM
`tabStock Entry` entry,
`tabStock Entry Detail` detail
diff --git a/erpnext/manufacturing/report/job_card_summary/job_card_summary.js b/erpnext/manufacturing/report/job_card_summary/job_card_summary.js
index 782ce81..a874f22 100644
--- a/erpnext/manufacturing/report/job_card_summary/job_card_summary.js
+++ b/erpnext/manufacturing/report/job_card_summary/job_card_summary.js
@@ -17,7 +17,7 @@
label: __("Fiscal Year"),
fieldtype: "Link",
options: "Fiscal Year",
- default: frappe.defaults.get_user_default("fiscal_year"),
+ default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today()),
reqd: 1,
on_change: function(query_report) {
var fiscal_year = query_report.get_values().fiscal_year;
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index b3b9bc6..73e0a95 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -317,7 +317,7 @@
erpnext.patches.v15_0.update_asset_value_for_manual_depr_entries
erpnext.patches.v15_0.update_gpa_and_ndb_for_assdeprsch
erpnext.patches.v14_0.create_accounting_dimensions_for_closing_balance
-erpnext.patches.v14_0.update_closing_balances #17-05-2023
+erpnext.patches.v14_0.update_closing_balances #14-07-2023
execute:frappe.db.set_single_value("Accounts Settings", "merge_similar_account_heads", 0)
# below migration patches should always run last
erpnext.patches.v14_0.migrate_gl_to_payment_ledger
@@ -333,4 +333,6 @@
erpnext.patches.v14_0.cleanup_workspaces
erpnext.patches.v15_0.remove_loan_management_module #2023-07-03
erpnext.patches.v14_0.set_report_in_process_SOA
-erpnext.buying.doctype.supplier.patches.migrate_supplier_portal_users
\ No newline at end of file
+erpnext.buying.doctype.supplier.patches.migrate_supplier_portal_users
+execute:frappe.defaults.clear_default("fiscal_year")
+erpnext.patches.v15_0.remove_exotel_integration
diff --git a/erpnext/patches/v14_0/update_closing_balances.py b/erpnext/patches/v14_0/update_closing_balances.py
index d664677..2947b98 100644
--- a/erpnext/patches/v14_0/update_closing_balances.py
+++ b/erpnext/patches/v14_0/update_closing_balances.py
@@ -13,56 +13,63 @@
def execute():
frappe.db.truncate("Account Closing Balance")
- i = 0
- company_wise_order = {}
- for pcv in frappe.db.get_all(
- "Period Closing Voucher",
- fields=["company", "posting_date", "name"],
- filters={"docstatus": 1},
- order_by="posting_date",
- ):
+ for company in frappe.get_all("Company", pluck="name"):
+ i = 0
+ company_wise_order = {}
+ for pcv in frappe.db.get_all(
+ "Period Closing Voucher",
+ fields=["company", "posting_date", "name"],
+ filters={"docstatus": 1, "company": company},
+ order_by="posting_date",
+ ):
- company_wise_order.setdefault(pcv.company, [])
- if pcv.posting_date not in company_wise_order[pcv.company]:
- pcv_doc = frappe.get_doc("Period Closing Voucher", pcv.name)
- pcv_doc.year_start_date = get_fiscal_year(
- pcv.posting_date, pcv.fiscal_year, company=pcv.company
- )[1]
+ company_wise_order.setdefault(pcv.company, [])
+ if pcv.posting_date not in company_wise_order[pcv.company]:
+ pcv_doc = frappe.get_doc("Period Closing Voucher", pcv.name)
+ pcv_doc.year_start_date = get_fiscal_year(
+ pcv.posting_date, pcv.fiscal_year, company=pcv.company
+ )[1]
- # get gl entries against pcv
- gl_entries = frappe.db.get_all(
- "GL Entry", filters={"voucher_no": pcv.name, "is_cancelled": 0}, fields=["*"]
- )
- for entry in gl_entries:
- entry["is_period_closing_voucher_entry"] = 1
- entry["closing_date"] = pcv_doc.posting_date
- entry["period_closing_voucher"] = pcv_doc.name
-
- # get all gl entries for the year
- closing_entries = frappe.db.get_all(
- "GL Entry",
- filters={
- "is_cancelled": 0,
- "voucher_no": ["!=", pcv.name],
- "posting_date": ["between", [pcv_doc.year_start_date, pcv.posting_date]],
- "is_opening": "No",
- },
- fields=["*"],
- )
-
- if i == 0:
- # add opening entries only for the first pcv
- closing_entries += frappe.db.get_all(
- "GL Entry",
- filters={"is_cancelled": 0, "is_opening": "Yes"},
- fields=["*"],
+ # get gl entries against pcv
+ gl_entries = frappe.db.get_all(
+ "GL Entry", filters={"voucher_no": pcv.name, "is_cancelled": 0}, fields=["*"]
)
+ for entry in gl_entries:
+ entry["is_period_closing_voucher_entry"] = 1
+ entry["closing_date"] = pcv_doc.posting_date
+ entry["period_closing_voucher"] = pcv_doc.name
- for entry in closing_entries:
- entry["closing_date"] = pcv_doc.posting_date
- entry["period_closing_voucher"] = pcv_doc.name
+ closing_entries = []
- make_closing_entries(gl_entries + closing_entries, voucher_name=pcv.name)
- company_wise_order[pcv.company].append(pcv.posting_date)
+ if pcv.posting_date not in company_wise_order[pcv.company]:
+ # get all gl entries for the year
+ closing_entries = frappe.db.get_all(
+ "GL Entry",
+ filters={
+ "is_cancelled": 0,
+ "voucher_no": ["!=", pcv.name],
+ "posting_date": ["between", [pcv_doc.year_start_date, pcv.posting_date]],
+ "is_opening": "No",
+ "company": company,
+ },
+ fields=["*"],
+ )
- i += 1
+ if i == 0:
+ # add opening entries only for the first pcv
+ closing_entries += frappe.db.get_all(
+ "GL Entry",
+ filters={"is_cancelled": 0, "is_opening": "Yes", "company": company},
+ fields=["*"],
+ )
+
+ for entry in closing_entries:
+ entry["closing_date"] = pcv_doc.posting_date
+ entry["period_closing_voucher"] = pcv_doc.name
+
+ entries = gl_entries + closing_entries
+
+ if entries:
+ make_closing_entries(entries, voucher_name=pcv.name)
+ i += 1
+ company_wise_order[pcv.company].append(pcv.posting_date)
diff --git a/erpnext/patches/v15_0/remove_exotel_integration.py b/erpnext/patches/v15_0/remove_exotel_integration.py
new file mode 100644
index 0000000..a37773f
--- /dev/null
+++ b/erpnext/patches/v15_0/remove_exotel_integration.py
@@ -0,0 +1,37 @@
+from contextlib import suppress
+
+import click
+import frappe
+from frappe import _
+from frappe.desk.doctype.notification_log.notification_log import make_notification_logs
+from frappe.utils.user import get_system_managers
+
+SETTINGS_DOCTYPE = "Exotel Settings"
+
+
+def execute():
+ if "exotel_integration" in frappe.get_installed_apps():
+ return
+
+ with suppress(Exception):
+ exotel = frappe.get_doc(SETTINGS_DOCTYPE)
+ if exotel.enabled:
+ notify_existing_users()
+
+ frappe.delete_doc("DocType", SETTINGS_DOCTYPE)
+
+
+def notify_existing_users():
+ click.secho(
+ "Exotel integration is moved to a separate app and will be removed from ERPNext in version-15.\n"
+ "Please install the app to continue using the integration: https://github.com/frappe/exotel_integration",
+ fg="yellow",
+ )
+
+ notification = {
+ "subject": _(
+ "WARNING: Exotel app has been separated from ERPNext, please install the app to continue using Exotel integration."
+ ),
+ "type": "Alert",
+ }
+ make_notification_logs(notification, get_system_managers(only_name=True))
diff --git a/erpnext/public/js/financial_statements.js b/erpnext/public/js/financial_statements.js
index b0082bd..959cf50 100644
--- a/erpnext/public/js/financial_statements.js
+++ b/erpnext/public/js/financial_statements.js
@@ -56,7 +56,7 @@
// dropdown for links to other financial statements
erpnext.financial_statements.filters = get_filters()
- let fiscal_year = frappe.defaults.get_user_default("fiscal_year")
+ let fiscal_year = erpnext.utils.get_fiscal_year(frappe.datetime.get_today());
frappe.model.with_doc("Fiscal Year", fiscal_year, function(r) {
var fy = frappe.model.get_doc("Fiscal Year", fiscal_year);
@@ -137,7 +137,7 @@
"label": __("Start Year"),
"fieldtype": "Link",
"options": "Fiscal Year",
- "default": frappe.defaults.get_user_default("fiscal_year"),
+ "default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today()),
"reqd": 1,
"depends_on": "eval:doc.filter_based_on == 'Fiscal Year'"
},
@@ -146,7 +146,7 @@
"label": __("End Year"),
"fieldtype": "Link",
"options": "Fiscal Year",
- "default": frappe.defaults.get_user_default("fiscal_year"),
+ "default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today()),
"reqd": 1,
"depends_on": "eval:doc.filter_based_on == 'Fiscal Year'"
},
@@ -182,6 +182,16 @@
company: frappe.query_report.get_filter_value("company")
});
}
+ },
+ {
+ "fieldname": "project",
+ "label": __("Project"),
+ "fieldtype": "MultiSelectList",
+ get_data: function(txt) {
+ return frappe.db.get_link_options('Project', txt, {
+ company: frappe.query_report.get_filter_value("company")
+ });
+ },
}
]
diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js
index 29c8aa0..497f8d2 100755
--- a/erpnext/public/js/utils.js
+++ b/erpnext/public/js/utils.js
@@ -398,6 +398,23 @@
});
});
});
+ },
+
+ get_fiscal_year: function(date) {
+ let fiscal_year = '';
+ frappe.call({
+ method: "erpnext.accounts.utils.get_fiscal_year",
+ args: {
+ date: date
+ },
+ async: false,
+ callback: function(r) {
+ if (r.message) {
+ fiscal_year = r.message[0];
+ }
+ }
+ });
+ return fiscal_year;
}
});
@@ -649,7 +666,6 @@
fields.splice(3, 0, {
fieldtype: 'Float',
fieldname: "conversion_factor",
- in_list_view: 1,
label: __("Conversion Factor"),
precision: get_precision('conversion_factor')
})
@@ -657,6 +673,7 @@
new frappe.ui.Dialog({
title: __("Update Items"),
+ size: "extra-large",
fields: [
{
fieldname: "trans_items",
@@ -871,95 +888,87 @@
// Show SLA dashboard
$(document).on('app_ready', function() {
- frappe.call({
- method: 'erpnext.support.doctype.service_level_agreement.service_level_agreement.get_sla_doctypes',
- callback: function(r) {
- if (!r.message)
- return;
+ $.each(frappe.boot.service_level_agreement_doctypes, function(_i, d) {
+ frappe.ui.form.on(d, {
+ onload: function(frm) {
+ if (!frm.doc.service_level_agreement)
+ return;
- $.each(r.message, function(_i, d) {
- frappe.ui.form.on(d, {
- onload: function(frm) {
- if (!frm.doc.service_level_agreement)
- return;
-
- frappe.call({
- method: 'erpnext.support.doctype.service_level_agreement.service_level_agreement.get_service_level_agreement_filters',
- args: {
- doctype: frm.doc.doctype,
- name: frm.doc.service_level_agreement,
- customer: frm.doc.customer
- },
- callback: function (r) {
- if (r && r.message) {
- frm.set_query('priority', function() {
- return {
- filters: {
- 'name': ['in', r.message.priority],
- }
- };
- });
- frm.set_query('service_level_agreement', function() {
- return {
- filters: {
- 'name': ['in', r.message.service_level_agreements],
- }
- };
- });
- }
- }
- });
+ frappe.call({
+ method: 'erpnext.support.doctype.service_level_agreement.service_level_agreement.get_service_level_agreement_filters',
+ args: {
+ doctype: frm.doc.doctype,
+ name: frm.doc.service_level_agreement,
+ customer: frm.doc.customer
},
-
- refresh: function(frm) {
- if (frm.doc.status !== 'Closed' && frm.doc.service_level_agreement
- && ['First Response Due', 'Resolution Due'].includes(frm.doc.agreement_status)) {
- frappe.call({
- 'method': 'frappe.client.get',
- args: {
- doctype: 'Service Level Agreement',
- name: frm.doc.service_level_agreement
- },
- callback: function(data) {
- let statuses = data.message.pause_sla_on;
- const hold_statuses = [];
- $.each(statuses, (_i, entry) => {
- hold_statuses.push(entry.status);
- });
- if (hold_statuses.includes(frm.doc.status)) {
- frm.dashboard.clear_headline();
- let message = {'indicator': 'orange', 'msg': __('SLA is on hold since {0}', [moment(frm.doc.on_hold_since).fromNow(true)])};
- frm.dashboard.set_headline_alert(
- '<div class="row">' +
- '<div class="col-xs-12">' +
- '<span class="indicator whitespace-nowrap '+ message.indicator +'"><span>'+ message.msg +'</span></span> ' +
- '</div>' +
- '</div>'
- );
- } else {
- set_time_to_resolve_and_response(frm, data.message.apply_sla_for_resolution);
+ callback: function (r) {
+ if (r && r.message) {
+ frm.set_query('priority', function() {
+ return {
+ filters: {
+ 'name': ['in', r.message.priority],
}
- }
+ };
});
- } else if (frm.doc.service_level_agreement) {
- frm.dashboard.clear_headline();
-
- let agreement_status = (frm.doc.agreement_status == 'Fulfilled') ?
- {'indicator': 'green', 'msg': 'Service Level Agreement has been fulfilled'} :
- {'indicator': 'red', 'msg': 'Service Level Agreement Failed'};
-
- frm.dashboard.set_headline_alert(
- '<div class="row">' +
- '<div class="col-xs-12">' +
- '<span class="indicator whitespace-nowrap '+ agreement_status.indicator +'"><span class="hidden-xs">'+ agreement_status.msg +'</span></span> ' +
- '</div>' +
- '</div>'
- );
+ frm.set_query('service_level_agreement', function() {
+ return {
+ filters: {
+ 'name': ['in', r.message.service_level_agreements],
+ }
+ };
+ });
}
- },
+ }
});
- });
- }
+ },
+
+ refresh: function(frm) {
+ if (frm.doc.status !== 'Closed' && frm.doc.service_level_agreement
+ && ['First Response Due', 'Resolution Due'].includes(frm.doc.agreement_status)) {
+ frappe.call({
+ 'method': 'frappe.client.get',
+ args: {
+ doctype: 'Service Level Agreement',
+ name: frm.doc.service_level_agreement
+ },
+ callback: function(data) {
+ let statuses = data.message.pause_sla_on;
+ const hold_statuses = [];
+ $.each(statuses, (_i, entry) => {
+ hold_statuses.push(entry.status);
+ });
+ if (hold_statuses.includes(frm.doc.status)) {
+ frm.dashboard.clear_headline();
+ let message = {'indicator': 'orange', 'msg': __('SLA is on hold since {0}', [moment(frm.doc.on_hold_since).fromNow(true)])};
+ frm.dashboard.set_headline_alert(
+ '<div class="row">' +
+ '<div class="col-xs-12">' +
+ '<span class="indicator whitespace-nowrap '+ message.indicator +'"><span>'+ message.msg +'</span></span> ' +
+ '</div>' +
+ '</div>'
+ );
+ } else {
+ set_time_to_resolve_and_response(frm, data.message.apply_sla_for_resolution);
+ }
+ }
+ });
+ } else if (frm.doc.service_level_agreement) {
+ frm.dashboard.clear_headline();
+
+ let agreement_status = (frm.doc.agreement_status == 'Fulfilled') ?
+ {'indicator': 'green', 'msg': 'Service Level Agreement has been fulfilled'} :
+ {'indicator': 'red', 'msg': 'Service Level Agreement Failed'};
+
+ frm.dashboard.set_headline_alert(
+ '<div class="row">' +
+ '<div class="col-xs-12">' +
+ '<span class="indicator whitespace-nowrap '+ agreement_status.indicator +'"><span class="hidden-xs">'+ agreement_status.msg +'</span></span> ' +
+ '</div>' +
+ '</div>'
+ );
+ }
+ },
+ });
});
});
diff --git "a/erpnext/regional/report/fichier_des_ecritures_comptables_\133fec\135/fichier_des_ecritures_comptables_\133fec\135.js" "b/erpnext/regional/report/fichier_des_ecritures_comptables_\133fec\135/fichier_des_ecritures_comptables_\133fec\135.js"
index a4c7640..b85b58f 100644
--- "a/erpnext/regional/report/fichier_des_ecritures_comptables_\133fec\135/fichier_des_ecritures_comptables_\133fec\135.js"
+++ "b/erpnext/regional/report/fichier_des_ecritures_comptables_\133fec\135/fichier_des_ecritures_comptables_\133fec\135.js"
@@ -16,7 +16,7 @@
"label": __("Fiscal Year"),
"fieldtype": "Link",
"options": "Fiscal Year",
- "default": frappe.defaults.get_user_default("fiscal_year"),
+ "default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today()),
"reqd": 1
}
],
diff --git a/erpnext/regional/report/irs_1099/irs_1099.js b/erpnext/regional/report/irs_1099/irs_1099.js
index 070ff43..b3508e4 100644
--- a/erpnext/regional/report/irs_1099/irs_1099.js
+++ b/erpnext/regional/report/irs_1099/irs_1099.js
@@ -17,7 +17,7 @@
"label": __("Fiscal Year"),
"fieldtype": "Link",
"options": "Fiscal Year",
- "default": frappe.defaults.get_user_default("fiscal_year"),
+ "default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today()),
"reqd": 1,
"width": 80,
},
diff --git a/erpnext/selling/doctype/customer/customer.js b/erpnext/selling/doctype/customer/customer.js
index 540e767..60f0941 100644
--- a/erpnext/selling/doctype/customer/customer.js
+++ b/erpnext/selling/doctype/customer/customer.js
@@ -131,8 +131,6 @@
erpnext.toggle_naming_series();
}
- frappe.dynamic_link = {doc: frm.doc, fieldname: 'name', doctype: 'Customer'}
-
if(!frm.doc.__islocal) {
frappe.contacts.render_address_and_contact(frm);
diff --git a/erpnext/setup/doctype/company/company.js b/erpnext/setup/doctype/company/company.js
index 3335387..f4682c1 100644
--- a/erpnext/setup/doctype/company/company.js
+++ b/erpnext/setup/doctype/company/company.js
@@ -81,8 +81,6 @@
disbale_coa_fields(frm);
frappe.contacts.render_address_and_contact(frm);
- frappe.dynamic_link = {doc: frm.doc, fieldname: 'name', doctype: 'Company'}
-
if (frappe.perm.has_perm("Cost Center", 0, 'read')) {
frm.add_custom_button(__('Cost Centers'), function() {
frappe.set_route('Tree', 'Cost Center', {'company': frm.doc.name});
diff --git a/erpnext/setup/doctype/global_defaults/global_defaults.json b/erpnext/setup/doctype/global_defaults/global_defaults.json
index bafb97a..823d2ba 100644
--- a/erpnext/setup/doctype/global_defaults/global_defaults.json
+++ b/erpnext/setup/doctype/global_defaults/global_defaults.json
@@ -1,352 +1,99 @@
{
- "allow_copy": 1,
- "allow_guest_to_view": 0,
- "allow_import": 0,
- "allow_rename": 0,
- "beta": 0,
- "creation": "2013-05-02 17:53:24",
- "custom": 0,
- "docstatus": 0,
- "doctype": "DocType",
- "editable_grid": 0,
+ "actions": [],
+ "allow_copy": 1,
+ "creation": "2013-05-02 17:53:24",
+ "doctype": "DocType",
+ "engine": "InnoDB",
+ "field_order": [
+ "default_company",
+ "country",
+ "default_distance_unit",
+ "column_break_8",
+ "default_currency",
+ "hide_currency_symbol",
+ "disable_rounded_total",
+ "disable_in_words"
+ ],
"fields": [
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "default_company",
- "fieldtype": "Link",
- "hidden": 0,
- "ignore_user_permissions": 1,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "Default Company",
- "length": 0,
- "no_copy": 0,
- "options": "Company",
- "permlevel": 0,
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "default_company",
+ "fieldtype": "Link",
+ "ignore_user_permissions": 1,
+ "label": "Default Company",
+ "options": "Company"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "current_fiscal_year",
- "fieldtype": "Link",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "Current Fiscal Year",
- "length": 0,
- "no_copy": 0,
- "options": "Fiscal Year",
- "permlevel": 0,
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 1,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "country",
+ "fieldtype": "Link",
+ "label": "Country",
+ "options": "Country"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "country",
- "fieldtype": "Link",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "Country",
- "length": 0,
- "no_copy": 0,
- "options": "Country",
- "permlevel": 0,
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "default_distance_unit",
+ "fieldtype": "Link",
+ "label": "Default Distance Unit",
+ "options": "UOM"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "default": "",
- "fieldname": "default_distance_unit",
- "fieldtype": "Link",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "Default Distance Unit",
- "length": 0,
- "no_copy": 0,
- "options": "UOM",
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "column_break_8",
+ "fieldtype": "Column Break"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "column_break_8",
- "fieldtype": "Column Break",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "default": "INR",
+ "fieldname": "default_currency",
+ "fieldtype": "Link",
+ "ignore_user_permissions": 1,
+ "in_list_view": 1,
+ "label": "Default Currency",
+ "options": "Currency",
+ "reqd": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "default": "INR",
- "fieldname": "default_currency",
- "fieldtype": "Link",
- "hidden": 0,
- "ignore_user_permissions": 1,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 1,
- "in_standard_filter": 0,
- "label": "Default Currency",
- "length": 0,
- "no_copy": 0,
- "options": "Currency",
- "permlevel": 0,
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 1,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "description": "Do not show any symbol like $ etc next to currencies.",
+ "fieldname": "hide_currency_symbol",
+ "fieldtype": "Select",
+ "in_list_view": 1,
+ "label": "Hide Currency Symbol",
+ "options": "\nNo\nYes"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "description": "Do not show any symbol like $ etc next to currencies.",
- "fieldname": "hide_currency_symbol",
- "fieldtype": "Select",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 1,
- "in_standard_filter": 0,
- "label": "Hide Currency Symbol",
- "length": 0,
- "no_copy": 0,
- "options": "\nNo\nYes",
- "permlevel": 0,
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "default": "0",
+ "description": "If disable, 'Rounded Total' field will not be visible in any transaction",
+ "fieldname": "disable_rounded_total",
+ "fieldtype": "Check",
+ "in_list_view": 1,
+ "label": "Disable Rounded Total"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "description": "If disable, 'Rounded Total' field will not be visible in any transaction",
- "fieldname": "disable_rounded_total",
- "fieldtype": "Check",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 1,
- "in_standard_filter": 0,
- "label": "Disable Rounded Total",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
- {
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "description": "If disable, 'In Words' field will not be visible in any transaction",
- "fieldname": "disable_in_words",
- "fieldtype": "Check",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 1,
- "in_standard_filter": 0,
- "label": "Disable In Words",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
+ "default": "0",
+ "description": "If disable, 'In Words' field will not be visible in any transaction",
+ "fieldname": "disable_in_words",
+ "fieldtype": "Check",
+ "in_list_view": 1,
+ "label": "Disable In Words"
}
- ],
- "has_web_view": 0,
- "hide_heading": 0,
- "hide_toolbar": 0,
- "icon": "fa fa-cog",
- "idx": 1,
- "image_view": 0,
- "in_create": 1,
- "is_submittable": 0,
- "issingle": 1,
- "istable": 0,
- "max_attachments": 0,
- "menu_index": 0,
- "modified": "2018-10-15 03:08:19.886212",
- "modified_by": "Administrator",
- "module": "Setup",
- "name": "Global Defaults",
- "owner": "Administrator",
+ ],
+ "icon": "fa fa-cog",
+ "idx": 1,
+ "in_create": 1,
+ "issingle": 1,
+ "links": [],
+ "modified": "2023-07-01 19:45:00.323953",
+ "modified_by": "Administrator",
+ "module": "Setup",
+ "name": "Global Defaults",
+ "owner": "Administrator",
"permissions": [
{
- "amend": 0,
- "cancel": 0,
- "create": 1,
- "delete": 0,
- "email": 0,
- "export": 0,
- "if_owner": 0,
- "import": 0,
- "permlevel": 0,
- "print": 0,
- "read": 1,
- "report": 0,
- "role": "System Manager",
- "set_user_permissions": 0,
- "share": 1,
- "submit": 0,
+ "create": 1,
+ "read": 1,
+ "role": "System Manager",
+ "share": 1,
"write": 1
}
- ],
- "quick_entry": 0,
- "read_only": 1,
- "read_only_onload": 0,
- "show_name_in_global_search": 0,
- "sort_order": "DESC",
- "track_changes": 0,
- "track_seen": 0,
- "track_views": 0
+ ],
+ "read_only": 1,
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "states": []
}
\ No newline at end of file
diff --git a/erpnext/setup/doctype/global_defaults/global_defaults.py b/erpnext/setup/doctype/global_defaults/global_defaults.py
index 16e9434..fc80483 100644
--- a/erpnext/setup/doctype/global_defaults/global_defaults.py
+++ b/erpnext/setup/doctype/global_defaults/global_defaults.py
@@ -10,7 +10,6 @@
keydict = {
# "key in defaults": "key in Global Defaults"
- "fiscal_year": "current_fiscal_year",
"company": "default_company",
"currency": "default_currency",
"country": "country",
@@ -29,22 +28,6 @@
for key in keydict:
frappe.db.set_default(key, self.get(keydict[key], ""))
- # update year start date and year end date from fiscal_year
- if self.current_fiscal_year:
- if fiscal_year := frappe.get_all(
- "Fiscal Year",
- filters={"name": self.current_fiscal_year},
- fields=["year_start_date", "year_end_date"],
- limit=1,
- order_by=None,
- ):
- ysd = fiscal_year[0].year_start_date or ""
- yed = fiscal_year[0].year_end_date or ""
-
- if ysd and yed:
- frappe.db.set_default("year_start_date", ysd.strftime("%Y-%m-%d"))
- frappe.db.set_default("year_end_date", yed.strftime("%Y-%m-%d"))
-
# enable default currency
if self.default_currency:
frappe.db.set_value("Currency", self.default_currency, "enabled", 1)
diff --git a/erpnext/setup/doctype/holiday_list/holiday_list.js b/erpnext/setup/doctype/holiday_list/holiday_list.js
index ea033c7..90d9f1b 100644
--- a/erpnext/setup/doctype/holiday_list/holiday_list.js
+++ b/erpnext/setup/doctype/holiday_list/holiday_list.js
@@ -6,13 +6,41 @@
if (frm.doc.holidays) {
frm.set_value("total_holidays", frm.doc.holidays.length);
}
+
+ frm.call("get_supported_countries").then(r => {
+ frm.subdivisions_by_country = r.message.subdivisions_by_country;
+ frm.fields_dict.country.set_data(
+ r.message.countries.sort((a, b) => a.label.localeCompare(b.label))
+ );
+
+ if (frm.doc.country) {
+ frm.trigger("set_subdivisions");
+ }
+ });
},
from_date: function(frm) {
if (frm.doc.from_date && !frm.doc.to_date) {
var a_year_from_start = frappe.datetime.add_months(frm.doc.from_date, 12);
frm.set_value("to_date", frappe.datetime.add_days(a_year_from_start, -1));
}
- }
+ },
+ country: function(frm) {
+ frm.set_value("subdivision", "");
+
+ if (frm.doc.country) {
+ frm.trigger("set_subdivisions");
+ }
+ },
+ set_subdivisions: function(frm) {
+ const subdivisions = [...frm.subdivisions_by_country[frm.doc.country]];
+ if (subdivisions && subdivisions.length > 0) {
+ frm.fields_dict.subdivision.set_data(subdivisions);
+ frm.set_df_property("subdivision", "hidden", 0);
+ } else {
+ frm.fields_dict.subdivision.set_data([]);
+ frm.set_df_property("subdivision", "hidden", 1);
+ }
+ },
});
frappe.tour["Holiday List"] = [
diff --git a/erpnext/setup/doctype/holiday_list/holiday_list.json b/erpnext/setup/doctype/holiday_list/holiday_list.json
index 4bbe6a6..45671d1 100644
--- a/erpnext/setup/doctype/holiday_list/holiday_list.json
+++ b/erpnext/setup/doctype/holiday_list/holiday_list.json
@@ -1,480 +1,166 @@
{
- "allow_copy": 0,
- "allow_guest_to_view": 0,
+ "actions": [],
"allow_import": 1,
"allow_rename": 1,
"autoname": "field:holiday_list_name",
- "beta": 0,
"creation": "2013-01-10 16:34:14",
- "custom": 0,
- "docstatus": 0,
"doctype": "DocType",
"document_type": "Setup",
- "editable_grid": 0,
"engine": "InnoDB",
+ "field_order": [
+ "holiday_list_name",
+ "from_date",
+ "to_date",
+ "column_break_4",
+ "total_holidays",
+ "add_weekly_holidays",
+ "weekly_off",
+ "get_weekly_off_dates",
+ "add_local_holidays",
+ "country",
+ "subdivision",
+ "get_local_holidays",
+ "holidays_section",
+ "holidays",
+ "clear_table",
+ "section_break_9",
+ "color"
+ ],
"fields": [
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "holiday_list_name",
"fieldtype": "Data",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
"label": "Holiday List Name",
- "length": 0,
- "no_copy": 0,
"oldfieldname": "holiday_list_name",
"oldfieldtype": "Data",
- "permlevel": 0,
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
"reqd": 1,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
"unique": 1
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "from_date",
"fieldtype": "Date",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
"in_list_view": 1,
- "in_standard_filter": 0,
"label": "From Date",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 1,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
+ "reqd": 1
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "to_date",
"fieldtype": "Date",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
"in_list_view": 1,
- "in_standard_filter": 0,
"label": "To Date",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 1,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
+ "reqd": 1
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "column_break_4",
- "fieldtype": "Column Break",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
+ "fieldtype": "Column Break"
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "total_holidays",
"fieldtype": "Int",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
"in_list_view": 1,
- "in_standard_filter": 0,
"label": "Total Holidays",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 1,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
+ "read_only": 1
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
"collapsible": 1,
- "columns": 0,
+ "depends_on": "eval: doc.from_date && doc.to_date",
"fieldname": "add_weekly_holidays",
"fieldtype": "Section Break",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "Add Weekly Holidays",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
+ "label": "Add Weekly Holidays"
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "weekly_off",
"fieldtype": "Select",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
"in_standard_filter": 1,
"label": "Weekly Off",
- "length": 0,
"no_copy": 1,
"options": "\nSunday\nMonday\nTuesday\nWednesday\nThursday\nFriday\nSaturday",
- "permlevel": 0,
"print_hide": 1,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 1,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
+ "report_hide": 1
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "get_weekly_off_dates",
"fieldtype": "Button",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
"label": "Add to Holidays",
- "length": 0,
- "no_copy": 0,
- "options": "get_weekly_off_dates",
- "permlevel": 0,
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
+ "options": "get_weekly_off_dates"
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "holidays_section",
"fieldtype": "Section Break",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "Holidays",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
+ "label": "Holidays"
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "holidays",
"fieldtype": "Table",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
"label": "Holidays",
- "length": 0,
- "no_copy": 0,
"oldfieldname": "holiday_list_details",
"oldfieldtype": "Table",
- "options": "Holiday",
- "permlevel": 0,
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
+ "options": "Holiday"
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "clear_table",
"fieldtype": "Button",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
"label": "Clear Table",
- "length": 0,
- "no_copy": 0,
- "options": "clear_table",
- "permlevel": 0,
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
+ "options": "clear_table"
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "section_break_9",
- "fieldtype": "Section Break",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
+ "fieldtype": "Section Break"
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "color",
"fieldtype": "Color",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
"label": "Color",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 1,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
+ "print_hide": 1
+ },
+ {
+ "fieldname": "country",
+ "fieldtype": "Autocomplete",
+ "label": "Country"
+ },
+ {
+ "depends_on": "country",
+ "fieldname": "subdivision",
+ "fieldtype": "Autocomplete",
+ "label": "Subdivision"
+ },
+ {
+ "collapsible": 1,
+ "depends_on": "eval: doc.from_date && doc.to_date",
+ "fieldname": "add_local_holidays",
+ "fieldtype": "Section Break",
+ "label": "Add Local Holidays"
+ },
+ {
+ "fieldname": "get_local_holidays",
+ "fieldtype": "Button",
+ "label": "Add to Holidays",
+ "options": "get_local_holidays"
}
],
- "has_web_view": 0,
- "hide_heading": 0,
- "hide_toolbar": 0,
"icon": "fa fa-calendar",
"idx": 1,
- "image_view": 0,
- "in_create": 0,
- "is_submittable": 0,
- "issingle": 0,
- "istable": 0,
- "max_attachments": 0,
- "modified": "2018-07-03 07:22:46.474096",
+ "links": [],
+ "modified": "2023-07-14 13:28:53.156421",
"modified_by": "Administrator",
"module": "Setup",
"name": "Holiday List",
+ "naming_rule": "By fieldname",
"owner": "Administrator",
"permissions": [
{
- "amend": 0,
- "cancel": 0,
"create": 1,
"delete": 1,
"email": 1,
- "export": 0,
- "if_owner": 0,
- "import": 0,
- "permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "HR Manager",
- "set_user_permissions": 0,
"share": 1,
- "submit": 0,
"write": 1
}
],
- "quick_entry": 0,
- "read_only": 0,
- "read_only_onload": 0,
- "show_name_in_global_search": 0,
"sort_field": "modified",
"sort_order": "DESC",
- "track_changes": 0,
- "track_seen": 0,
- "track_views": 0
+ "states": []
}
\ No newline at end of file
diff --git a/erpnext/setup/doctype/holiday_list/holiday_list.py b/erpnext/setup/doctype/holiday_list/holiday_list.py
index 84d0d35..2ef4e65 100644
--- a/erpnext/setup/doctype/holiday_list/holiday_list.py
+++ b/erpnext/setup/doctype/holiday_list/holiday_list.py
@@ -3,11 +3,15 @@
import json
+from datetime import date
import frappe
+from babel import Locale
from frappe import _, throw
from frappe.model.document import Document
-from frappe.utils import cint, formatdate, getdate, today
+from frappe.utils import formatdate, getdate, today
+from holidays import country_holidays
+from holidays.utils import list_supported_countries
class OverlapError(frappe.ValidationError):
@@ -21,25 +25,66 @@
@frappe.whitelist()
def get_weekly_off_dates(self):
- self.validate_values()
- date_list = self.get_weekly_off_date_list(self.from_date, self.to_date)
- last_idx = max(
- [cint(d.idx) for d in self.get("holidays")]
- or [
- 0,
- ]
- )
- for i, d in enumerate(date_list):
- ch = self.append("holidays", {})
- ch.description = _(self.weekly_off)
- ch.holiday_date = d
- ch.weekly_off = 1
- ch.idx = last_idx + i + 1
-
- def validate_values(self):
if not self.weekly_off:
throw(_("Please select weekly off day"))
+ existing_holidays = self.get_holidays()
+
+ for d in self.get_weekly_off_date_list(self.from_date, self.to_date):
+ if d in existing_holidays:
+ continue
+
+ self.append("holidays", {"description": _(self.weekly_off), "holiday_date": d, "weekly_off": 1})
+
+ self.sort_holidays()
+
+ @frappe.whitelist()
+ def get_supported_countries(self):
+ subdivisions_by_country = list_supported_countries()
+ countries = [
+ {"value": country, "label": local_country_name(country)}
+ for country in subdivisions_by_country.keys()
+ ]
+ return {
+ "countries": countries,
+ "subdivisions_by_country": subdivisions_by_country,
+ }
+
+ @frappe.whitelist()
+ def get_local_holidays(self):
+ if not self.country:
+ throw(_("Please select a country"))
+
+ existing_holidays = self.get_holidays()
+ from_date = getdate(self.from_date)
+ to_date = getdate(self.to_date)
+
+ for holiday_date, holiday_name in country_holidays(
+ self.country,
+ subdiv=self.subdivision,
+ years=[from_date.year, to_date.year],
+ language=frappe.local.lang,
+ ).items():
+ if holiday_date in existing_holidays:
+ continue
+
+ if holiday_date < from_date or holiday_date > to_date:
+ continue
+
+ self.append(
+ "holidays", {"description": holiday_name, "holiday_date": holiday_date, "weekly_off": 0}
+ )
+
+ self.sort_holidays()
+
+ def sort_holidays(self):
+ self.holidays.sort(key=lambda x: getdate(x.holiday_date))
+ for i in range(len(self.holidays)):
+ self.holidays[i].idx = i + 1
+
+ def get_holidays(self) -> list[date]:
+ return [getdate(holiday.holiday_date) for holiday in self.holidays]
+
def validate_days(self):
if getdate(self.from_date) > getdate(self.to_date):
throw(_("To Date cannot be before From Date"))
@@ -120,3 +165,8 @@
)
else:
return False
+
+
+def local_country_name(country_code: str) -> str:
+ """Return the localized country name for the given country code."""
+ return Locale.parse(frappe.local.lang).territories.get(country_code, country_code)
diff --git a/erpnext/setup/doctype/holiday_list/test_holiday_list.py b/erpnext/setup/doctype/holiday_list/test_holiday_list.py
index d32cfe8..23b08fd 100644
--- a/erpnext/setup/doctype/holiday_list/test_holiday_list.py
+++ b/erpnext/setup/doctype/holiday_list/test_holiday_list.py
@@ -3,7 +3,7 @@
import unittest
from contextlib import contextmanager
-from datetime import timedelta
+from datetime import date, timedelta
import frappe
from frappe.utils import getdate
@@ -23,6 +23,41 @@
fetched_holiday_list = frappe.get_value("Holiday List", holiday_list.name)
self.assertEqual(holiday_list.name, fetched_holiday_list)
+ def test_weekly_off(self):
+ holiday_list = frappe.new_doc("Holiday List")
+ holiday_list.from_date = "2023-01-01"
+ holiday_list.to_date = "2023-02-28"
+ holiday_list.weekly_off = "Sunday"
+ holiday_list.get_weekly_off_dates()
+
+ holidays = [holiday.holiday_date for holiday in holiday_list.holidays]
+
+ self.assertNotIn(date(2022, 12, 25), holidays)
+ self.assertIn(date(2023, 1, 1), holidays)
+ self.assertIn(date(2023, 1, 8), holidays)
+ self.assertIn(date(2023, 1, 15), holidays)
+ self.assertIn(date(2023, 1, 22), holidays)
+ self.assertIn(date(2023, 1, 29), holidays)
+ self.assertIn(date(2023, 2, 5), holidays)
+ self.assertIn(date(2023, 2, 12), holidays)
+ self.assertIn(date(2023, 2, 19), holidays)
+ self.assertIn(date(2023, 2, 26), holidays)
+ self.assertNotIn(date(2023, 3, 5), holidays)
+
+ def test_local_holidays(self):
+ holiday_list = frappe.new_doc("Holiday List")
+ holiday_list.from_date = "2023-04-01"
+ holiday_list.to_date = "2023-04-30"
+ holiday_list.country = "DE"
+ holiday_list.subdivision = "SN"
+ holiday_list.get_local_holidays()
+
+ holidays = [holiday.holiday_date for holiday in holiday_list.holidays]
+ self.assertNotIn(date(2023, 1, 1), holidays)
+ self.assertIn(date(2023, 4, 7), holidays)
+ self.assertIn(date(2023, 4, 10), holidays)
+ self.assertNotIn(date(2023, 5, 1), holidays)
+
def make_holiday_list(
name, from_date=getdate() - timedelta(days=10), to_date=getdate(), holiday_dates=None
diff --git a/erpnext/setup/doctype/sales_partner/sales_partner.js b/erpnext/setup/doctype/sales_partner/sales_partner.js
index 5656d43..f9e3770 100644
--- a/erpnext/setup/doctype/sales_partner/sales_partner.js
+++ b/erpnext/setup/doctype/sales_partner/sales_partner.js
@@ -3,8 +3,6 @@
frappe.ui.form.on('Sales Partner', {
refresh: function(frm) {
- frappe.dynamic_link = {doc: frm.doc, fieldname: 'name', doctype: 'Sales Partner'}
-
if(frm.doc.__islocal){
hide_field(['address_html', 'contact_html', 'address_contacts']);
frappe.contacts.clear_address_and_contact(frm);
diff --git a/erpnext/setup/setup_wizard/operations/install_fixtures.py b/erpnext/setup/setup_wizard/operations/install_fixtures.py
index 8e61fe2..535c87d 100644
--- a/erpnext/setup/setup_wizard/operations/install_fixtures.py
+++ b/erpnext/setup/setup_wizard/operations/install_fixtures.py
@@ -462,11 +462,9 @@
def set_global_defaults(args):
global_defaults = frappe.get_doc("Global Defaults", "Global Defaults")
- current_fiscal_year = frappe.get_all("Fiscal Year")[0]
global_defaults.update(
{
- "current_fiscal_year": current_fiscal_year.name,
"default_currency": args.get("currency"),
"default_company": args.get("company_name"),
"country": args.get("country"),
diff --git a/erpnext/stock/doctype/delivery_note/test_delivery_note.py b/erpnext/stock/doctype/delivery_note/test_delivery_note.py
index 8baae8a..0ef3027 100644
--- a/erpnext/stock/doctype/delivery_note/test_delivery_note.py
+++ b/erpnext/stock/doctype/delivery_note/test_delivery_note.py
@@ -318,6 +318,37 @@
self.assertEqual(dn.per_returned, 100)
self.assertEqual(dn.status, "Return Issued")
+ def test_delivery_note_return_valuation_on_different_warehuose(self):
+ from erpnext.stock.doctype.warehouse.test_warehouse import create_warehouse
+
+ company = frappe.db.get_value("Warehouse", "Stores - TCP1", "company")
+ item_code = "Test Return Valuation For DN"
+ make_item("Test Return Valuation For DN", {"is_stock_item": 1})
+ return_warehouse = create_warehouse("Returned Test Warehouse", company=company)
+
+ make_stock_entry(item_code=item_code, target="Stores - TCP1", qty=5, basic_rate=150)
+
+ dn = create_delivery_note(
+ item_code=item_code,
+ qty=5,
+ rate=500,
+ warehouse="Stores - TCP1",
+ company=company,
+ expense_account="Cost of Goods Sold - TCP1",
+ cost_center="Main - TCP1",
+ )
+
+ dn.submit()
+ self.assertEqual(dn.items[0].incoming_rate, 150)
+
+ from erpnext.controllers.sales_and_purchase_return import make_return_doc
+
+ return_dn = make_return_doc(dn.doctype, dn.name)
+ return_dn.items[0].warehouse = return_warehouse
+ return_dn.save().submit()
+
+ self.assertEqual(return_dn.items[0].incoming_rate, 150)
+
def test_return_single_item_from_bundled_items(self):
company = frappe.db.get_value("Warehouse", "Stores - TCP1", "company")
diff --git a/erpnext/stock/doctype/item/item.json b/erpnext/stock/doctype/item/item.json
index 34adbeb..87c2a7e 100644
--- a/erpnext/stock/doctype/item/item.json
+++ b/erpnext/stock/doctype/item/item.json
@@ -194,7 +194,8 @@
"default": "0",
"fieldname": "disabled",
"fieldtype": "Check",
- "label": "Disabled"
+ "label": "Disabled",
+ "search_index": 1
},
{
"default": "0",
@@ -911,7 +912,7 @@
"index_web_pages_for_search": 1,
"links": [],
"make_attachments_public": 1,
- "modified": "2023-02-14 04:48:26.343620",
+ "modified": "2023-07-14 17:18:18.658942",
"modified_by": "Administrator",
"module": "Stock",
"name": "Item",
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index 93d799a..ef4155e 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -773,7 +773,7 @@
rows = ""
for docname, attr_list in not_included.items():
- link = "<a href='/app/Form/Item/{0}'>{0}</a>".format(frappe.bold(_(docname)))
+ link = f"<a href='/app/item/{docname}'>{frappe.bold(docname)}</a>"
rows += table_row(link, body(attr_list))
error_description = _(
diff --git a/erpnext/stock/doctype/item_variant_attribute/item_variant_attribute.json b/erpnext/stock/doctype/item_variant_attribute/item_variant_attribute.json
index 6d02ea9..9699ecb 100644
--- a/erpnext/stock/doctype/item_variant_attribute/item_variant_attribute.json
+++ b/erpnext/stock/doctype/item_variant_attribute/item_variant_attribute.json
@@ -1,370 +1,90 @@
{
- "allow_copy": 0,
- "allow_events_in_timeline": 0,
- "allow_guest_to_view": 0,
- "allow_import": 0,
- "allow_rename": 0,
- "autoname": "",
- "beta": 0,
- "creation": "2015-05-19 05:12:30.344797",
- "custom": 0,
- "docstatus": 0,
- "doctype": "DocType",
- "document_type": "Other",
- "editable_grid": 1,
+ "actions": [],
+ "creation": "2015-05-19 05:12:30.344797",
+ "doctype": "DocType",
+ "document_type": "Other",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "field_order": [
+ "variant_of",
+ "attribute",
+ "column_break_2",
+ "attribute_value",
+ "numeric_values",
+ "section_break_4",
+ "from_range",
+ "increment",
+ "column_break_8",
+ "to_range"
+ ],
"fields": [
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "variant_of",
- "fieldtype": "Link",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "Variant Of",
- "length": 0,
- "no_copy": 0,
- "options": "Item",
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "variant_of",
+ "fieldtype": "Link",
+ "label": "Variant Of",
+ "options": "Item",
+ "search_index": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "attribute",
- "fieldtype": "Link",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 1,
- "in_standard_filter": 0,
- "label": "Attribute",
- "length": 0,
- "no_copy": 0,
- "options": "Item Attribute",
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 1,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "attribute",
+ "fieldtype": "Link",
+ "in_list_view": 1,
+ "label": "Attribute",
+ "options": "Item Attribute",
+ "reqd": 1,
+ "search_index": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "column_break_2",
- "fieldtype": "Column Break",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "column_break_2",
+ "fieldtype": "Column Break"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "depends_on": "",
- "fieldname": "attribute_value",
- "fieldtype": "Data",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 1,
- "in_standard_filter": 0,
- "label": "Attribute Value",
- "length": 0,
- "no_copy": 0,
- "options": "",
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "attribute_value",
+ "fieldtype": "Data",
+ "in_list_view": 1,
+ "label": "Attribute Value"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "depends_on": "has_variants",
- "fieldname": "numeric_values",
- "fieldtype": "Check",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "Numeric Values",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "default": "0",
+ "depends_on": "has_variants",
+ "fieldname": "numeric_values",
+ "fieldtype": "Check",
+ "label": "Numeric Values"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "depends_on": "numeric_values",
- "fieldname": "section_break_4",
- "fieldtype": "Section Break",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "depends_on": "numeric_values",
+ "fieldname": "section_break_4",
+ "fieldtype": "Section Break"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "depends_on": "",
- "fieldname": "from_range",
- "fieldtype": "Float",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "From Range",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "from_range",
+ "fieldtype": "Float",
+ "label": "From Range"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "depends_on": "",
- "fieldname": "increment",
- "fieldtype": "Float",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "Increment",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "increment",
+ "fieldtype": "Float",
+ "label": "Increment"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "column_break_8",
- "fieldtype": "Column Break",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "column_break_8",
+ "fieldtype": "Column Break"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "depends_on": "",
- "fieldname": "to_range",
- "fieldtype": "Float",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "To Range",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
+ "fieldname": "to_range",
+ "fieldtype": "Float",
+ "label": "To Range"
}
- ],
- "has_web_view": 0,
- "hide_heading": 0,
- "hide_toolbar": 0,
- "icon": "",
- "idx": 0,
- "image_view": 0,
- "in_create": 0,
- "is_submittable": 0,
- "issingle": 0,
- "istable": 1,
- "max_attachments": 0,
- "modified": "2019-01-03 15:36:59.129006",
- "modified_by": "Administrator",
- "module": "Stock",
- "name": "Item Variant Attribute",
- "name_case": "",
- "owner": "Administrator",
- "permissions": [],
- "quick_entry": 0,
- "read_only": 0,
- "read_only_onload": 0,
- "show_name_in_global_search": 0,
- "sort_field": "modified",
- "sort_order": "DESC",
- "track_changes": 0,
- "track_seen": 0,
- "track_views": 0
+ ],
+ "istable": 1,
+ "links": [],
+ "modified": "2023-07-14 17:15:19.112119",
+ "modified_by": "Administrator",
+ "module": "Stock",
+ "name": "Item Variant Attribute",
+ "owner": "Administrator",
+ "permissions": [],
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "states": []
}
\ No newline at end of file
diff --git a/erpnext/stock/doctype/manufacturer/manufacturer.js b/erpnext/stock/doctype/manufacturer/manufacturer.js
index bb7e314..5b4990f 100644
--- a/erpnext/stock/doctype/manufacturer/manufacturer.js
+++ b/erpnext/stock/doctype/manufacturer/manufacturer.js
@@ -3,7 +3,6 @@
frappe.ui.form.on('Manufacturer', {
refresh: function(frm) {
- frappe.dynamic_link = { doc: frm.doc, fieldname: 'name', doctype: 'Manufacturer' };
if (frm.doc.__islocal) {
hide_field(['address_html','contact_html']);
frappe.contacts.clear_address_and_contact(frm);
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json
index b41e971..912b908 100755
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json
@@ -438,6 +438,7 @@
{
"fieldname": "rejected_warehouse",
"fieldtype": "Link",
+ "ignore_user_permissions": 1,
"label": "Rejected Warehouse",
"no_copy": 1,
"oldfieldname": "rejected_warehouse",
@@ -1240,7 +1241,7 @@
"idx": 261,
"is_submittable": 1,
"links": [],
- "modified": "2023-06-03 16:23:20.781368",
+ "modified": "2023-07-04 17:23:17.025390",
"modified_by": "Administrator",
"module": "Stock",
"name": "Purchase Receipt",
diff --git a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
index 07d6e86..6134bfa 100644
--- a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
+++ b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
@@ -350,6 +350,15 @@
pr.cancel()
self.assertFalse(frappe.db.get_value("Serial No", pr_row_1_serial_no, "warehouse"))
+ def test_rejected_warehouse_filter(self):
+ pr = frappe.copy_doc(test_records[0])
+ pr.get("items")[0].item_code = "_Test Serialized Item With Series"
+ pr.get("items")[0].qty = 3
+ pr.get("items")[0].rejected_qty = 2
+ pr.get("items")[0].received_qty = 5
+ pr.get("items")[0].rejected_warehouse = pr.get("items")[0].warehouse
+ self.assertRaises(frappe.ValidationError, pr.save)
+
def test_rejected_serial_no(self):
pr = frappe.copy_doc(test_records[0])
pr.get("items")[0].item_code = "_Test Serialized Item With Series"
@@ -1956,6 +1965,32 @@
ste5.reload()
self.assertEqual(ste5.items[0].valuation_rate, 275.00)
+ ste6 = make_stock_entry(
+ purpose="Material Transfer",
+ posting_date=add_days(today(), -3),
+ source=warehouse1,
+ target=warehouse,
+ item_code=item_code,
+ qty=20,
+ company=pr.company,
+ )
+
+ ste6.reload()
+ self.assertEqual(ste6.items[0].valuation_rate, 275.00)
+
+ ste7 = make_stock_entry(
+ purpose="Material Transfer",
+ posting_date=add_days(today(), -3),
+ source=warehouse,
+ target=warehouse1,
+ item_code=item_code,
+ qty=20,
+ company=pr.company,
+ )
+
+ ste7.reload()
+ self.assertEqual(ste7.items[0].valuation_rate, 275.00)
+
create_landed_cost_voucher("Purchase Receipt", pr.name, pr.company, charges=2500 * -1)
pr.reload()
@@ -1976,6 +2011,12 @@
ste5.reload()
self.assertEqual(ste5.items[0].valuation_rate, valuation_rate)
+ ste6.reload()
+ self.assertEqual(ste6.items[0].valuation_rate, valuation_rate)
+
+ ste7.reload()
+ self.assertEqual(ste7.items[0].valuation_rate, valuation_rate)
+
def prepare_data_for_internal_transfer():
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_internal_supplier
diff --git a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json
index 3929616..bc5e8a0 100644
--- a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json
+++ b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json
@@ -502,6 +502,7 @@
{
"fieldname": "rejected_warehouse",
"fieldtype": "Link",
+ "ignore_user_permissions": 1,
"label": "Rejected Warehouse",
"no_copy": 1,
"oldfieldname": "rejected_warehouse",
@@ -1058,7 +1059,7 @@
"idx": 1,
"istable": 1,
"links": [],
- "modified": "2023-07-02 18:40:48.152637",
+ "modified": "2023-07-04 17:22:02.830029",
"modified_by": "Administrator",
"module": "Stock",
"name": "Purchase Receipt Item",
diff --git a/erpnext/stock/doctype/warehouse/warehouse.js b/erpnext/stock/doctype/warehouse/warehouse.js
index 746a1cb..3819c0b2 100644
--- a/erpnext/stock/doctype/warehouse/warehouse.js
+++ b/erpnext/stock/doctype/warehouse/warehouse.js
@@ -83,12 +83,6 @@
}
frm.toggle_enable(["is_group", "company"], false);
-
- frappe.dynamic_link = {
- doc: frm.doc,
- fieldname: "name",
- doctype: "Warehouse",
- };
},
});
diff --git a/erpnext/stock/report/batch_item_expiry_status/batch_item_expiry_status.js b/erpnext/stock/report/batch_item_expiry_status/batch_item_expiry_status.js
index a7d7149..48a72a2 100644
--- a/erpnext/stock/report/batch_item_expiry_status/batch_item_expiry_status.js
+++ b/erpnext/stock/report/batch_item_expiry_status/batch_item_expiry_status.js
@@ -9,13 +9,27 @@
"fieldtype": "Date",
"width": "80",
"default": frappe.sys_defaults.year_start_date,
+ "reqd": 1,
},
{
"fieldname":"to_date",
"label": __("To Date"),
"fieldtype": "Date",
"width": "80",
- "default": frappe.datetime.get_today()
+ "default": frappe.datetime.get_today(),
+ "reqd": 1,
+ },
+ {
+ "fieldname":"item",
+ "label": __("Item"),
+ "fieldtype": "Link",
+ "options": "Item",
+ "width": "100",
+ "get_query": function () {
+ return {
+ filters: {"has_batch_no": 1}
+ }
+ }
}
]
}
diff --git a/erpnext/stock/report/batch_item_expiry_status/batch_item_expiry_status.py b/erpnext/stock/report/batch_item_expiry_status/batch_item_expiry_status.py
index ef7d6e6..5661e8b 100644
--- a/erpnext/stock/report/batch_item_expiry_status/batch_item_expiry_status.py
+++ b/erpnext/stock/report/batch_item_expiry_status/batch_item_expiry_status.py
@@ -4,113 +4,86 @@
import frappe
from frappe import _
-from frappe.query_builder.functions import IfNull
-from frappe.utils import cint, getdate
+from frappe.query_builder.functions import Date
def execute(filters=None):
- if not filters:
- filters = {}
+ validate_filters(filters)
- float_precision = cint(frappe.db.get_default("float_precision")) or 3
-
- columns = get_columns(filters)
- item_map = get_item_details(filters)
- iwb_map = get_item_warehouse_batch_map(filters, float_precision)
-
- data = []
- for item in sorted(iwb_map):
- for wh in sorted(iwb_map[item]):
- for batch in sorted(iwb_map[item][wh]):
- qty_dict = iwb_map[item][wh][batch]
-
- data.append(
- [
- item,
- item_map[item]["item_name"],
- item_map[item]["description"],
- wh,
- batch,
- frappe.db.get_value("Batch", batch, "expiry_date"),
- qty_dict.expiry_status,
- ]
- )
+ columns = get_columns()
+ data = get_data(filters)
return columns, data
-def get_columns(filters):
- """return columns based on filters"""
+def validate_filters(filters):
+ if not filters:
+ frappe.throw(_("Please select the required filters"))
- columns = (
- [_("Item") + ":Link/Item:100"]
- + [_("Item Name") + "::150"]
- + [_("Description") + "::150"]
- + [_("Warehouse") + ":Link/Warehouse:100"]
- + [_("Batch") + ":Link/Batch:100"]
- + [_("Expires On") + ":Date:90"]
- + [_("Expiry (In Days)") + ":Int:120"]
- )
-
- return columns
-
-
-def get_stock_ledger_entries(filters):
if not filters.get("from_date"):
frappe.throw(_("'From Date' is required"))
if not filters.get("to_date"):
frappe.throw(_("'To Date' is required"))
- sle = frappe.qb.DocType("Stock Ledger Entry")
- query = (
- frappe.qb.from_(sle)
- .select(sle.item_code, sle.batch_no, sle.warehouse, sle.posting_date, sle.actual_qty)
- .where(
- (sle.is_cancelled == 0)
- & (sle.docstatus < 2)
- & (IfNull(sle.batch_no, "") != "")
- & (sle.posting_date <= filters["to_date"])
- )
- .orderby(sle.item_code, sle.warehouse)
+
+def get_columns():
+ return (
+ [_("Item") + ":Link/Item:150"]
+ + [_("Item Name") + "::150"]
+ + [_("Batch") + ":Link/Batch:150"]
+ + [_("Stock UOM") + ":Link/UOM:100"]
+ + [_("Quantity") + ":Float:100"]
+ + [_("Expires On") + ":Date:100"]
+ + [_("Expiry (In Days)") + ":Int:130"]
)
- return query.run(as_dict=True)
+def get_data(filters):
+ data = []
-def get_item_warehouse_batch_map(filters, float_precision):
- sle = get_stock_ledger_entries(filters)
- iwb_map = {}
-
- from_date = getdate(filters["from_date"])
- to_date = getdate(filters["to_date"])
-
- for d in sle:
- iwb_map.setdefault(d.item_code, {}).setdefault(d.warehouse, {}).setdefault(
- d.batch_no, frappe._dict({"expires_on": None, "expiry_status": None})
+ for batch in get_batch_details(filters):
+ data.append(
+ [
+ batch.item,
+ batch.item_name,
+ batch.name,
+ batch.stock_uom,
+ batch.batch_qty,
+ batch.expiry_date,
+ max((batch.expiry_date - frappe.utils.datetime.date.today()).days, 0)
+ if batch.expiry_date
+ else None,
+ ]
)
- qty_dict = iwb_map[d.item_code][d.warehouse][d.batch_no]
-
- expiry_date_unicode = frappe.db.get_value("Batch", d.batch_no, "expiry_date")
- qty_dict.expires_on = expiry_date_unicode
-
- exp_date = frappe.utils.data.getdate(expiry_date_unicode)
- qty_dict.expires_on = exp_date
-
- expires_in_days = (exp_date - frappe.utils.datetime.date.today()).days
-
- if expires_in_days > 0:
- qty_dict.expiry_status = expires_in_days
- else:
- qty_dict.expiry_status = 0
-
- return iwb_map
+ return data
-def get_item_details(filters):
- item_map = {}
- for d in (frappe.qb.from_("Item").select("name", "item_name", "description")).run(as_dict=True):
- item_map.setdefault(d.name, d)
+def get_batch_details(filters):
+ batch = frappe.qb.DocType("Batch")
+ query = (
+ frappe.qb.from_(batch)
+ .select(
+ batch.name,
+ batch.creation,
+ batch.expiry_date,
+ batch.item,
+ batch.item_name,
+ batch.stock_uom,
+ batch.batch_qty,
+ )
+ .where(
+ (batch.disabled == 0)
+ & (batch.batch_qty > 0)
+ & (
+ (Date(batch.creation) >= filters["from_date"]) & (Date(batch.creation) <= filters["to_date"])
+ )
+ )
+ .orderby(batch.creation)
+ )
- return item_map
+ if filters.get("item"):
+ query = query.where(batch.item == filters["item"])
+
+ return query.run(as_dict=True)
diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py
index 7b1eae5..5abb8e8 100644
--- a/erpnext/stock/stock_ledger.py
+++ b/erpnext/stock/stock_ledger.py
@@ -645,7 +645,7 @@
def update_distinct_item_warehouses(self, dependant_sle):
key = (dependant_sle.item_code, dependant_sle.warehouse)
- val = frappe._dict({"sle": dependant_sle})
+ val = frappe._dict({"sle": dependant_sle, "dependent_voucher_detail_nos": []})
if key not in self.distinct_item_warehouses:
self.distinct_item_warehouses[key] = val
@@ -654,13 +654,26 @@
existing_sle_posting_date = (
self.distinct_item_warehouses[key].get("sle", {}).get("posting_date")
)
+
+ dependent_voucher_detail_nos = self.get_dependent_voucher_detail_nos(key)
+
if getdate(dependant_sle.posting_date) < getdate(existing_sle_posting_date):
val.sle_changed = True
self.distinct_item_warehouses[key] = val
self.new_items_found = True
- elif self.distinct_item_warehouses[key].get("reposting_status"):
- self.distinct_item_warehouses[key] = val
+ elif dependant_sle.voucher_detail_no not in set(dependent_voucher_detail_nos):
+ # Future dependent voucher needs to be repost to get the correct stock value
+ # If dependent voucher has not reposted, then add it to the list
+ dependent_voucher_detail_nos.append(dependant_sle.voucher_detail_no)
self.new_items_found = True
+ val.dependent_voucher_detail_nos = dependent_voucher_detail_nos
+ self.distinct_item_warehouses[key] = val
+
+ def get_dependent_voucher_detail_nos(self, key):
+ if "dependent_voucher_detail_nos" not in self.distinct_item_warehouses[key]:
+ self.distinct_item_warehouses[key].dependent_voucher_detail_nos = []
+
+ return self.distinct_item_warehouses[key].dependent_voucher_detail_nos
def process_sle(self, sle):
# previous sle data for this warehouse
@@ -1370,6 +1383,7 @@
"qty_after_transaction",
"posting_date",
"posting_time",
+ "voucher_detail_no",
"timestamp(posting_date, posting_time) as timestamp",
],
as_dict=1,
diff --git a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.json b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.json
index 9dee3aa..4b3cc83 100644
--- a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.json
+++ b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.json
@@ -251,6 +251,7 @@
"description": "Sets 'Rejected Warehouse' in each row of the Items table.",
"fieldname": "rejected_warehouse",
"fieldtype": "Link",
+ "ignore_user_permissions": 1,
"label": "Rejected Warehouse",
"no_copy": 1,
"options": "Warehouse",
@@ -630,7 +631,7 @@
"in_create": 1,
"is_submittable": 1,
"links": [],
- "modified": "2023-06-03 16:18:39.088518",
+ "modified": "2023-07-06 18:43:16.171842",
"modified_by": "Administrator",
"module": "Subcontracting",
"name": "Subcontracting Receipt",
diff --git a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py
index 4af38e5..60746d9 100644
--- a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py
+++ b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py
@@ -192,13 +192,23 @@
self.total = total_amount
def validate_rejected_warehouse(self):
- if not self.rejected_warehouse:
- for item in self.items:
- if item.rejected_qty:
+ for item in self.items:
+ if flt(item.rejected_qty) and not item.rejected_warehouse:
+ if self.rejected_warehouse:
+ item.rejected_warehouse = self.rejected_warehouse
+
+ if not item.rejected_warehouse:
frappe.throw(
- _("Rejected Warehouse is mandatory against rejected Item {0}").format(item.item_code)
+ _("Row #{0}: Rejected Warehouse is mandatory for the rejected Item {1}").format(
+ item.idx, item.item_code
+ )
)
+ if item.get("rejected_warehouse") and (item.get("rejected_warehouse") == item.get("warehouse")):
+ frappe.throw(
+ _("Row #{0}: Accepted Warehouse and Rejected Warehouse cannot be same").format(item.idx)
+ )
+
def validate_available_qty_for_consumption(self):
for item in self.get("supplied_items"):
precision = item.precision("consumed_qty")
diff --git a/erpnext/subcontracting/doctype/subcontracting_receipt_item/subcontracting_receipt_item.json b/erpnext/subcontracting/doctype/subcontracting_receipt_item/subcontracting_receipt_item.json
index d550b75..d728780 100644
--- a/erpnext/subcontracting/doctype/subcontracting_receipt_item/subcontracting_receipt_item.json
+++ b/erpnext/subcontracting/doctype/subcontracting_receipt_item/subcontracting_receipt_item.json
@@ -254,6 +254,7 @@
"depends_on": "eval: !parent.is_return",
"fieldname": "rejected_warehouse",
"fieldtype": "Link",
+ "ignore_user_permissions": 1,
"label": "Rejected Warehouse",
"no_copy": 1,
"options": "Warehouse",
@@ -494,7 +495,7 @@
"idx": 1,
"istable": 1,
"links": [],
- "modified": "2023-03-12 14:00:41.418681",
+ "modified": "2023-07-06 18:43:45.599761",
"modified_by": "Administrator",
"module": "Subcontracting",
"name": "Subcontracting Receipt Item",
diff --git a/erpnext/support/doctype/service_level_agreement/service_level_agreement.py b/erpnext/support/doctype/service_level_agreement/service_level_agreement.py
index 2a078c4..6c9bc54 100644
--- a/erpnext/support/doctype/service_level_agreement/service_level_agreement.py
+++ b/erpnext/support/doctype/service_level_agreement/service_level_agreement.py
@@ -21,6 +21,7 @@
time_diff_in_seconds,
to_timedelta,
)
+from frappe.utils.caching import redis_cache
from frappe.utils.nestedset import get_ancestors_of
from frappe.utils.safe_exec import get_safe_globals
@@ -209,6 +210,10 @@
def on_update(self):
set_documents_with_active_service_level_agreement()
+ def clear_cache(self):
+ get_sla_doctypes.clear_cache()
+ return super().clear_cache()
+
def create_docfields(self, meta, service_level_agreement_fields):
last_index = len(meta.fields)
@@ -990,6 +995,7 @@
@frappe.whitelist()
+@redis_cache()
def get_sla_doctypes():
doctypes = []
data = frappe.get_all("Service Level Agreement", {"enabled": 1}, ["document_type"], distinct=1)
@@ -998,3 +1004,7 @@
doctypes.append(entry.document_type)
return doctypes
+
+
+def add_sla_doctypes(bootinfo):
+ bootinfo.service_level_agreement_doctypes = get_sla_doctypes()
diff --git a/erpnext/telephony/doctype/call_log/call_log.py b/erpnext/telephony/doctype/call_log/call_log.py
index 7725e71..1d6839c 100644
--- a/erpnext/telephony/doctype/call_log/call_log.py
+++ b/erpnext/telephony/doctype/call_log/call_log.py
@@ -24,12 +24,10 @@
lead_number = self.get("from") if self.is_incoming_call() else self.get("to")
lead_number = strip_number(lead_number)
- contact = get_contact_with_phone_number(strip_number(lead_number))
- if contact:
+ if contact := get_contact_with_phone_number(strip_number(lead_number)):
self.add_link(link_type="Contact", link_name=contact)
- lead = get_lead_with_phone_number(lead_number)
- if lead:
+ if lead := get_lead_with_phone_number(lead_number):
self.add_link(link_type="Lead", link_name=lead)
# Add Employee Name
@@ -70,28 +68,30 @@
self.append("links", {"link_doctype": link_type, "link_name": link_name})
def trigger_call_popup(self):
- if self.is_incoming_call():
- scheduled_employees = get_scheduled_employees_for_popup(self.medium)
- employees = get_employees_with_number(self.to)
- employee_emails = [employee.get("user_id") for employee in employees]
+ if not self.is_incoming_call():
+ return
- # check if employees with matched number are scheduled to receive popup
- emails = set(scheduled_employees).intersection(employee_emails)
+ scheduled_employees = get_scheduled_employees_for_popup(self.medium)
+ employees = get_employees_with_number(self.to)
+ employee_emails = [employee.get("user_id") for employee in employees]
- if frappe.conf.developer_mode:
- self.add_comment(
- text=f"""
+ # check if employees with matched number are scheduled to receive popup
+ emails = set(scheduled_employees).intersection(employee_emails)
+
+ if frappe.conf.developer_mode:
+ self.add_comment(
+ text=f"""
Scheduled Employees: {scheduled_employees}
Matching Employee: {employee_emails}
Show Popup To: {emails}
"""
- )
+ )
- if employee_emails and not emails:
- self.add_comment(text=_("No employee was scheduled for call popup"))
+ if employee_emails and not emails:
+ self.add_comment(text=_("No employee was scheduled for call popup"))
- for email in emails:
- frappe.publish_realtime("show_call_popup", self, user=email)
+ for email in emails:
+ frappe.publish_realtime("show_call_popup", self, user=email)
def update_received_by(self):
if employees := get_employees_with_number(self.get("to")):
@@ -154,8 +154,8 @@
ELSE 0
END
)=0
- """,
- dict(phone_number="%{}".format(number), docname=doc.name, doctype=doc.doctype),
+ """,
+ dict(phone_number=f"%{number}", docname=doc.name, doctype=doc.doctype),
)
for log in logs:
@@ -175,7 +175,7 @@
filters={"parenttype": "Call Log", "link_doctype": doctype, "link_name": docname},
)
- logs = set([log.parent for log in logs])
+ logs = {log.parent for log in logs}
logs = frappe.get_all("Call Log", fields=["*"], filters={"name": ["in", logs]})
diff --git a/erpnext/tests/exotel_test_data.py b/erpnext/tests/exotel_test_data.py
deleted file mode 100644
index 3ad2575..0000000
--- a/erpnext/tests/exotel_test_data.py
+++ /dev/null
@@ -1,122 +0,0 @@
-import frappe
-
-call_initiation_data = frappe._dict(
- {
- "CallSid": "23c162077629863c1a2d7f29263a162m",
- "CallFrom": "09999999991",
- "CallTo": "09999999980",
- "Direction": "incoming",
- "Created": "Wed, 23 Feb 2022 12:31:59",
- "From": "09999999991",
- "To": "09999999988",
- "CurrentTime": "2022-02-23 12:32:02",
- "DialWhomNumber": "09999999999",
- "Status": "busy",
- "EventType": "Dial",
- "AgentEmail": "test_employee_exotel@company.com",
- }
-)
-
-call_end_data = frappe._dict(
- {
- "CallSid": "23c162077629863c1a2d7f29263a162m",
- "CallFrom": "09999999991",
- "CallTo": "09999999980",
- "Direction": "incoming",
- "ForwardedFrom": "null",
- "Created": "Wed, 23 Feb 2022 12:31:59",
- "DialCallDuration": "17",
- "RecordingUrl": "https://s3-ap-southeast-1.amazonaws.com/random.mp3",
- "StartTime": "2022-02-23 12:31:58",
- "EndTime": "1970-01-01 05:30:00",
- "DialCallStatus": "completed",
- "CallType": "completed",
- "DialWhomNumber": "09999999999",
- "ProcessStatus": "null",
- "flow_id": "228040",
- "tenant_id": "67291",
- "From": "09999999991",
- "To": "09999999988",
- "RecordingAvailableBy": "Wed, 23 Feb 2022 12:37:25",
- "CurrentTime": "2022-02-23 12:32:25",
- "OutgoingPhoneNumber": "09999999988",
- "Legs": [
- {
- "Number": "09999999999",
- "Type": "single",
- "OnCallDuration": "10",
- "CallerId": "09999999980",
- "CauseCode": "NORMAL_CLEARING",
- "Cause": "16",
- }
- ],
- }
-)
-
-call_disconnected_data = frappe._dict(
- {
- "CallSid": "d96421addce69e24bdc7ce5880d1162l",
- "CallFrom": "09999999991",
- "CallTo": "09999999980",
- "Direction": "incoming",
- "ForwardedFrom": "null",
- "Created": "Mon, 21 Feb 2022 15:58:12",
- "DialCallDuration": "0",
- "StartTime": "2022-02-21 15:58:12",
- "EndTime": "1970-01-01 05:30:00",
- "DialCallStatus": "canceled",
- "CallType": "client-hangup",
- "DialWhomNumber": "09999999999",
- "ProcessStatus": "null",
- "flow_id": "228040",
- "tenant_id": "67291",
- "From": "09999999991",
- "To": "09999999988",
- "CurrentTime": "2022-02-21 15:58:47",
- "OutgoingPhoneNumber": "09999999988",
- "Legs": [
- {
- "Number": "09999999999",
- "Type": "single",
- "OnCallDuration": "0",
- "CallerId": "09999999980",
- "CauseCode": "RING_TIMEOUT",
- "Cause": "1003",
- }
- ],
- }
-)
-
-call_not_answered_data = frappe._dict(
- {
- "CallSid": "fdb67a2b4b2d057b610a52ef43f81622",
- "CallFrom": "09999999991",
- "CallTo": "09999999980",
- "Direction": "incoming",
- "ForwardedFrom": "null",
- "Created": "Mon, 21 Feb 2022 15:47:02",
- "DialCallDuration": "0",
- "StartTime": "2022-02-21 15:47:02",
- "EndTime": "1970-01-01 05:30:00",
- "DialCallStatus": "no-answer",
- "CallType": "incomplete",
- "DialWhomNumber": "09999999999",
- "ProcessStatus": "null",
- "flow_id": "228040",
- "tenant_id": "67291",
- "From": "09999999991",
- "To": "09999999988",
- "CurrentTime": "2022-02-21 15:47:40",
- "OutgoingPhoneNumber": "09999999988",
- "Legs": [
- {
- "Number": "09999999999",
- "Type": "single",
- "OnCallDuration": "0",
- "CallerId": "09999999980",
- "CauseCode": "RING_TIMEOUT",
- "Cause": "1003",
- }
- ],
- }
-)
diff --git a/erpnext/tests/test_exotel.py b/erpnext/tests/test_exotel.py
deleted file mode 100644
index 9b91414..0000000
--- a/erpnext/tests/test_exotel.py
+++ /dev/null
@@ -1,68 +0,0 @@
-import frappe
-from frappe.contacts.doctype.contact.test_contact import create_contact
-from frappe.tests.test_api import FrappeAPITestCase
-
-from erpnext.setup.doctype.employee.test_employee import make_employee
-
-
-class TestExotel(FrappeAPITestCase):
- @classmethod
- def setUpClass(cls):
- cls.CURRENT_DB_CONNECTION = frappe.db
- cls.test_employee_name = make_employee(
- user="test_employee_exotel@company.com", cell_number="9999999999"
- )
- frappe.db.set_single_value("Exotel Settings", "enabled", 1)
- phones = [{"phone": "+91 9999999991", "is_primary_phone": 0, "is_primary_mobile_no": 1}]
- create_contact(name="Test Contact", salutation="Mr", phones=phones)
- frappe.db.commit()
-
- def test_for_successful_call(self):
- from .exotel_test_data import call_end_data, call_initiation_data
-
- api_method = "handle_incoming_call"
- end_call_api_method = "handle_end_call"
-
- self.emulate_api_call_from_exotel(api_method, call_initiation_data)
- self.emulate_api_call_from_exotel(end_call_api_method, call_end_data)
- call_log = frappe.get_doc("Call Log", call_initiation_data.CallSid)
-
- self.assertEqual(call_log.get("from"), call_initiation_data.CallFrom)
- self.assertEqual(call_log.get("to"), call_initiation_data.DialWhomNumber)
- self.assertEqual(call_log.get("call_received_by"), self.test_employee_name)
- self.assertEqual(call_log.get("status"), "Completed")
-
- def test_for_disconnected_call(self):
- from .exotel_test_data import call_disconnected_data
-
- api_method = "handle_missed_call"
- self.emulate_api_call_from_exotel(api_method, call_disconnected_data)
- call_log = frappe.get_doc("Call Log", call_disconnected_data.CallSid)
- self.assertEqual(call_log.get("from"), call_disconnected_data.CallFrom)
- self.assertEqual(call_log.get("to"), call_disconnected_data.DialWhomNumber)
- self.assertEqual(call_log.get("call_received_by"), self.test_employee_name)
- self.assertEqual(call_log.get("status"), "Canceled")
-
- def test_for_call_not_answered(self):
- from .exotel_test_data import call_not_answered_data
-
- api_method = "handle_missed_call"
- self.emulate_api_call_from_exotel(api_method, call_not_answered_data)
- call_log = frappe.get_doc("Call Log", call_not_answered_data.CallSid)
- self.assertEqual(call_log.get("from"), call_not_answered_data.CallFrom)
- self.assertEqual(call_log.get("to"), call_not_answered_data.DialWhomNumber)
- self.assertEqual(call_log.get("call_received_by"), self.test_employee_name)
- self.assertEqual(call_log.get("status"), "No Answer")
-
- def emulate_api_call_from_exotel(self, api_method, data):
- self.post(
- f"/api/method/erpnext.erpnext_integrations.exotel_integration.{api_method}",
- data=frappe.as_json(data),
- content_type="application/json",
- )
- # restart db connection to get latest data
- frappe.connect()
-
- @classmethod
- def tearDownClass(cls):
- frappe.db = cls.CURRENT_DB_CONNECTION
diff --git a/erpnext/translations/de.csv b/erpnext/translations/de.csv
index 5f0a8dc..e30a5d0 100644
--- a/erpnext/translations/de.csv
+++ b/erpnext/translations/de.csv
@@ -1219,7 +1219,7 @@
Hold,Anhalten,
Hold Invoice,Rechnung zurückhalten,
Holiday,Urlaub,
-Holiday List,Urlaubsübersicht,
+Holiday List,Feiertagsliste,
Hotel Rooms of type {0} are unavailable on {1},Hotelzimmer vom Typ {0} sind auf {1} nicht verfügbar,
Hotels,Hotels,
Hourly,Stündlich,
@@ -3317,7 +3317,7 @@
Working,In Bearbeitung,
Working Hours,Arbeitszeit,
Workstation,Arbeitsplatz,
-Workstation is closed on the following dates as per Holiday List: {0},Arbeitsplatz ist an folgenden Tagen gemäß der Urlaubsliste geschlossen: {0},
+Workstation is closed on the following dates as per Holiday List: {0},Arbeitsplatz ist an folgenden Tagen gemäß der Feiertagsliste geschlossen: {0},
Wrapping up,Aufwickeln,
Wrong Password,Falsches Passwort,
Year start date or end date is overlapping with {0}. To avoid please set company,"Jahresbeginn oder Enddatum überlappt mit {0}. Bitte ein Unternehmen wählen, um dies zu verhindern",
@@ -3583,6 +3583,7 @@
Activity,Aktivität,
Add / Manage Email Accounts.,Hinzufügen/Verwalten von E-Mail-Konten,
Add Child,Unterpunkt hinzufügen,
+Add Local Holidays,Lokale Feiertage hinzufügen,
Add Multiple,Mehrere hinzufügen,
Add Participants,Teilnehmer hinzufügen,
Add to Featured Item,Zum empfohlenen Artikel hinzufügen,
@@ -4046,6 +4047,7 @@
Stock Value ({0}) and Account Balance ({1}) are out of sync for account {2} and it's linked warehouses.,Der Bestandswert ({0}) und der Kontostand ({1}) sind für das Konto {2} und die verknüpften Lager nicht synchron.,
Stores - {0},Stores - {0},
Student with email {0} does not exist,Der Student mit der E-Mail-Adresse {0} existiert nicht,
+Subdivision,Teilgebiet,
Submit Review,Bewertung abschicken,
Submitted,Gebucht,
Supplier Addresses And Contacts,Lieferanten-Adressen und Kontaktdaten,
@@ -4192,6 +4194,7 @@
No students Found,Keine Schüler gefunden,
Not in Stock,Nicht lagernd,
Please select a Customer,Bitte wählen Sie einen Kunden aus,
+Please select a country,Bitte wählen Sie ein Land aus,
Printed On,Gedruckt auf,
Received From,Erhalten von,
Sales Person,Verkäufer,
@@ -6497,7 +6500,7 @@
Attendance and Leave Details,Anwesenheits- und Urlaubsdetails,
Leave Policy,Urlaubsrichtlinie,
Attendance Device ID (Biometric/RF tag ID),Anwesenheitsgeräte-ID (biometrische / RF-Tag-ID),
-Applicable Holiday List,Geltende Urlaubsliste,
+Applicable Holiday List,Geltende Feiertagsliste,
Default Shift,Standardverschiebung,
Salary Details,Gehaltsdetails,
Salary Mode,Gehaltsmodus,
@@ -6662,12 +6665,12 @@
Expense Claim Detail,Auslage,
Expense Date,Datum der Auslage,
Expense Claim Type,Art der Auslagenabrechnung,
-Holiday List Name,Urlaubslistenname,
-Total Holidays,Insgesamt Feiertage,
-Add Weekly Holidays,Wöchentliche Feiertage hinzufügen,
+Holiday List Name,Name der Feiertagsliste,
+Total Holidays,Insgesamt freie Tage,
+Add Weekly Holidays,Wöchentlich freie Tage hinzufügen,
Weekly Off,Wöchentlich frei,
-Add to Holidays,Zu Feiertagen hinzufügen,
-Holidays,Ferien,
+Add to Holidays,Zu freien Tagen hinzufügen,
+Holidays,Arbeitsfreie Tage,
Clear Table,Tabelle leeren,
HR Settings,Einstellungen zum Modul Personalwesen,
Employee Settings,Mitarbeitereinstellungen,
@@ -6777,7 +6780,7 @@
Is Carry Forward,Ist Übertrag,
Is Expired,Ist abgelaufen,
Is Leave Without Pay,Ist unbezahlter Urlaub,
-Holiday List for Optional Leave,Urlaubsliste für optionalen Urlaub,
+Holiday List for Optional Leave,Feiertagsliste für optionalen Urlaub,
Leave Allocations,Zuteilungen verlassen,
Leave Policy Details,Urlaubsrichtliniendetails,
Leave Policy Detail,Urlaubsrichtliniendetail,
@@ -7646,7 +7649,7 @@
Change Abbreviation,Abkürzung ändern,
Parent Company,Muttergesellschaft,
Default Values,Standardwerte,
-Default Holiday List,Standard-Urlaubsliste,
+Default Holiday List,Standard Feiertagsliste,
Default Selling Terms,Standardverkaufsbedingungen,
Default Buying Terms,Standard-Einkaufsbedingungen,
Create Chart Of Accounts Based On,"Kontenplan erstellen, basierend auf",
diff --git a/pyproject.toml b/pyproject.toml
index 012ffb1..3e0dfb2 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -13,6 +13,7 @@
"Unidecode~=1.3.6",
"barcodenumber~=0.5.0",
"rapidfuzz~=2.15.0",
+ "holidays~=0.28",
# integration dependencies
"gocardless-pro~=1.22.0",