Merge pull request #26071 from Anurag810/training_event_fixes_2.0
fix: Training event
diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json
index 2735b1c..0ff7230 100644
--- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json
+++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json
@@ -257,9 +257,10 @@
},
{
"default": "1",
+ "description": "If enabled, ledger entries will be posted for change amount in POS transactions",
"fieldname": "post_change_gl_entries",
"fieldtype": "Check",
- "label": "Post Ledger Entries for Given Change"
+ "label": "Change Ledger Entries for Change Amount"
}
],
"icon": "icon-cog",
@@ -267,7 +268,7 @@
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
- "modified": "2021-05-25 12:34:05.858669",
+ "modified": "2021-06-16 13:14:45.739107",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Accounts Settings",
diff --git a/erpnext/accounts/doctype/dunning/dunning.py b/erpnext/accounts/doctype/dunning/dunning.py
index 1a6dbed..c6c6892 100644
--- a/erpnext/accounts/doctype/dunning/dunning.py
+++ b/erpnext/accounts/doctype/dunning/dunning.py
@@ -86,7 +86,7 @@
for reference in doc.references:
if reference.reference_doctype == 'Sales Invoice' and reference.outstanding_amount <= 0:
dunnings = frappe.get_list('Dunning', filters={
- 'sales_invoice': reference.reference_name, 'status': ('!=', 'Resolved')})
+ 'sales_invoice': reference.reference_name, 'status': ('!=', 'Resolved')}, ignore_permissions=True)
for dunning in dunnings:
frappe.db.set_value("Dunning", dunning.name, "status", 'Resolved')
@@ -96,7 +96,7 @@
grand_total = 0
if rate_of_interest:
interest_per_year = flt(outstanding_amount) * flt(rate_of_interest) / 100
- interest_amount = (interest_per_year * cint(overdue_days)) / 365
+ interest_amount = (interest_per_year * cint(overdue_days)) / 365
grand_total = flt(outstanding_amount) + flt(interest_amount) + flt(dunning_fee)
dunning_amount = flt(interest_amount) + flt(dunning_fee)
return {
diff --git a/erpnext/accounts/doctype/payment_terms_template/payment_terms_template.py b/erpnext/accounts/doctype/payment_terms_template/payment_terms_template.py
index 80e3348..39627eb 100644
--- a/erpnext/accounts/doctype/payment_terms_template/payment_terms_template.py
+++ b/erpnext/accounts/doctype/payment_terms_template/payment_terms_template.py
@@ -26,7 +26,7 @@
def check_duplicate_terms(self):
terms = []
for term in self.terms:
- term_info = (term.credit_days, term.credit_months, term.due_date_based_on)
+ term_info = (term.payment_term, term.credit_days, term.credit_months, term.due_date_based_on)
if term_info in terms:
frappe.msgprint(
_('The Payment Term at row {0} is possibly a duplicate.').format(term.idx),
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 10e1c73..8a55ff8 100644
--- a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json
+++ b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json
@@ -272,7 +272,7 @@
"fieldname": "rate",
"fieldtype": "Currency",
"in_list_view": 1,
- "label": "Rate ",
+ "label": "Rate",
"oldfieldname": "import_rate",
"oldfieldtype": "Currency",
"options": "currency",
@@ -854,7 +854,7 @@
"idx": 1,
"istable": 1,
"links": [],
- "modified": "2021-03-30 09:02:39.256602",
+ "modified": "2021-06-16 19:57:03.101571",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Purchase Invoice Item",
diff --git a/erpnext/accounts/report/general_ledger/general_ledger.js b/erpnext/accounts/report/general_ledger/general_ledger.js
index a8e5530..4a551b8 100644
--- a/erpnext/accounts/report/general_ledger/general_ledger.js
+++ b/erpnext/accounts/report/general_ledger/general_ledger.js
@@ -36,16 +36,12 @@
{
"fieldname":"account",
"label": __("Account"),
- "fieldtype": "Link",
+ "fieldtype": "MultiSelectList",
"options": "Account",
- "get_query": function() {
- var company = frappe.query_report.get_filter_value('company');
- return {
- "doctype": "Account",
- "filters": {
- "company": company,
- }
- }
+ get_data: function(txt) {
+ return frappe.db.get_link_options('Account', txt, {
+ company: frappe.query_report.get_filter_value("company")
+ });
}
},
{
diff --git a/erpnext/accounts/report/general_ledger/general_ledger.py b/erpnext/accounts/report/general_ledger/general_ledger.py
index 562df4f..03808c3 100644
--- a/erpnext/accounts/report/general_ledger/general_ledger.py
+++ b/erpnext/accounts/report/general_ledger/general_ledger.py
@@ -49,8 +49,12 @@
if not filters.get("from_date") and not filters.get("to_date"):
frappe.throw(_("{0} and {1} are mandatory").format(frappe.bold(_("From Date")), frappe.bold(_("To Date"))))
- if filters.get("account") and not account_details.get(filters.account):
- frappe.throw(_("Account {0} does not exists").format(filters.account))
+ for account in filters.account:
+ if not account_details.get(account):
+ frappe.throw(_("Account {0} does not exists").format(account))
+
+ if filters.get('account'):
+ filters.account = frappe.parse_json(filters.get('account'))
if (filters.get("account") and filters.get("group_by") == _('Group by Account')
and account_details[filters.account].is_group == 0):
@@ -87,7 +91,19 @@
account_currency = None
if filters.get("account"):
- account_currency = get_account_currency(filters.account)
+ if len(filters.get("account")) == 1:
+ account_currency = get_account_currency(filters.account[0])
+ else:
+ currency = get_account_currency(filters.account[0])
+ is_same_account_currency = True
+ for account in filters.get("account"):
+ if get_account_currency(account) != currency:
+ is_same_account_currency = False
+ break
+
+ if is_same_account_currency:
+ account_currency = currency
+
elif filters.get("party"):
gle_currency = frappe.db.get_value(
"GL Entry", {
@@ -205,10 +221,10 @@
def get_conditions(filters):
conditions = []
+
if filters.get("account") and not filters.get("include_dimensions"):
- lft, rgt = frappe.db.get_value("Account", filters["account"], ["lft", "rgt"])
- conditions.append("""account in (select name from tabAccount
- where lft>=%s and rgt<=%s and docstatus<2)""" % (lft, rgt))
+ filters.account = get_accounts_with_children(filters.account)
+ conditions.append("account in %(account)s")
if filters.get("cost_center"):
filters.cost_center = get_cost_centers_with_children(filters.cost_center)
@@ -266,6 +282,20 @@
return "and {}".format(" and ".join(conditions)) if conditions else ""
+def get_accounts_with_children(accounts):
+ if not isinstance(accounts, list):
+ accounts = [d.strip() for d in accounts.strip().split(',') if d]
+
+ all_accounts = []
+ for d in accounts:
+ if frappe.db.exists("Account", d):
+ lft, rgt = frappe.db.get_value("Account", d, ["lft", "rgt"])
+ children = frappe.get_all("Account", filters={"lft": [">=", lft], "rgt": ["<=", rgt]})
+ all_accounts += [c.name for c in children]
+ else:
+ frappe.throw(_("Account: {0} does not exist").format(d))
+
+ return list(set(all_accounts))
def get_data_with_opening_closing(filters, account_details, accounting_dimensions, gl_entries):
data = []
diff --git a/erpnext/public/scss/point-of-sale.scss b/erpnext/public/scss/point-of-sale.scss
index 9bdaa8d..c77b2ce 100644
--- a/erpnext/public/scss/point-of-sale.scss
+++ b/erpnext/public/scss/point-of-sale.scss
@@ -806,6 +806,9 @@
display: none;
float: right;
font-weight: 700;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
}
> .cash-shortcuts {
@@ -829,6 +832,11 @@
}
}
}
+
+ > .loyalty-card {
+ display: flex;
+ flex-direction: column;
+ }
}
}
@@ -1134,4 +1142,4 @@
}
}
}
-}
\ No newline at end of file
+}
diff --git a/erpnext/selling/page/point_of_sale/pos_payment.js b/erpnext/selling/page/point_of_sale/pos_payment.js
index 156fb77..c484873 100644
--- a/erpnext/selling/page/point_of_sale/pos_payment.js
+++ b/erpnext/selling/page/point_of_sale/pos_payment.js
@@ -481,7 +481,7 @@
const amount = doc.loyalty_amount > 0 ? format_currency(doc.loyalty_amount, doc.currency) : '';
this.$payment_modes.append(
`<div class="payment-mode-wrapper">
- <div class="mode-of-payment" data-mode="loyalty-amount" data-payment-type="loyalty-amount">
+ <div class="mode-of-payment loyalty-card" data-mode="loyalty-amount" data-payment-type="loyalty-amount">
Redeem Loyalty Points
<div class="loyalty-amount-amount pay-amount">${amount}</div>
<div class="loyalty-amount-name">${loyalty_program}</div>
@@ -563,4 +563,4 @@
toggle_component(show) {
show ? this.$component.css('display', 'flex') : this.$component.css('display', 'none');
}
-};
\ No newline at end of file
+};
diff --git a/erpnext/setup/setup_wizard/data/country_wise_tax.json b/erpnext/setup/setup_wizard/data/country_wise_tax.json
index ec9a6d6..daaa626 100644
--- a/erpnext/setup/setup_wizard/data/country_wise_tax.json
+++ b/erpnext/setup/setup_wizard/data/country_wise_tax.json
@@ -1867,7 +1867,7 @@
"South Africa": {
"South Africa Tax": {
"account_name": "VAT",
- "tax_rate": 14.00
+ "tax_rate": 15.00
}
},
diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py
index 306df99..2b51c1a 100644
--- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py
+++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py
@@ -473,6 +473,13 @@
else:
self._submit()
+ def cancel(self):
+ if len(self.items) > 100:
+ msgprint(_("The task has been enqueued as a background job. In case there is any issue on processing in background, the system will add a comment about the error on this Stock Reconciliation and revert to the Submitted stage"))
+ self.queue_action('cancel', timeout=2000)
+ else:
+ self._cancel()
+
@frappe.whitelist()
def get_items(warehouse, posting_date, posting_time, company):
lft, rgt = frappe.db.get_value("Warehouse", warehouse, ["lft", "rgt"])
diff --git a/erpnext/stock/doctype/warehouse/test_warehouse.py b/erpnext/stock/doctype/warehouse/test_warehouse.py
index 95478f6..e3981c9 100644
--- a/erpnext/stock/doctype/warehouse/test_warehouse.py
+++ b/erpnext/stock/doctype/warehouse/test_warehouse.py
@@ -11,6 +11,7 @@
import erpnext
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
from erpnext.accounts.doctype.account.test_account import get_inventory_account, create_account
+from erpnext.stock.doctype.item.test_item import create_item
test_records = frappe.get_test_records('Warehouse')
@@ -92,6 +93,39 @@
self.assertTrue(frappe.db.get_value("Warehouse",
filters={"account": "Test Warehouse for Merging 2 - TCP1"}))
+ def test_unlinking_warehouse_from_item_defaults(self):
+ company = "_Test Company"
+
+ warehouse_names = [f'_Test Warehouse {i} for Unlinking' for i in range(2)]
+ warehouse_ids = []
+ for warehouse in warehouse_names:
+ warehouse_id = create_warehouse(warehouse, company=company)
+ warehouse_ids.append(warehouse_id)
+
+ item_names = [f'_Test Item {i} for Unlinking' for i in range(2)]
+ for item, warehouse in zip(item_names, warehouse_ids):
+ create_item(item, warehouse=warehouse, company=company)
+
+ # Delete warehouses
+ for warehouse in warehouse_ids:
+ frappe.delete_doc("Warehouse", warehouse)
+
+ # Check Item existance
+ for item in item_names:
+ self.assertTrue(
+ bool(frappe.db.exists("Item", item)),
+ f"{item} doesn't exist"
+ )
+
+ item_doc = frappe.get_doc("Item", item)
+ for item_default in item_doc.item_defaults:
+ self.assertNotIn(
+ item_default.default_warehouse,
+ warehouse_ids,
+ f"{item} linked to {item_default.default_warehouse} in {warehouse_ids}."
+ )
+
+
def create_warehouse(warehouse_name, properties=None, company=None):
if not company:
company = "_Test Company"
diff --git a/erpnext/stock/doctype/warehouse/warehouse.py b/erpnext/stock/doctype/warehouse/warehouse.py
index 2062bdd..3abc139 100644
--- a/erpnext/stock/doctype/warehouse/warehouse.py
+++ b/erpnext/stock/doctype/warehouse/warehouse.py
@@ -54,6 +54,7 @@
throw(_("Child warehouse exists for this warehouse. You can not delete this warehouse."))
self.update_nsm_model()
+ self.unlink_from_items()
def check_if_sle_exists(self):
return frappe.db.sql("""select name from `tabStock Ledger Entry`
@@ -138,6 +139,12 @@
self.save()
return 1
+ def unlink_from_items(self):
+ frappe.db.sql("""
+ update `tabItem Default`
+ set default_warehouse=NULL
+ where default_warehouse=%s""", self.name)
+
@frappe.whitelist()
def get_children(doctype, parent=None, company=None, is_root=False):
if is_root:
diff --git a/erpnext/support/doctype/issue/issue.json b/erpnext/support/doctype/issue/issue.json
index bc29821..14712f8 100644
--- a/erpnext/support/doctype/issue/issue.json
+++ b/erpnext/support/doctype/issue/issue.json
@@ -166,7 +166,7 @@
"options": "Service Level Agreement"
},
{
- "depends_on": "eval: doc.status != 'Replied';",
+ "depends_on": "eval: doc.status != 'Replied' && doc.service_level_agreement;",
"fieldname": "response_by",
"fieldtype": "Datetime",
"label": "Response By",
@@ -180,7 +180,7 @@
"read_only": 1
},
{
- "depends_on": "eval: doc.status != 'Replied';",
+ "depends_on": "eval: doc.status != 'Replied' && doc.service_level_agreement;",
"fieldname": "resolution_by",
"fieldtype": "Datetime",
"label": "Resolution By",
@@ -410,7 +410,7 @@
"icon": "fa fa-ticket",
"idx": 7,
"links": [],
- "modified": "2021-05-26 10:49:07.574769",
+ "modified": "2021-06-10 03:22:27.098898",
"modified_by": "Administrator",
"module": "Support",
"name": "Issue",
diff --git a/erpnext/support/doctype/issue/issue.py b/erpnext/support/doctype/issue/issue.py
index b068363..9c69deb 100644
--- a/erpnext/support/doctype/issue/issue.py
+++ b/erpnext/support/doctype/issue/issue.py
@@ -29,6 +29,9 @@
self.update_status()
self.set_lead_contact(self.raised_by)
+ if not self.service_level_agreement:
+ self.reset_sla_fields()
+
def on_update(self):
# Add a communication in the issue timeline
if self.flags.create_communication and self.via_customer_portal:
@@ -54,6 +57,13 @@
self.company = frappe.db.get_value("Lead", self.lead, "company") or \
frappe.db.get_default("Company")
+ def reset_sla_fields(self):
+ self.agreement_status = ""
+ self.response_by = ""
+ self.resolution_by = ""
+ self.response_by_variance = 0
+ self.resolution_by_variance = 0
+
def update_status(self):
status = frappe.db.get_value("Issue", self.name, "status")
if self.status != "Open" and status == "Open" and not self.first_responded_on:
@@ -511,4 +521,4 @@
Converts datetime.time(10, 36, 55, 961454) to datetime.timedelta(seconds=38215)
"""
import datetime
- return datetime.timedelta(hours=time.hour, minutes=time.minute, seconds=time.second)
\ No newline at end of file
+ return datetime.timedelta(hours=time.hour, minutes=time.minute, seconds=time.second)