Merge pull request #20381 from nextchamp-saqib/small-fix-asset
fix: tuple index out of range error
diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py
index cf1748f..1407d5f 100644
--- a/erpnext/accounts/doctype/account/account.py
+++ b/erpnext/accounts/doctype/account/account.py
@@ -95,29 +95,29 @@
# ignore validation while creating new compnay or while syncing to child companies
if frappe.local.flags.ignore_root_company_validation or self.flags.ignore_root_company_validation:
return
-
ancestors = get_root_company(self.company)
if ancestors:
if frappe.get_value("Company", self.company, "allow_account_creation_against_child_company"):
return
-
if not frappe.db.get_value("Account",
{'account_name': self.account_name, 'company': ancestors[0]}, 'name'):
frappe.throw(_("Please add the account to root level Company - %s" % ancestors[0]))
else:
descendants = get_descendants_of('Company', self.company)
if not descendants: return
-
parent_acc_name_map = {}
parent_acc_name, parent_acc_number = frappe.db.get_value('Account', self.parent_account, \
["account_name", "account_number"])
- for d in frappe.db.get_values('Account',
- { "company": ["in", descendants], "account_name": parent_acc_name,
- "account_number": parent_acc_number },
- ["company", "name"], as_dict=True):
+ filters = {
+ "company": ["in", descendants],
+ "account_name": parent_acc_name,
+ }
+ if parent_acc_number:
+ filters["account_number"] = parent_acc_number
+
+ for d in frappe.db.get_values('Account', filters=filters, fieldname=["company", "name"], as_dict=True):
parent_acc_name_map[d["company"]] = d["name"]
if not parent_acc_name_map: return
-
self.create_account_for_child_company(parent_acc_name_map, descendants, parent_acc_name)
def validate_group_or_ledger(self):
@@ -175,7 +175,6 @@
filters["account_number"] = self.account_number
child_account = frappe.db.get_value("Account", filters, 'name')
-
if not child_account:
doc = frappe.copy_doc(self)
doc.flags.ignore_root_company_validation = True
diff --git a/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.py b/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.py
index 34070b0..362efef 100644
--- a/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.py
+++ b/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.py
@@ -96,7 +96,11 @@
if parent_account == account_name == child:
return [parent_account]
elif account_name == child:
- return [child] + return_parent(data, parent_account)
+ parent_account_list = return_parent(data, parent_account)
+ if not parent_account_list:
+ frappe.throw(_("The parent account {0} does not exists")
+ .format(parent_account))
+ return [child] + parent_account_list
charts_map, paths = {}, []
diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index 8cfde8c..51ab48a 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -968,7 +968,7 @@
qty: function(doc, cdt, cdn) {
let item = frappe.get_doc(cdt, cdn);
- this.conversion_factor(doc, cdt, cdn, false);
+ this.conversion_factor(doc, cdt, cdn, true);
this.apply_pricing_rule(item, true);
},
diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py
index 9ebef0d..d8667f6 100644
--- a/erpnext/selling/doctype/quotation/quotation.py
+++ b/erpnext/selling/doctype/quotation/quotation.py
@@ -182,8 +182,12 @@
return doclist
def set_expired_status():
- frappe.db.sql("""UPDATE `tabQuotation` SET `status` = 'Expired'
- WHERE `status` != "Expired" AND `valid_till` < %s""", (nowdate()))
+ frappe.db.sql("""
+ UPDATE
+ `tabQuotation` SET `status` = 'Expired'
+ WHERE
+ `status` not in ('Ordered', 'Expired', 'Lost', 'Cancelled') AND `valid_till` < %s
+ """, (nowdate()))
@frappe.whitelist()
def make_sales_invoice(source_name, target_doc=None):
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index a43ac85..3607626 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -484,7 +484,7 @@
if self.work_order \
and frappe.db.get_single_value("Manufacturing Settings", "material_consumption"):
bom_items = self.get_bom_raw_materials(d.transfer_qty)
- raw_material_cost = sum([flt(d.qty)*flt(d.rate) for d in bom_items.values()])
+ raw_material_cost = sum([flt(row.qty)*flt(row.rate) for row in bom_items.values()])
if raw_material_cost:
d.basic_rate = flt((raw_material_cost - scrap_material_cost) / flt(d.transfer_qty), d.precision("basic_rate"))
@@ -614,7 +614,7 @@
if self.work_order and self.purpose == "Manufacture":
allowed_qty = wo_qty + (allowance_percentage/100 * wo_qty)
if self.fg_completed_qty > allowed_qty:
- frappe.throw(_("For quantity {0} should not be grater than work order quantity {1}")
+ frappe.throw(_("For quantity {0} should not be greater than work order quantity {1}")
.format(flt(self.fg_completed_qty), wo_qty))
if production_item not in items_with_target_warehouse: