[enhancement] warehouse tree structure
This commit is contained in:
parent
b72a2955ac
commit
dfbcdeb8a0
@ -273,3 +273,4 @@ execute:frappe.rename_doc("DocType", "Payments", "Sales Invoice Payment", force=
|
|||||||
erpnext.patches.v7_0.update_mins_to_first_response
|
erpnext.patches.v7_0.update_mins_to_first_response
|
||||||
erpnext.patches.v6_20x.repost_valuation_rate_for_negative_inventory
|
erpnext.patches.v6_20x.repost_valuation_rate_for_negative_inventory
|
||||||
erpnext.patches.v7_0.re_route
|
erpnext.patches.v7_0.re_route
|
||||||
|
erpnext.patches.v7_0.create_warehouse_nestedset
|
||||||
|
18
erpnext/patches/v7_0/create_warehouse_nestedset.py
Normal file
18
erpnext/patches/v7_0/create_warehouse_nestedset.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import frappe
|
||||||
|
from frappe import _
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
if not frappe.db.exists("Warehouse", {"warehouse_name": _("All Warehouses")}):
|
||||||
|
parent_warehouse = frappe.get_doc({
|
||||||
|
"doctype": "Warehouse",
|
||||||
|
"warehouse_name": _("All Warehouses"),
|
||||||
|
"is_group": "Yes"
|
||||||
|
}).insert(ignore_permissions=True)
|
||||||
|
|
||||||
|
for warehouse in frappe.db.sql_list("""select name from tabWarehouse
|
||||||
|
where name != %s order by name asc""", "All Warehouses - SI"):
|
||||||
|
print warehouse
|
||||||
|
warehouse = frappe.get_doc("Warehouse", warehouse)
|
||||||
|
warehouse.is_group = "No"
|
||||||
|
warehouse.parent_warehouse = parent_warehouse.name
|
||||||
|
warehouse.save(ignore_permissions=True)
|
@ -2,6 +2,7 @@
|
|||||||
"allow_copy": 0,
|
"allow_copy": 0,
|
||||||
"allow_import": 1,
|
"allow_import": 1,
|
||||||
"allow_rename": 1,
|
"allow_rename": 1,
|
||||||
|
"beta": 0,
|
||||||
"creation": "2013-03-07 18:50:32",
|
"creation": "2013-03-07 18:50:32",
|
||||||
"custom": 0,
|
"custom": 0,
|
||||||
"description": "A logical Warehouse against which stock entries are made.",
|
"description": "A logical Warehouse against which stock entries are made.",
|
||||||
@ -420,6 +421,159 @@
|
|||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"fieldname": "tree_details",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"label": "Tree Details",
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"unique": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"fieldname": "parent_warehouse",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 1,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"label": "Parent Warehouse",
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"options": "Warehouse",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 1,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"unique": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"fieldname": "is_group",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Has Child Node",
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"options": "\nYes\nNo",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 1,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"unique": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"fieldname": "lft",
|
||||||
|
"fieldtype": "Int",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"label": "lft",
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"unique": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"fieldname": "rgt",
|
||||||
|
"fieldtype": "Int",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"label": "rgt",
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"unique": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"fieldname": "old_parent",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"label": "Old Parent",
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"options": "Warehouse",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"unique": 0
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"hide_heading": 0,
|
"hide_heading": 0,
|
||||||
@ -432,7 +586,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2016-04-18 05:44:24.837579",
|
"modified": "2016-05-23 21:25:21.396188",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Warehouse",
|
"name": "Warehouse",
|
||||||
|
@ -5,10 +5,11 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe.utils import cint, validate_email_add
|
from frappe.utils import cint, validate_email_add
|
||||||
from frappe import throw, msgprint, _
|
from frappe import throw, msgprint, _
|
||||||
|
from frappe.utils.nestedset import NestedSet
|
||||||
|
|
||||||
from frappe.model.document import Document
|
class Warehouse(NestedSet):
|
||||||
|
nsm_parent_field = 'parent_warehouse'
|
||||||
|
|
||||||
class Warehouse(Document):
|
|
||||||
def autoname(self):
|
def autoname(self):
|
||||||
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):
|
||||||
@ -45,6 +46,7 @@ class Warehouse(Document):
|
|||||||
|
|
||||||
def on_update(self):
|
def on_update(self):
|
||||||
self.create_account_head()
|
self.create_account_head()
|
||||||
|
self.update_nsm_model()
|
||||||
|
|
||||||
def create_account_head(self):
|
def create_account_head(self):
|
||||||
if cint(frappe.defaults.get_global_default("auto_accounting_for_stock")):
|
if cint(frappe.defaults.get_global_default("auto_accounting_for_stock")):
|
||||||
@ -82,6 +84,8 @@ class Warehouse(Document):
|
|||||||
frappe.throw(_("Warehouse {0}: Parent account {1} does not bolong to the company {2}")
|
frappe.throw(_("Warehouse {0}: Parent account {1} does not bolong to the company {2}")
|
||||||
.format(self.name, self.create_account_under, self.company))
|
.format(self.name, self.create_account_under, self.company))
|
||||||
|
|
||||||
|
def update_nsm_model(self):
|
||||||
|
frappe.utils.nestedset.update_nsm(self)
|
||||||
|
|
||||||
def on_trash(self):
|
def on_trash(self):
|
||||||
# delete bin
|
# delete bin
|
||||||
|
Loading…
x
Reference in New Issue
Block a user