Browse Source

kilometer mapping changes

version2
venkataakhil 12 months ago
parent
commit
bb51b2c7db
  1. 59
      smart_service/transactions/doctype/kilometer_mapping/kilometer_mapping.py

59
smart_service/transactions/doctype/kilometer_mapping/kilometer_mapping.py

@ -5,6 +5,34 @@ import frappe
from frappe.model.document import Document
import sys
from frappe import _
<<<<<<< HEAD
sys.tracebacklimit = 0
class KilometerMapping(Document):
def onload(self):
# Kilometer mapping config table idx allignment
if (self.config_kilometer):
idx = 0
for x in self.get("config_kilometer"):
idx += 1
x.idx = idx
@frappe.whitelist()
def get_system(doc):
current_db_name = frappe.conf.get("db_name")
system_map = frappe.db.sql("""select name from {0}.`tabSystem Mapping` where variant_mapping='{1}'""".format(
current_db_name, doc), as_dict=True)
if system_map:
for s in system_map:
doc = frappe.get_doc("System Mapping", s.name)
system = frappe.db.sql("""select sub_systems,mat from {0}.`tabSystem Mapping_Sub System` where parent = '{1}' and procedure_is_published = '0'""".format(
current_db_name, s.name), as_dict=True)
return system
=======
sys.tracebacklimit=0
current_db_name = frappe.conf.get("db_name")
class KilometerMapping(Document):
@ -25,22 +53,26 @@ def get_system(doc):
system = frappe.db.sql("""select sub_systems,mat from {0}.`tabSystem Mapping_Sub System` where parent = '{1}' and procedure_is_published = '0'""".format(current_db_name,s.name),as_dict=True)
return system
>>>>>>> bb4600bece5c8a0a27d7e8515d386801fc23a646
@frappe.whitelist()
def get_subsystem(doc):
current_db_name = frappe.conf.get("db_name")
system_map = frappe.db.sql("""select name from {0}.`tabSystem Mapping` where variant_mapping='{1}'""".format(current_db_name,doc),as_dict=True)
system_map = frappe.db.sql("""select name from {0}.`tabSystem Mapping` where variant_mapping='{1}'""".format(
current_db_name, doc), as_dict=True)
if system_map:
for s in system_map:
doc = frappe.get_doc("System Mapping",s.name)
sub_system = frappe.db.sql("""select sub_systems,mat,idx from {0}.`tabSystem Mapping_Sub System` where parent = '{1}' and procedure_is_published = '0'""".format(current_db_name,s.name),as_dict=True)
doc = frappe.get_doc("System Mapping", s.name)
sub_system = frappe.db.sql("""select sub_systems,mat,idx from {0}.`tabSystem Mapping_Sub System` where parent = '{1}' and procedure_is_published = '0'""".format(
current_db_name, s.name), as_dict=True)
return sub_system
@frappe.whitelist()
def update_duplicate_km(doc,kilometer):
def update_duplicate_km(doc, kilometer):
km = frappe.get_doc("Kilometer Mapping",doc)
output = frappe.db.sql("""select kilometer,mat,sub_systems,row_name from `tabKilometer Mapping_Items` where parent = '{0}' and kilometer = '{1}' order by kilometer""".format(doc,kilometer),as_dict=True)
km = frappe.get_doc("Kilometer Mapping", doc)
output = frappe.db.sql("""select kilometer,mat,sub_systems,row_name from `tabKilometer Mapping_Items` where parent = '{0}' and kilometer = '{1}' order by kilometer""".format(
doc, kilometer), as_dict=True)
# frappe.msgprint(str(output))
for data in output:
# frappe.msgprint(str(data['mat']))
@ -53,8 +85,20 @@ def update_duplicate_km(doc,kilometer):
km.save(ignore_permissions=True)
@frappe.whitelist()
<<<<<<< HEAD
def get_config_kilometer(doc, docname):
res = frappe.db.sql(
f"""select kilometer,mat,sub_systems,applicable,row_name from `tabKilometer Mapping_Items` where parent='{doc}'""", as_dict=1)
ress = frappe.get_doc("Kilometer Mapping", docname)
ress.config_kilometer = []
for d in res:
ress.append("config_kilometer", d)
ress.add_comment(text=_("data added"+str(res)))
ress.save()
frappe.db.commit()
return {"status": "success"}
=======
def get_config_kilometer(doc,docname):
res = frappe.db.sql(f"""select kilometer,mat,sub_systems,applicable,row_name from `tabKilometer Mapping_Items` where parent='{doc}'""",as_dict=1)
ress = frappe.get_doc("Kilometer Mapping",docname)
@ -79,3 +123,4 @@ def get_config_kilometer(doc,docname):
# km_filters =frappe.db.sql(f"""select * from `tabKilometer Mapping_Items` where parent ="{parent}" and kilometer ="{km}" order by length(kilometer),kilometer """,as_dict = 1)
# return km_filters
>>>>>>> bb4600bece5c8a0a27d7e8515d386801fc23a646

Loading…
Cancel
Save