[fix] warehouse validation for parent_account
diff --git a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js
index 726f767..6058cb4 100644
--- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js
+++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js
@@ -39,6 +39,7 @@
refresh: function(frm, cdt, cdn) {
if (frm.doc.docstatus === 1) {
+ frm.dashboard.show_dashboard();
frm.add_custom_button(__("Make"),
function(){ frm.trigger("make_suppplier_quotation") }, __("Supplier Quotation"));
diff --git a/erpnext/buying/doctype/request_for_quotation/request_for_quotation_links.py b/erpnext/buying/doctype/request_for_quotation/request_for_quotation_links.py
new file mode 100644
index 0000000..809b38c
--- /dev/null
+++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation_links.py
@@ -0,0 +1,14 @@
+from frappe import _
+
+links = {
+ 'fieldname': 'supplier_quotation',
+ # 'non_standard_fieldnames': {
+ # 'Purchase Order': 'prevdoc_detail_docname',
+ # },
+ 'transactions': [
+ {
+ 'label': _('Related Documents'),
+ 'items': ['Supplier Quotation', 'Purchase Order']
+ },
+ ]
+}
\ No newline at end of file
diff --git a/erpnext/stock/doctype/material_request/material_request.js b/erpnext/stock/doctype/material_request/material_request.js
index 1f0fe34..1b1a56b 100644
--- a/erpnext/stock/doctype/material_request/material_request.js
+++ b/erpnext/stock/doctype/material_request/material_request.js
@@ -43,8 +43,6 @@
var me = this;
this._super();
- this.frm.dashboard.reset();
-
if(doc.docstatus==0) {
cur_frm.add_custom_button(__("Get Items from BOM"),
cur_frm.cscript.get_items_from_bom, "icon-sitemap", "btn-default");
diff --git a/erpnext/stock/doctype/material_request/material_request_links.py b/erpnext/stock/doctype/material_request/material_request_links.py
index 7f12490..abd27dc 100644
--- a/erpnext/stock/doctype/material_request/material_request_links.py
+++ b/erpnext/stock/doctype/material_request/material_request_links.py
@@ -3,12 +3,11 @@
links = {
'fieldname': 'material_request',
'non_standard_fieldnames': {
- 'Supplier Quotation': 'prevdoc_detail_docname',
'Purchase Order': 'prevdoc_detail_docname',
},
'transactions': [
{
- 'label': _('Documents'),
+ 'label': _('Related Documents'),
'items': ['Request for Quotation', 'Supplier Quotation', 'Purchase Order']
},
]
diff --git a/erpnext/stock/doctype/warehouse/warehouse.py b/erpnext/stock/doctype/warehouse/warehouse.py
index adef7ce..efb5951 100644
--- a/erpnext/stock/doctype/warehouse/warehouse.py
+++ b/erpnext/stock/doctype/warehouse/warehouse.py
@@ -94,6 +94,11 @@
frappe.db.set_value("Warehouse", self.name, "create_account_under", parent_account[0][0])
self.create_account_under = parent_account[0][0]
else:
+ # did not find parent, add it to root Assets
+ # let the user figure.
+ self.create_account_under = frappe.db.get_all('Account',
+ filters = {'company': self.company, 'is_group': 1,
+ 'parent_account': '', 'root_type': 'Asset'}, limit=1)[0].name
frappe.throw(_("Please enter parent account group for warehouse {0}").format(self.name))
elif frappe.db.get_value("Account", self.create_account_under, "company") != self.company:
frappe.throw(_("Warehouse {0}: Parent account {1} does not bolong to the company {2}")
@@ -124,11 +129,11 @@
throw(_("Child warehouse exists for this warehouse. You can not delete this warehouse."))
self.update_nsm_model()
-
+
def check_if_sle_exists(self):
return frappe.db.sql("""select name from `tabStock Ledger Entry`
where warehouse = %s""", self.name)
-
+
def check_if_child_exists(self):
return frappe.db.sql("""select name from `tabWarehouse`
where parent_warehouse = %s""", self.name)
@@ -202,7 +207,7 @@
frappe.db.set_value("Stock Settings", None, "allow_negative_stock", existing_allow_negative_stock)
frappe.db.auto_commit_on_many_writes = 0
-
+
def convert_to_group_or_ledger(self):
if self.is_group:
self.convert_to_ledger()
@@ -220,11 +225,11 @@
doc = frappe.get_doc("Account", account_name)
doc.warehouse = self.name
doc.convert_group_to_ledger()
-
+
self.is_group = 0
self.save()
return 1
-
+
def convert_to_group(self):
if self.check_if_sle_exists():
throw(_("Warehouses with existing transaction can not be converted to group."))
@@ -255,7 +260,7 @@
is_group as expandable
from `tab{doctype}`
where docstatus < 2
- and ifnull(`{parent_field}`,'') = %s
+ and ifnull(`{parent_field}`,'') = %s
and (`company` = %s or company is null or company = '')
order by name""".format(doctype=frappe.db.escape(doctype),
parent_field=frappe.db.escape(parent_field)), (parent, company), as_dict=1)
@@ -292,4 +297,3 @@
def convert_to_group_or_ledger():
args = frappe.form_dict
return frappe.get_doc("Warehouse", args.docname).convert_to_group_or_ledger()
-
\ No newline at end of file