mirror of
https://github.com/itsdave-de/msp.git
synced 2025-05-06 15:35:12 +02:00
repair Location
This commit is contained in:
parent
b141c968ea
commit
a985f8524c
27
msp/hooked_methods.py
Normal file
27
msp/hooked_methods.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import frappe
|
||||||
|
from frappe.utils import cstr
|
||||||
|
|
||||||
|
def build_full_location_path(doctype, method=None):
|
||||||
|
parent_location_name = doctype.parent_location
|
||||||
|
full_path = ''
|
||||||
|
html_full_path = ''
|
||||||
|
has_parent_location = True if parent_location_name else False
|
||||||
|
|
||||||
|
while has_parent_location:
|
||||||
|
result = frappe.db.get_value('Location', {'name': parent_location_name}, ['name', 'location_name', 'parent_location'], as_dict=True)
|
||||||
|
if not result:
|
||||||
|
has_parent_location = False
|
||||||
|
continue
|
||||||
|
|
||||||
|
full_path = f"{result['location_name']} --> {full_path}"
|
||||||
|
html_full_path = f"<a href='http://{cstr(frappe.local.site)}/app/location/{result['name']}' target='_blank'>{result['location_name']}</a> --> {html_full_path}"
|
||||||
|
parent_location_name = result['parent_location']
|
||||||
|
|
||||||
|
if not parent_location_name:
|
||||||
|
has_parent_location = False
|
||||||
|
|
||||||
|
full_path = f"{full_path} {doctype.location_name}" if full_path != '' else doctype.location_name
|
||||||
|
html_full_path = f"{html_full_path} <a href='http://{cstr(frappe.local.site)}/app/location/{doctype.name}' target='_blank'>{doctype.location_name}</a>" if html_full_path != '' else f"<a href='{doctype.name}'>{doctype.location_name}</a>"
|
||||||
|
|
||||||
|
doctype.full_path = full_path
|
||||||
|
doctype.html_full_path = html_full_path
|
@ -91,7 +91,7 @@ doctype_js = {"Location" : "public/js/location.js"}
|
|||||||
|
|
||||||
doc_events = {
|
doc_events = {
|
||||||
"Location": {
|
"Location": {
|
||||||
"before_save": "msp.tools.hooks_methods.build_full_location_path"
|
"before_save": "msp.hooked_methods.build_full_location_path"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user