Browse Source

publish client changes

version2
venkataakhil 11 months ago
parent
commit
cf38659136
  1. 100
      smart_service/apis/publish_api.py
  2. 534
      smart_service/apis/update_validation.py
  3. 6
      smart_service/apis/v2/master.py
  4. 2
      smart_service/phase_2/doctype/special_tool_information/special_tool_information.py
  5. 0
      smart_service/transactions/doctype/duplicate_kilometer_mapping_items/__init__.py
  6. 63
      smart_service/transactions/doctype/duplicate_kilometer_mapping_items/duplicate_kilometer_mapping_items.json
  7. 8
      smart_service/transactions/doctype/duplicate_kilometer_mapping_items/duplicate_kilometer_mapping_items.py
  8. 23
      smart_service/transactions/doctype/kilometer_mapping/kilometer_mapping.js
  9. 13
      smart_service/transactions/doctype/kilometer_mapping/kilometer_mapping.json
  10. 17
      smart_service/transactions/doctype/kilometer_mapping/kilometer_mapping.py
  11. 22
      smart_service/transactions/doctype/publish/publish.js
  12. 4
      smart_service/transactions/doctype/publish/publish.py

100
smart_service/apis/publish_api.py

@ -20,6 +20,7 @@ base_url = os.path.expanduser(
internal_path = base_url + "/files/json_files/internal/"
global_path = base_url + "/files/json_files/global/"
full_update_path = base_url + "/files/json_files/full_update/"
full_update_path_internal = base_url + "/files/json_files/full_update/internal/"
STATUS = "status"
ERROR = "error"
PARAM_MISSING = "Parameter missing :"
@ -254,6 +255,7 @@ def old_json_grouping(args, language):
def json_grouping(args, language):
try:
dicfinal = []
frappe.log_error('args' + str(args))
docs_child = frappe.db.get_list("Publish_Docs", filters={"parent": args},
fields=["variant_mapping", "system", "sub_system", "procedure_status",
"procedure_link"])
@ -431,6 +433,8 @@ def new_publish(args, publish_type, vehicle, language, version):
os.makedirs(global_path + vehicle + "/")
if not os.path.exists(full_update_path + vehicle + "/"):
os.makedirs(full_update_path + vehicle + "/")
if not os.path.exists(full_update_path_internal + vehicle + "/"):
os.makedirs(full_update_path_internal + vehicle + "/")
except Exception as e:
return False, "Failed to create Folders"
@ -447,24 +451,29 @@ def new_publish(args, publish_type, vehicle, language, version):
file_name = global_path + vehicle + "/" + base_file_name
else:
return {STATUS: 0, ERROR: "Publish type not available"}
frappe.log_error('created file name' +str(file_name))
""" Save file (Internal/Global) """
with open(file_name, "w") as outfile:
outfile.write(json.dumps(json_file))
get_step_total_count(file_name)
""" Remove previous internal publish file """
if publish_type.lower() == "internal":
for fil in os.listdir(internal_path + vehicle):
file_val = internal_path + vehicle + "/" + fil
if file_val != file_name:
if (fil.split("-")[1]).split("_")[0] == language:
os.remove(file_val)
# """ Remove previous internal publish file """
# if publish_type.lower() == "internal":
# for fil in os.listdir(internal_path + vehicle):
# file_val = internal_path + vehicle + "/" + fil
# if file_val != file_name:
# if (fil.split("-")[1]).split("_")[0] == language:
# os.remove(file_val)
""" Generate full update file """
pub_ver = None
prev_update_ver = None
check_if_global_exist = frappe.db.sql("""SELECT vehicle,language,format(version,2) as version,modified,publish_type FROM tabPublish where vehicle = "{}"
and publish_type = "Global" AND `language` = "{}" order by modified desc limit 1 ;""".format(vehicle, language), as_dict=1)
if publish_type.lower() == "global":
frappe.log_error(str("global"))
full_update_file_name = full_update_path + vehicle + "/" + \
"%s-%s-full_v%s.json" % (vehicle, language, version)
@ -472,11 +481,14 @@ def new_publish(args, publish_type, vehicle, language, version):
with open(full_update_file_name, "w") as outfile:
outfile.write(json.dumps(json_file))
get_step_total_count(full_update_file_name)
file_name = file_name
return True, file_name.split("public")[1]
else:
pub_ver = frappe.db.sql(""" SELECT vehicle,`language`,format(version,2) as version,modified,publish_type FROM tabPublish where vehicle = "{}"
pub_ver = frappe.db.sql(""" SELECT vehicle,language,format(version,2) as version,modified,publish_type FROM tabPublish where vehicle = "{}"
and publish_type = "Global" AND `language` = "{}" order by modified desc limit 2 ;""".format(vehicle, language), as_dict=1)
if pub_ver:
prev_update_ver = pub_ver[1]["version"]
prev_full_update_file = full_update_path + vehicle + "/" + \
"%s-%s-full_v%s.json" % (vehicle,
@ -491,8 +503,76 @@ def new_publish(args, publish_type, vehicle, language, version):
# return True, file_name
else:
return False, "File save issue"
if publish_type.lower() == "internal" and len(check_if_global_exist)>0:
frappe.log_error(str('already global published'))
full_update_file_name = full_update_path_internal + vehicle + "/" + \
"%s-%s-full_v%s.json" % (vehicle, language, version)
frappe.log_error( 'update file' + str(full_update_file_name))
pub_ver = frappe.db.sql(""" SELECT vehicle,language,format(version,2) as version,modified,publish_type FROM tabPublish where vehicle = "{}"
and publish_type = "Internal" AND `language` = "{}" order by modified desc limit 2 ;""".format(vehicle, language), as_dict=1)
if pub_ver:
frappe.log_error('inside')
prev_update_ver_internal = float(pub_ver[1]["version"])
frappe.log_error('version_internal' + str(prev_update_ver_internal))
prev_full_internal_update_file = full_update_path_internal + vehicle + "/" + \
"%s-%s-full_v%s.json" % (vehicle,
language, prev_update_ver_internal)
if check_if_global_exist:
frappe.log_error('inside1')
prev_global_update_ver = check_if_global_exist[0]["version"]
frappe.log_error('version_global' + str(prev_global_update_ver))
prev_global_file = full_update_path + vehicle + "/" + \
"%s-%s-full_v%s.json" % (vehicle,
language, prev_global_update_ver)
frappe.log_error('prev_global' + str(prev_global_file))
file_flag, final_update_file = merge_json_files(
prev_global_file, file_name, full_update_file_name)
get_step_total_count(final_update_file)
set_publish_flag(publish_type,vehicle,language)
if file_flag:
return True, file_name.split("public")[1]
# return True, file_name
else:
return False, "File save issue"
# frappe.log_error("global exists")
# last_fullupdate_file = frappe.db.sql(""" SELECT vehicle,language,format(version,2) as version,modified,publish_type FROM tabPublish where vehicle = "{}"
# and publish_type = "Internal" AND `language` = "{}" order by modified desc limit 2 ;""".format(vehicle, language), as_dict=1)
# if last_fullupdate_file:
# pass
else:
full_update_file_name = full_update_path_internal + vehicle + "/" + \
"%s-%s-full_v%s.json" % (vehicle, language, version)
if str(version) == "0.01":
with open(full_update_file_name, "w") as outfile:
outfile.write(json.dumps(json_file))
get_step_total_count(full_update_file_name)
else:
pub_ver = frappe.db.sql(""" SELECT vehicle,language,format(version,2) as version,modified,publish_type FROM tabPublish where vehicle = "{}"
and publish_type = "Internal" AND `language` = "{}" order by modified desc limit 2 ;""".format(vehicle, language), as_dict=1)
if pub_ver:
prev_update_ver = pub_ver[1]["version"]
prev_full_update_file = full_update_path_internal + vehicle + "/" + \
"%s-%s-full_v%s.json" % (vehicle,
language, prev_update_ver)
file_flag, final_update_file = merge_json_files(
prev_full_update_file, file_name, full_update_file_name)
get_step_total_count(final_update_file)
set_publish_flag(publish_type,vehicle,language)
if file_flag:
return True, file_name.split("public")[1]
# return True, file_name
else:
return False, "File save issue"
set_publish_flag(publish_type,vehicle,language)
frappe.log_error('file_name' +str(file_name))
return True, file_name.split("public")[1]
# return True, file_name
@ -550,7 +630,7 @@ def set_publish_flag(publish_type,vehicle,language):
frappe.db.commit()
except Exception as e:
frappe.log_error(str(e))
frappe.log_error('set_publish_flag' +str(e))
def merge_json_files(old_json_path, new_json_path, out_file_path):

534
smart_service/apis/update_validation.py

@ -13,9 +13,10 @@ base_url = os.path.expanduser(
current_db_name = frappe.conf.get("db_name")
# Constants
JSON_EXT = ".json"
JSON_INT_PATH = "/files/json_files/internal/"
# JSON_INT_PATH = "/files/json_files/internal/"
JSON_INT_PATH = "/files/json_files/full_update/internal/"
JSON_GLOABL_PATH = "/files/json_files/global/"
JSON_FULL_UPDATE_PATH = "/files/json_files/full_update/"
JSON_FULL_UPDATE_PATH = base_url+"/files/json_files/full_update/internal/"
STATUS = "status"
ERROR = "error"
UPDATE_AVAILABLE = 'IsUpdateAvailable'
@ -23,6 +24,7 @@ UPDATE_FAILED = "Update checking Failed"
PARAM_MISSING = "Parameter missing :"
VERSION = 'Version'
CUR_VERSION = 'CurrentVersion'
DIS ='Discription'
FILE_ERROR = 'File failed to load'
LANGUAGE = 'Language'
FILE_SIZE = 'FileSize'
@ -64,8 +66,8 @@ def get_parent_map(input_list, parameter):
return list1, steps_length
@frappe.whitelist()
def check_all_vehicle_updates(vehicle_list=None):
@frappe.whitelist(allow_guest = 1)
def check_all_vehicle_updates1(vehicle_list=None):
rate_res = custom_rate_limit(limit=5, seconds=15)
if rate_res != 1:
return rate_res
@ -91,11 +93,11 @@ def check_all_vehicle_updates(vehicle_list=None):
for v in vehicle_data:
v_id = v['Vehicle']
current_version = float(v[CUR_VERSION])
data1_global = frappe.db.sql('''SELECT name,format(max(version),2) as version,vehicle_id,language FROM `tabPublish` where vehicle='{}' and language='{}'
and publish_status='Published' and publish_type='Global' and vehicle_status='Active'
data1_global = frappe.db.sql('''SELECT name,format(max(version),2) as version,vehicle_id,language,release_description as description FROM `tabPublish` where vehicle='{}' and language='{}'
and publish_status='Published' and publish_type='Global' and vehicle_status='Active' and publish_module='Automotive System'
order by version ASC;'''.format(v_id, lang), as_dict=1)
data1 = frappe.db.sql('''SELECT name,format(max(version),2) as version,vehicle_id,language FROM `tabPublish` where vehicle='{}' and language='{}'
and publish_status='Published' and publish_type='{}' and vehicle_status='Active'
data1 = frappe.db.sql('''SELECT name,format(max(version),2) as version,vehicle_id,language,release_description as description FROM `tabPublish` where vehicle='{}' and language='{}'
and publish_status='Published' and publish_type='{}' and vehicle_status='Active' and publish_module='Automotive System'
order by version ASC;'''.format(v_id, lang, publish_type[0][0]), as_dict=1)
if data1[0]['version'] is not None:
@ -104,17 +106,24 @@ def check_all_vehicle_updates(vehicle_list=None):
vehicle_req_list.append(data1)
else:
if current_version < float(data1_global[0]['version']):
data = frappe.db.sql('''SELECT name,format(max(version),2) as version,vehicle_id,language FROM `tabPublish` where vehicle='{}' and language='{}'
and publish_status='Published' and publish_type='Global' and vehicle_status='Active' and version > '{}'
data = frappe.db.sql('''SELECT name,format(max(version),2) as version,vehicle_id,language,release_description as description FROM `tabPublish` where vehicle='{}' and language='{}'
and publish_status='Published' and publish_type='Global' and vehicle_status='Active' and version > '{}' and publish_module='Automotive System'
order by version ASC;'''.format(v_id, lang, current_version), as_dict=1)
publish_dec = frappe.db.sql('''SELECT name,format(max(version),2) as version,vehicle_id,language,release_description as description FROM `tabPublish` where vehicle='{}' and language='{}'
# and publish_status='Published' and publish_type='Global' and vehicle_status='Active' and version = '{}' and publish_module='Automotive System'
# order by version ASC;'''.format(v_id, lang, data1_global[0]['version']), as_dict=1)
elif current_version == float(data1_global[0]['version']):
if current_version < float(data1[0]['version']):
data = frappe.db.sql('''SELECT name,format(max(version),2) as version,vehicle_id,language FROM `tabPublish` where vehicle='{}' and
language='{}' and publish_status='Published' and publish_type='{}' and vehicle_status='Active' and version > '{}'
data = frappe.db.sql('''SELECT name,format(max(version),2) as version,vehicle_id,language,release_description as description FROM `tabPublish` where vehicle='{}' and
language='{}' and publish_status='Published' and publish_type='{}' and vehicle_status='Active' and version > '{}' and publish_module='Automotive System'
order by version ASC;'''.format(v_id, lang, publish_type[0][0], current_version), as_dict=1)
publish_dec = frappe.db.sql('''SELECT name,format(max(version),2) as version,vehicle_id,language,release_description as description FROM `tabPublish` where vehicle='{}' and language='{}'
and publish_status='Published' and publish_type='Global' and vehicle_status='Active' and version ='{}' and publish_module='Automotive System'
order by version ASC;'''.format(v_id, lang, data1[0]['version']), as_dict=1)
# return data
data_append = []
rd = []
try:
for d in data:
d[UPDATE_AVAILABLE] = 'true'
@ -122,13 +131,24 @@ def check_all_vehicle_updates(vehicle_list=None):
current_version)
data_append.append(d)
vehicle_req_list.append(data_append)
# for note in publish_dec:
# rd.append(note)
# vehicle_req_list.append(rd)
# for n in publish_dec:
# rd.append(n['release_description'])
# vehicle_req_list.append(rd)
except:
pass
response['LanguageID'] = lang
if len(vehicle_req_list) != 0:
response['VehicleReqList'] = vehicle_req_list[0]
data = [vu[0] for vu in vehicle_req_list]
frappe.log_error(str(data))
# publish_dec_txt = [pd[0] for pd in publish_dec]
response['VehicleReqList'] = data
# response['release_description'] = publish_dec_txt['release_description']
return response
else:
return {STATUS: 0, ERROR: "No Vehicles in criteria"}
@ -138,13 +158,147 @@ def check_all_vehicle_updates(vehicle_list=None):
return {STATUS: 0, ERROR: "Invalid Publish Details"}
except Exception as e:
frappe.log_error(str(e))
return {STATUS: 0, ERROR: "Failed to fetch updates"}
else:
return {STATUS: 0, ERROR: "Check argument: vehicle list"}
@frappe.whitelist()
def check_vehicle_update(vehicle_list=None):
def check_all_vehicle_updates(vehicle_list=None):
frappe.log_error('request' + str(vehicle_list))
rate_res = custom_rate_limit(limit=5, seconds=15)
if rate_res != 1:
return rate_res
# if vehicle_list == None:
# return {STATUS: 0, ERROR: "Parameter missing: Vehicle List"}
val = input_validation(vehicle_list=vehicle_list)
if val != '':
return {STATUS: 0, ERROR: PARAM_MISSING+val}
if vehicle_list:
try:
vehicle_req_list = []
response = {}
v_list = json.loads(vehicle_list)
lang = v_list['LanguageID']
iid = v_list['InstallationId']
vehicle_data = v_list['VehicleReqList']
publish_type = frappe.db.sql(
'''SELECT publish_type FROM `tabApp Device` where name='{}';'''.format(iid), as_list=1)
if publish_type[0][0] is not None:
if vehicle_data:
for v in vehicle_data:
v_id = v['Vehicle']
current_version = float(v[CUR_VERSION])
data1_global = frappe.db.sql('''SELECT name,format(max(version),2) as version,vehicle_id,language,release_description as description FROM `tabPublish` where vehicle='{}' and language='{}'
and publish_status='Published' and publish_type='Global' and vehicle_status='Active' and publish_module='Automotive System'
order by version ASC;'''.format(v_id, lang), as_dict=1)
data1 = frappe.db.sql('''SELECT name,format(max(version),2) as version,vehicle_id,language,release_description as description FROM `tabPublish` where vehicle='{}' and language='{}'
and publish_status='Published' and publish_type='{}' and vehicle_status='Active' and publish_module='Automotive System'
order by version ASC;'''.format(v_id, lang, publish_type[0][0]), as_dict=1)
if publish_type[0][0] == "Global":
if current_version == float(data1_global[0]['version']):
data1[0][UPDATE_AVAILABLE] = "false"
vehicle_req_list.append(data1)
else:
if current_version < float(data1_global[0]['version']):
data = frappe.db.sql('''SELECT name,format(max(version),2) as version,vehicle_id,language,release_description as description FROM `tabPublish` where vehicle='{}' and language='{}'
and publish_status='Published' and publish_type='Global' and vehicle_status='Active' and version > '{}' and publish_module='Automotive System'
order by version ASC;'''.format(v_id, lang, current_version), as_dict=1)
frappe.log_error('global_publish' + str(data))
publish_dec = frappe.db.sql('''SELECT name,format(max(version),2) as version,vehicle_id,language,release_description as description FROM `tabPublish` where vehicle='{}' and language='{}'
# and publish_status='Published' and publish_type='Global' and vehicle_status='Active' and version = '{}' and publish_module='Automotive System'
# order by version ASC;'''.format(v_id, lang, data1_global[0]['version']), as_dict=1)
frappe.log_error(str('global_publish'))
# elif current_version == float(data1_global[0]['version']):
# if current_version < float(data1[0]['version']):
# data = frappe.db.sql('''SELECT name,format(max(version),2) as version,vehicle_id,language,release_description as description FROM `tabPublish` where vehicle='{}' and
# language='{}' and publish_status='Published' and publish_type='{}' and vehicle_status='Active' and version > '{}' and publish_module='Automotive System'
# order by version ASC;'''.format(v_id, lang, publish_type[0][0], current_version), as_dict=1)
# publish_dec = frappe.db.sql('''SELECT name,format(max(version),2) as version,vehicle_id,language,release_description as description FROM `tabPublish` where vehicle='{}' and language='{}'
# and publish_status='Published' and publish_type='Global' and vehicle_status='Active' and version ='{}' and publish_module='Automotive System'
# order by version ASC;'''.format(v_id, lang, data1[0]['version']), as_dict=1)
# return data
data_append = []
rd = []
try:
for d in data:
d[UPDATE_AVAILABLE] = 'true'
d[CUR_VERSION] = float(
current_version)
data_append.append(d)
vehicle_req_list.append(data_append)
except:
pass
elif publish_type[0][0] == "Internal":
frappe.log_error(str('check_ful_internal'))
if current_version == float(data1[0]['version']):
data1[0][UPDATE_AVAILABLE] = "false"
vehicle_req_list.append(data1)
else:
if current_version < float(data1[0]['version']):
data = frappe.db.sql('''SELECT name,format(max(version),2) as version,vehicle_id,language,release_description as description FROM `tabPublish` where vehicle='{}' and language='{}'
and publish_status='Published' and publish_type='Internal' and vehicle_status='Active' and version > '{}' and publish_module='Automotive System'
order by version ASC;'''.format(v_id, lang, current_version), as_dict=1)
frappe.log_error('check_ful_inter' + str(data))
publish_dec = frappe.db.sql('''SELECT name,format(max(version),2) as version,vehicle_id,language,release_description as description FROM `tabPublish` where vehicle='{}' and language='{}'
# and publish_status='Published' and publish_type='Internal' and vehicle_status='Active' and version = '{}' and publish_module='Automotive System'
# order by version ASC;'''.format(v_id, lang, data1_global[0]['version']), as_dict=1)
elif current_version == float(data1[0]['version']):
if current_version < float(data1[0]['version']):
data = frappe.db.sql('''SELECT name,format(max(version),2) as version,vehicle_id,language,release_description as description FROM `tabPublish` where vehicle='{}' and
language='{}' and publish_status='Published' and publish_type='{}' and vehicle_status='Active' and version > '{}' and publish_module='Automotive System'
order by version ASC;'''.format(v_id, lang, publish_type[0][0], current_version), as_dict=1)
publish_dec = frappe.db.sql('''SELECT name,format(max(version),2) as version,vehicle_id,language,release_description as description FROM `tabPublish` where vehicle='{}' and language='{}'
and publish_status='Published' and publish_type='Global' and vehicle_status='Active' and version ='{}' and publish_module='Automotive System'
order by version ASC;'''.format(v_id, lang, data1[0]['version']), as_dict=1)
# return data
data_append = []
rd = []
try:
for d in data:
d[UPDATE_AVAILABLE] = 'true'
d[CUR_VERSION] = float(
current_version)
data_append.append(d)
vehicle_req_list.append(data_append)
# for note in publish_dec:
# rd.append(note)
# vehicle_req_list.append(rd)
# for n in publish_dec:
# rd.append(n['release_description'])
# vehicle_req_list.append(rd)
except:
pass
response['LanguageID'] = lang
if len(vehicle_req_list) != 0:
data = [vu[0] for vu in vehicle_req_list]
response['VehicleReqList'] = data
# response['release_description'] = publish_dec_txt['release_description']
return response
else:
return {STATUS: 0, ERROR: "No Vehicles in criteria"}
else:
return {STATUS: 0, ERROR: "Invalid Publish Details"}
else:
return {STATUS: 0, ERROR: "Invalid Publish Details"}
except Exception as e:
frappe.log_error(str(e))
return {STATUS: 0, ERROR: "Failed to fetch updates"}
else:
return {STATUS: 0, ERROR: "Check argument: vehicle list"}
@frappe.whitelist(allow_guest = 1)
def check_vehicle_update1(vehicle_list=None):
rate_res = custom_rate_limit(limit=5, seconds=15)
if rate_res != 1:
return rate_res
@ -172,12 +326,14 @@ def check_vehicle_update(vehicle_list=None):
for v in vehicle_data:
l_id = v['LanguageID']
current_version = float(v[CUR_VERSION])
data1_global = frappe.db.sql('''SELECT name,format(max(version),2) as version,vehicle_id,language FROM `tabPublish` where vehicle='{}' and language='{}'
data1_global = frappe.db.sql('''SELECT name,format(max(version),2) as version,vehicle_id,language,release_description as description FROM `tabPublish` where
vehicle='{}' and language='{}'
and publish_status='Published' and publish_type='Global' and vehicle_status='Active' and publish_module='Automotive System'
order by version ASC;'''.format(vehicle, l_id), as_dict=1)
data1 = frappe.db.sql('''SELECT name,format(max(version),2) as version,vehicle_id,language FROM `tabPublish` where vehicle='{}' and language='{}' and
data1 = frappe.db.sql('''SELECT name,format(max(version),2) as version,vehicle_id,language,release_description as description FROM `tabPublish`
where vehicle='{}' and language='{}' and
publish_status='Published' and vehicle_status='Active' and
publish_module='Automotive System'
order by version ASC;'''.format(vehicle, l_id), as_dict=1)
@ -193,19 +349,21 @@ def check_vehicle_update(vehicle_list=None):
else:
if current_version < (float(data1_global[0]['version'])-1.00):
data = frappe.db.sql('''SELECT name as Name,format(max(version),2) as Version,vehicle_id as Vehicle,language as Language FROM `tabPublish`
where vehicle='{}' and language='{}' and publish_status='Published' and publish_type='Global' and
vehicle_status='Active' and Version > '{}'
and publish_module='Automotive System' order by version ASC;'''.format(vehicle, l_id, current_version), as_dict=1)
data = frappe.db.sql('''SELECT name as Name,version as Version,vehicle_id as Vehicle,language as Language,release_description
as description FROM `tabPublish`
where vehicle='{}' and language='{}' and publish_status='Published' and publish_type='Global' and vehicle_status='Active'
and Version > '{}'
and publish_module='Automotive System' order by version DESC limit 1;'''.format(vehicle, l_id, current_version), as_dict=1)
try:
for d in data:
try:
file_name = JSON_FULL_UPDATE_PATH+vehicle+"/"+vehicle + \
file_name =JSON_FULL_UPDATE_PATH+vehicle+"/"+vehicle + \
"-" + \
d[LANGUAGE]+"-"+"full_v" + \
str(d[VERSION])+JSON_EXT
file_size = os.path.getsize(
base_url + file_name)
frappe.log_error("name"+str(file_name))
file_size = os.path.getsize(file_name)
frappe.log_error("size"+str(file_size))
d[JSON_URL] = file_name
d[FILE_SIZE] = file_size
d['Error'] = None
@ -227,10 +385,10 @@ def check_vehicle_update(vehicle_list=None):
{ERROR: UPDATE_FAILED})
elif current_version == (float(data1_global[0]['version'])-1.00):
data = frappe.db.sql('''SELECT name as Name,format(max(version),2) as Version,vehicle_id as Vehicle,language as Language FROM `tabPublish`
where vehicle='{}' and language='{}' and publish_status='Published' and publish_type='Global' and vehicle_status='Active'
and Version > '{}' and publish_module='Automotive System'
order by version ASC;'''.format(vehicle, l_id, current_version), as_dict=1)
data = frappe.db.sql('''SELECT name as Name,format(max(version),2) as Version,vehicle_id as Vehicle,language as Language,release_description as description FROM `tabPublish`
where vehicle='{}' and language='{}' and publish_status='Published' and publish_type='Global' and vehicle_status='Active'
and Version > '{}' and publish_module='Automotive System'
order by version DESC;'''.format(vehicle, l_id, current_version), as_dict=1)
try:
for d in data:
file_name = None
@ -263,10 +421,10 @@ def check_vehicle_update(vehicle_list=None):
elif current_version == float(data1_global[0]['version']):
if current_version < float(data1[0]['version']):
data = frappe.db.sql('''SELECT name as Name,format(max(version),2) as Version,vehicle_id as Vehicle,language as Language
FROM `tabPublish` where vehicle='{}' and language='{}' and publish_status='Published' and publish_type='{}' and
vehicle_status='Active' and version > '{}' and publish_module='Automotive System'
order by version ASC;'''.format(vehicle, l_id, publish_type, current_version), as_dict=1)
data = frappe.db.sql('''SELECT name as Name,format(max(version),2) as Version,vehicle_id as Vehicle,language as Language,release_description as description
FROM `tabPublish` where vehicle='{}' and language='{}' and publish_status='Published' and publish_type='{}' and
vehicle_status='Active' and version > '{}' and publish_module='Automotive System'
order by version DESC;'''.format(vehicle, l_id, publish_type, current_version), as_dict=1)
try:
for d in data:
try:
@ -299,10 +457,9 @@ def check_vehicle_update(vehicle_list=None):
elif (float(data1_global[0]['version'])-1.00) < current_version < float(data1_global[0]['version']):
if current_version < float(data1[0]['version']):
data = frappe.db.sql('''SELECT name as Name,format(max(version),2) as Version,vehicle_id as Vehicle,language as Language FROM `tabPublish`
where vehicle='{}' and language='{}' and publish_status='Published' and publish_type='Global' and vehicle_status='Active'
and publish_module='Automotive System'
and version > '{}' order by version ASC;'''.format(vehicle, l_id, current_version), as_dict=1)
data = frappe.db.sql('''SELECT name as Name,format(max(version),2) as Version,vehicle_id as Vehicle,language as Language,release_description as description FROM `tabPublish`
where vehicle='{}' and language='{}' and publish_status='Published' and publish_type='Global' and vehicle_status='Active'
and publish_module='Automotive System'and version > '{}' order by version DESC;'''.format(vehicle, l_id, current_version), as_dict=1)
try:
for d in data:
try:
@ -339,10 +496,9 @@ def check_vehicle_update(vehicle_list=None):
elif current_version > float(data1_global[0]['version']):
if current_version < float(data1[0]['version']):
data = frappe.db.sql('''SELECT name as Name,format(max(version),2) as Version,vehicle_id as Vehicle,language as Language FROM `tabPublish`
where vehicle='{}' and language='{}' and publish_status='Published' and publish_type='{}' and vehicle_status='Active' and version > '{}'
and publish_module='Automotive System'
order by version ASC;'''.format(vehicle, l_id, publish_type, current_version), as_dict=1)
data = frappe.db.sql('''SELECT name as Name,format(max(version),2) as Version,vehicle_id as Vehicle,language as Language,
release_description as description FROM `tabPublish` where vehicle='{}' and language='{}' and publish_status='Published' and publish_type='{}' and vehicle_status='Active' and version > '{}'
and publish_module='Automotive System' order by version DESC;'''.format(vehicle, l_id, publish_type, current_version), as_dict=1)
try:
for d in data:
try:
@ -383,16 +539,19 @@ def check_vehicle_update(vehicle_list=None):
vehicle_req_list.append(
{LANGUAGE: l_id, UPDATE_AVAILABLE: 'false', CUR_VERSION: float(current_version)})
else:
data = frappe.db.sql('''SELECT name as Name,format(max(version),2) as Version,vehicle_id as Vehicle,language as Language FROM `tabPublish`
frappe.log_error(str('internal update'))
data = frappe.db.sql('''SELECT name as Name,format(max(version),2) as Version,vehicle_id as Vehicle,language as Language,release_description as description FROM `tabPublish`
where vehicle='{}' and language='{}' and publish_status='Published' and publish_type='{}' and vehicle_status='Active'
and publish_module='Automotive System'
and version > '{}' order by version ASC;'''.format(vehicle, l_id, publish_type, current_version), as_dict=1)
and version > '{}' order by version DESC;'''.format(vehicle, l_id, publish_type, current_version), as_dict=1)
frappe.log_error(str(data))
try:
for d in data:
try:
file_name = JSON_INT_PATH+vehicle+"/" + \
file_name = JSON_INT_PATH+vehicle+"/" + \
vehicle+"-"+d[LANGUAGE] + \
"_v"+str(d[VERSION])+JSON_EXT
"-full_v"+str(d[VERSION])+JSON_EXT
frappe.log_error('full_inernal' +str(file_name))
file_size = os.path.getsize(
base_url + file_name)
d[JSON_URL] = file_name
@ -426,6 +585,293 @@ def check_vehicle_update(vehicle_list=None):
else:
return {STATUS: 0, ERROR: "Check Parameter: vehicle list"}
@frappe.whitelist()
def check_vehicle_update(vehicle_list=None):
rate_res = custom_rate_limit(limit=5, seconds=15)
if rate_res != 1:
return rate_res
# if vehicle_list == None:
# return {STATUS: 0, ERROR: "Parameter missing: Vehicle List"}
val = input_validation(vehicle_list=vehicle_list)
if val != '':
return {STATUS: 0, ERROR: PARAM_MISSING+val}
if vehicle_list:
try:
response = {}
req_list = json.loads(vehicle_list)
response['Vehicle'] = req_list['Vehicle']
vehicle = req_list['Vehicle']
iid = req_list['InstallationId']
vehicle_data = req_list['VehicleReqList']
publish_type = frappe.db.get_list(
'App Device', filters={'name': iid}, fields='publish_type')
if len(publish_type) > 0:
publish_type = publish_type[0]['publish_type']
vehicle_req_list = []
# Iterate on language
for v in vehicle_data:
l_id = v['LanguageID']
current_version = float(v[CUR_VERSION])
data1_global = frappe.db.sql('''SELECT name,format(max(version),2) as version,vehicle_id,language,release_description as description FROM `tabPublish` where
vehicle='{}' and language='{}'
and publish_status='Published' and publish_type='Global' and vehicle_status='Active' and publish_module='Automotive System'
order by version ASC;'''.format(vehicle, l_id), as_dict=1)
data1 = frappe.db.sql('''SELECT name,format(max(version),2) as version,vehicle_id,language,release_description as description FROM `tabPublish`
where vehicle='{}' and language='{}' and
publish_status='Published' and vehicle_status='Active' and
publish_module='Automotive System'
order by version ASC;'''.format(vehicle, l_id), as_dict=1)
if data1_global[0]['version'] and publish_type == 'Global':
if data1[0]['version'] is not None:
if current_version == float(data1[0]['version']):
data1[0][UPDATE_AVAILABLE] = "false"
data = {}
data[LANGUAGE] = l_id
data[UPDATE_AVAILABLE] = 'false'
data[CUR_VERSION] = float(current_version)
vehicle_req_list.append(data)
else:
if current_version < (float(data1_global[0]['version'])-1.00):
data = frappe.db.sql('''SELECT name as Name,version as Version,vehicle_id as Vehicle,language as Language,release_description
as description FROM `tabPublish`
where vehicle='{}' and language='{}' and publish_status='Published' and publish_type='Global' and vehicle_status='Active'
and Version > '{}'
and publish_module='Automotive System' order by version DESC limit 1;'''.format(vehicle, l_id, current_version), as_dict=1)
try:
for d in data:
try:
file_name =JSON_FULL_UPDATE_PATH+vehicle+"/"+vehicle + \
"-" + \
d[LANGUAGE]+"-"+"full_v" + \
str(d[VERSION])+JSON_EXT
frappe.log_error("name"+str(file_name))
file_size = os.path.getsize(file_name)
frappe.log_error("size"+str(file_size))
d[JSON_URL] = file_name
d[FILE_SIZE] = file_size
d['Error'] = None
d[UPDATE_AVAILABLE] = 'true'
except Exception as e:
file_name = None
file_size = None
d[JSON_URL] = file_name
d[FILE_SIZE] = file_size
d['Error'] = e
d[UPDATE_AVAILABLE] = 'false'
d[CUR_VERSION] = float(
current_version)
vehicle_req_list.append(d)
except Exception as e:
vehicle_req_list.append(
{ERROR: UPDATE_FAILED})
elif current_version == (float(data1_global[0]['version'])-1.00):
data = frappe.db.sql('''SELECT name as Name,format(max(version),2) as Version,vehicle_id as Vehicle,language as Language,release_description as description FROM `tabPublish`
where vehicle='{}' and language='{}' and publish_status='Published' and publish_type='Global' and vehicle_status='Active'
and Version > '{}' and publish_module='Automotive System'
order by version DESC;'''.format(vehicle, l_id, current_version), as_dict=1)
try:
for d in data:
file_name = None
try:
file_name = JSON_GLOABL_PATH+vehicle+"/" + \
vehicle+"-" + \
d[LANGUAGE]+"_v" + \
str(d[VERSION])+JSON_EXT
file_size = os.path.getsize(
base_url + file_name)
d[JSON_URL] = file_name
d[FILE_SIZE] = file_size
d['Error'] = None
d[UPDATE_AVAILABLE] = 'true'
except Exception as e:
# file_name= None
file_size = None
d[JSON_URL] = file_name
d[FILE_SIZE] = file_size
d['Error'] = e
d[UPDATE_AVAILABLE] = 'false'
d[CUR_VERSION] = float(
current_version)
vehicle_req_list.append(d)
except Exception as e1:
vehicle_req_list.append(
{ERROR: UPDATE_FAILED})
elif current_version == float(data1_global[0]['version']):
if current_version < float(data1[0]['version']):
data = frappe.db.sql('''SELECT name as Name,format(max(version),2) as Version,vehicle_id as Vehicle,language as Language,release_description as description
FROM `tabPublish` where vehicle='{}' and language='{}' and publish_status='Published' and publish_type='{}' and
vehicle_status='Active' and version > '{}' and publish_module='Automotive System'
order by version DESC;'''.format(vehicle, l_id, publish_type, current_version), as_dict=1)
try:
for d in data:
try:
file_name = JSON_INT_PATH+vehicle+"/" + \
vehicle+"-" + \
d[LANGUAGE]+"_v" + \
str(d[VERSION]) + \
JSON_EXT
file_size = os.path.getsize(
base_url + file_name)
d[JSON_URL] = file_name
d[FILE_SIZE] = file_size
d['Error'] = None
d[UPDATE_AVAILABLE] = 'true'
except Exception as e:
file_name = None
file_size = None
d[JSON_URL] = file_name
d[FILE_SIZE] = file_size
d['Error'] = e
d[UPDATE_AVAILABLE] = 'false'
d[CUR_VERSION] = float(
current_version)
vehicle_req_list.append(d)
except Exception as e2:
vehicle_req_list.append(
{ERROR: UPDATE_FAILED})
elif (float(data1_global[0]['version'])-1.00) < current_version < float(data1_global[0]['version']):
if current_version < float(data1[0]['version']):
data = frappe.db.sql('''SELECT name as Name,format(max(version),2) as Version,vehicle_id as Vehicle,language as Language,release_description as description FROM `tabPublish`
where vehicle='{}' and language='{}' and publish_status='Published' and publish_type='Global' and vehicle_status='Active'
and publish_module='Automotive System'and version > '{}' order by version DESC;'''.format(vehicle, l_id, current_version), as_dict=1)
try:
for d in data:
try:
file_name = JSON_GLOABL_PATH+vehicle+"/" + \
vehicle+"-" + \
d[LANGUAGE]+"_v" + \
str(d[VERSION]) + \
JSON_EXT
file_size = os.path.getsize(
base_url + file_name)
d[JSON_URL] = file_name
d[FILE_SIZE] = file_size
d['Error'] = None
d[UPDATE_AVAILABLE] = 'true'
except Exception as e:
file_name = JSON_GLOABL_PATH+vehicle+"/" + \
vehicle+"-" + \
d[LANGUAGE]+"_v" + \
str(d[VERSION]) + \
JSON_EXT
file_size = None
d[JSON_URL] = file_name
d[FILE_SIZE] = file_size
d['Error'] = e
d[UPDATE_AVAILABLE] = 'false'
d[CUR_VERSION] = float(
current_version)
vehicle_req_list.append(d)
except Exception as e2:
vehicle_req_list.append(
{ERROR: UPDATE_FAILED})
elif current_version > float(data1_global[0]['version']):
if current_version < float(data1[0]['version']):
data = frappe.db.sql('''SELECT name as Name,format(max(version),2) as Version,vehicle_id as Vehicle,language as Language,
release_description as description FROM `tabPublish` where vehicle='{}' and language='{}' and publish_status='Published' and publish_type='{}' and vehicle_status='Active' and version > '{}'
and publish_module='Automotive System' order by version DESC;'''.format(vehicle, l_id, publish_type, current_version), as_dict=1)
try:
for d in data:
try:
file_name = JSON_INT_PATH+vehicle+"/" + \
vehicle+"-" + \
d[LANGUAGE]+"_v" + \
str(d[VERSION]) + \
JSON_EXT
file_size = os.path.getsize(
base_url + file_name)
d[JSON_URL] = file_name
d[FILE_SIZE] = file_size
d['Error'] = None
d[UPDATE_AVAILABLE] = 'true'
except Exception as e:
file_name = JSON_INT_PATH+vehicle+"/" + \
vehicle+"-" + \
d[LANGUAGE]+"_v" + \
str(d[VERSION]) + \
JSON_EXT
file_size = None
d[JSON_URL] = file_name
d[FILE_SIZE] = file_size
d['Error'] = e
d[UPDATE_AVAILABLE] = 'false'
d[CUR_VERSION] = float(
current_version)
vehicle_req_list.append(d)
except Exception as e3:
vehicle_req_list.append(
{'Error': UPDATE_FAILED})
# else:
# vehicle_req_list.append({'Error':"Else 3"})
else:
vehicle_req_list.append(
{LANGUAGE: l_id, UPDATE_AVAILABLE: 'false', CUR_VERSION: float(current_version)})
elif data1 and publish_type == 'Internal':
frappe.log_error(str('internal update'))
data = frappe.db.sql('''SELECT name as Name,format(max(version),2) as Version,vehicle_id as Vehicle,language as Language,release_description as description FROM `tabPublish`
where vehicle='{}' and language='{}' and publish_status='Published' and publish_type='{}' and vehicle_status='Active'
and publish_module='Automotive System'
and version > '{}' order by version DESC;'''.format(vehicle, l_id, publish_type, current_version), as_dict=1)
frappe.log_error(str(data))
try:
for d in data:
try:
file_name = JSON_INT_PATH+vehicle+"/" + \
vehicle+"-"+d[LANGUAGE] + \
"-full_v"+str(d[VERSION])+JSON_EXT
frappe.log_error('full_inernal' +str(file_name))
file_size = os.path.getsize(
base_url + file_name)
d[JSON_URL] = file_name
d[FILE_SIZE] = file_size
d['Error'] = None
d[UPDATE_AVAILABLE] = 'true'
except:
file_name = None
file_size = None
d[JSON_URL] = file_name
d[FILE_SIZE] = file_size
d['Error'] = FILE_ERROR
d[UPDATE_AVAILABLE] = 'false'
d[CUR_VERSION] = float(current_version)
vehicle_req_list.append(d)
except Exception as e2:
vehicle_req_list.append(
{ERROR: UPDATE_FAILED})
if len(vehicle_req_list)!=0:
response['Vehicle'] = vehicle
response['VehicleReqList'] = vehicle_req_list
return response
else:
response['JSON'] = {STATUS: 0, ERROR: "Data Not available"}
return response
except Exception as e:
response['JSON'] = {STATUS: 0, ERROR: UPDATE_FAILED}
return response
else:
return {STATUS: 0, ERROR: "Check Parameter: vehicle list"}
def get_step_total_count(json_path):
with open(json_path) as json_file:

6
smart_service/apis/v2/master.py

@ -250,8 +250,10 @@ def new_publish():
if qp['content']:
qp['content'] = re.sub('<ul>', ul_html,qp['content'] )
qp['content'] = re.sub('<li data-list="bullet">',li_html,qp['content'])
qp['content'] = re.sub('</li>',cling_li,qp['content'])
qp['content'] = re.sub(find_last_ul,cling_last,qp['content'])
clsing_li_tag = re.sub('</li>',cling_li,qp['content'])
qp['content'] = clsing_li_tag
res = re.sub(find_last_ul,cling_last,qp['content'])
qp['content'] = res
cnverted_data = re.sub(CLEANR_back_slash,"'",qp['content'])
qp['content'] = cnverted_data

2
smart_service/phase_2/doctype/special_tool_information/special_tool_information.py

@ -35,7 +35,7 @@ class SpecialToolInformation(Document):
if(d.step_name and (d.content_type == 'Heading')or( d.content_type == 'Description')or(d.content_type == 'Caution')or(d.content_type == 'Warning')or(d.content_type == 'Notice')):
# if(d.step_name and (d.content_type == 'Heading' or d.content_type == 'Description' or d.content_type == 'Caution' or d.content_type == 'Warning' or d.content_type == 'Notice')):
if not d.content:
frappe.throw("Content should not be empty" + str(d.content_type))
frappe.throw(str(d.content_type)+"Content should not be empty")
@frappe.whitelist()

0
smart_service/transactions/doctype/duplicate_kilometer_mapping_items/__init__.py

63
smart_service/transactions/doctype/duplicate_kilometer_mapping_items/duplicate_kilometer_mapping_items.json

@ -0,0 +1,63 @@
{
"actions": [],
"creation": "2023-10-26 15:59:12.521181",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"kilometer",
"mat",
"sub_systems",
"applicable",
"row_name"
],
"fields": [
{
"fieldname": "kilometer",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Kilometer",
"options": "Service Kilometers",
"read_only": 1
},
{
"fieldname": "mat",
"fieldtype": "Data",
"in_list_view": 1,
"label": "MAT",
"read_only": 1
},
{
"fieldname": "sub_systems",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Sub Systems",
"read_only": 1
},
{
"default": "1",
"fieldname": "applicable",
"fieldtype": "Check",
"in_list_view": 1,
"label": "Applicable"
},
{
"fieldname": "row_name",
"fieldtype": "Data",
"hidden": 1,
"label": "Row Name"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-10-26 15:59:12.521181",
"modified_by": "Administrator",
"module": "Transactions",
"name": "Duplicate Kilometer Mapping_Items",
"nsm_parent_field": "parent_kilometer_mapping_items",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC"
}

8
smart_service/transactions/doctype/duplicate_kilometer_mapping_items/duplicate_kilometer_mapping_items.py

@ -0,0 +1,8 @@
# Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors
# For license information, please see license.txt
# import frappe
from frappe.model.document import Document
class DuplicateKilometerMapping_Items(Document):
pass

23
smart_service/transactions/doctype/kilometer_mapping/kilometer_mapping.js

@ -179,6 +179,24 @@ frappe.ui.form.on('Kilometer Mapping', {
frm.refresh();
},
kilometer_filter1: function (frm) {
frm.doc.duplicate_kilometer_mapping_items='';
frm.refresh_field('duplicate_kilometer_mapping_items');
console.log("call")
frappe.call({
"method": "smart_service.transactions.doctype.kilometer_mapping.kilometer_mapping.update_duplicate_km",
"args": {
"doc": frm.doc.name,
"kilometer":frm.doc.kilometer_filter
},
callback: function (r) {
cur_frm.reload_doc()
}
})
},
sub_system_filter: function (frm) {
if (!trigger) { trigger = true; return; }
if (frm.doc.kilometer_filter != "All") {
@ -209,9 +227,8 @@ frappe.ui.form.on('Kilometer Mapping', {
sort_by_kilometer: function (frm) {
var idx = 1;
frm.doc.config_kilometer.sort(function (a, b) {
console.log(a.kilometer + 'Kilometer' + b.kilometer)
if (parseInt(a.kilometer) < parseInt(b.kilometer)) { return -1 }
else if (parseInt(a.kilometer) > parseInt(b.kilometer)) { return 1 }
if (parseInt(a.kilometer) < parseInt(b.kilometer)) { console.log(a.kilometer +"inside if"+ b.kilometer);return -1 }
else if (parseInt(a.kilometer) > parseInt(b.kilometer)) { console.log(a.kilometer + "inside else if" + b.kilometer); return 1 }
return 1;
});

13
smart_service/transactions/doctype/kilometer_mapping/kilometer_mapping.json

@ -26,7 +26,8 @@
"section_break_16",
"sort_by_kilometer",
"temp_field",
"config_kilometer"
"config_kilometer",
"duplicate_kilometer_mapping_items"
],
"fields": [
{
@ -119,6 +120,7 @@
"label": "Filter By"
},
{
"allow_bulk_edit": 1,
"fieldname": "config_kilometer",
"fieldtype": "Table",
"label": "Config Kilometer",
@ -168,11 +170,18 @@
"label": "Language",
"options": "Custom Languages",
"set_only_once": 1
},
{
"fieldname": "duplicate_kilometer_mapping_items",
"fieldtype": "Table",
"hidden": 1,
"label": "Duplicate Kilometer Mapping_Items",
"options": "Duplicate Kilometer Mapping_Items"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-09-26 17:48:09.485301",
"modified": "2023-10-27 10:49:00.008151",
"modified_by": "Administrator",
"module": "Transactions",
"name": "Kilometer Mapping",

17
smart_service/transactions/doctype/kilometer_mapping/kilometer_mapping.py

@ -34,3 +34,20 @@ def get_subsystem(doc):
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):
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']))
km.append('duplicate_kilometer_mapping_items', {
'kilometer': data['kilometer'],
'mat': data['mat'],
'sub_systems': data['sub_systems'],
'row_name': data['row_name']
})
km.save(ignore_permissions=True)

22
smart_service/transactions/doctype/publish/publish.js

@ -19,6 +19,7 @@ cur_frm.fields_dict["vehicle"].get_query = function (doc, cdt, cdn) {
let lang_set_first_time = true;
frappe.ui.form.on("Publish", {
onload: function (frm) {
setTimeout(function mysam(){
$('[data-fieldname="special_tool_publish"]').find('.grid-add-row').css('display', 'none')
$('[data-fieldname="qwik_service_publish"]').find('.grid-add-row').css('display', 'none')
@ -209,7 +210,6 @@ frappe.ui.form.on("Publish", {
}
},
refresh: function (frm) {
setTimeout(function mysam(){
$('[data-fieldname="special_tool_publish"]').find('.grid-add-row').css('display', 'none')
$('[data-fieldname="qwik_service_publish"]').find('.grid-add-row').css('display', 'none')
@ -346,10 +346,10 @@ frappe.ui.form.on("Publish", {
frm.fields_dict.publish_documents.grid.wrapper
.find(".grid-append-row")
.hide();
document.querySelectorAll(
"[data-fieldname='km_report']"
)[1].style.backgroundColor = "#e31a37";
// document.querySelectorAll(
// "[data-fieldname='km_report']"
// )[1].style.backgroundColor = "#e31a37";
// document.querySelectorAll("[data-fieldname='km_report']")[1].style.color =
// "#FFFFFF";
// document.querySelectorAll(
@ -375,9 +375,10 @@ frappe.ui.form.on("Publish", {
},
callback: function (r) {
if (r.message) {
debugger
if (r.message == frm.doc.version) {
frm
.add_custom_button(__("Global Publish"), function () {
debugger
frm.add_custom_button(__("Global Publish"), function () {
frappe.call({
method:
"smart_service.transactions.doctype.publish.publish.global_publish",
@ -396,13 +397,14 @@ frappe.ui.form.on("Publish", {
},
});
}
if (
frm.doc.docstatus === 1 &&
frm.doc.publish_status == "To Publish" &&
frappe.user.has_role("_Publisher") &&
frm.doc.publish_module == "Automotive System"
) {
console.log("call")
frm
.add_custom_button(__("Publish"), function () {
@ -460,6 +462,7 @@ frappe.ui.form.on("Publish", {
},
callback: (r) => {
// frm.save('Update');
// cur_frm.reload_doc()
},
});
frappe.msgprint({
@ -1840,4 +1843,5 @@ function add_special_tool(frm) {
},
});
}
}
}

4
smart_service/transactions/doctype/publish/publish.py

@ -110,7 +110,7 @@ class Publish(Document):
if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Special Tool' and self.publish_type == 'Internal':
special_tool_publish(self.vehicle, self.vehicle_id,
self.publish_type,
self.publish_type,
self.release_description,
self.special_tool_publish_docs)
update_publish_status = frappe.db.sql(
@ -506,7 +506,7 @@ def get_system(doc, name, lang):
@frappe.whitelist()
def max_publish(doc):
doc = frappe.get_doc("Publish", doc)
ver = frappe.db.sql("""select max(version) from {0}.tabPublish where vehicle = "{1}" and language = "{2}";""".format(
ver = frappe.db.sql("""select max(version) from {0}.tabPublish where vehicle = "{1}" and language = "{2}" and publish_module = "Automotive System";""".format(
current_db_name, doc.vehicle, doc.language))
if ver:
return ver

Loading…
Cancel
Save