[fix] wareehouse nestedset fix if company not associated with warehouse
This commit is contained in:
parent
d7d878b6db
commit
b8a57a4b4d
@ -18,7 +18,7 @@ def execute():
|
|||||||
|
|
||||||
def set_parent_to_warehouse(company):
|
def set_parent_to_warehouse(company):
|
||||||
frappe.db.sql(""" update tabWarehouse set parent_warehouse = %s
|
frappe.db.sql(""" update tabWarehouse set parent_warehouse = %s
|
||||||
where (is_group = 0 or is_group is null or is_group = '') and company = %s
|
where (is_group = 0 or is_group is null or is_group = '') and ifnull(company, '') = %s
|
||||||
""",("{0} - {1}".format(_("All Warehouses"), company.abbr), company.name))
|
""",("{0} - {1}".format(_("All Warehouses"), company.abbr), company.name))
|
||||||
|
|
||||||
rebuild_tree("Warehouse", "parent_warehouse")
|
rebuild_tree("Warehouse", "parent_warehouse")
|
||||||
|
@ -11,9 +11,12 @@ class Warehouse(NestedSet):
|
|||||||
nsm_parent_field = 'parent_warehouse'
|
nsm_parent_field = 'parent_warehouse'
|
||||||
|
|
||||||
def autoname(self):
|
def autoname(self):
|
||||||
|
if self.company:
|
||||||
suffix = " - " + frappe.db.get_value("Company", self.company, "abbr")
|
suffix = " - " + frappe.db.get_value("Company", self.company, "abbr")
|
||||||
if not self.warehouse_name.endswith(suffix):
|
if not self.warehouse_name.endswith(suffix):
|
||||||
self.name = self.warehouse_name + suffix
|
self.name = self.warehouse_name + suffix
|
||||||
|
else:
|
||||||
|
self.name = self.warehouse_name
|
||||||
|
|
||||||
def onload(self):
|
def onload(self):
|
||||||
'''load account name for General Ledger Report'''
|
'''load account name for General Ledger Report'''
|
||||||
@ -31,6 +34,7 @@ class Warehouse(NestedSet):
|
|||||||
|
|
||||||
def update_parent_account(self):
|
def update_parent_account(self):
|
||||||
if not getattr(self, "__islocal", None) \
|
if not getattr(self, "__islocal", None) \
|
||||||
|
and cint(frappe.defaults.get_global_default("auto_accounting_for_stock")) \
|
||||||
and (self.create_account_under != frappe.db.get_value("Warehouse", self.name, "create_account_under")):
|
and (self.create_account_under != frappe.db.get_value("Warehouse", self.name, "create_account_under")):
|
||||||
|
|
||||||
self.validate_parent_account()
|
self.validate_parent_account()
|
||||||
@ -251,9 +255,10 @@ def get_children():
|
|||||||
is_group as expandable
|
is_group as expandable
|
||||||
from `tab{doctype}`
|
from `tab{doctype}`
|
||||||
where docstatus < 2
|
where docstatus < 2
|
||||||
and ifnull(`{parent_field}`,'') = %s and `company` = %s
|
and ifnull(`{parent_field}`,'') = %s
|
||||||
order by name""".format(doctype=frappe.db.escape(doctype), parent_field=frappe.db.escape(parent_field)),
|
and (`company` = %s or company is null or company = '')
|
||||||
(parent, company), as_dict=1)
|
order by name""".format(doctype=frappe.db.escape(doctype),
|
||||||
|
parent_field=frappe.db.escape(parent_field)), (parent, company), as_dict=1)
|
||||||
|
|
||||||
# return warehouses
|
# return warehouses
|
||||||
for wh in warehouses:
|
for wh in warehouses:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user