Browse Source

Publish update and release 1 fix

version2
venkataakhil 1 year ago
parent
commit
baeede25f3
  1. 3
      smart_service/apis/addon_api.py
  2. 368
      smart_service/apis/app_user_login.py
  3. 23
      smart_service/apis/update_validation.py
  4. 6
      smart_service/masters/doctype/app_labels/app_labels.js
  5. 31
      smart_service/masters/doctype/role_master/role_master.js
  6. 100
      smart_service/phase_2/doctype/feature_finder/feature_finder.js
  7. 4
      smart_service/phase_2/doctype/feature_finder/feature_finder.json
  8. 25
      smart_service/phase_2/doctype/feature_finder/feature_finder.py
  9. 4
      smart_service/phase_2/doctype/feature_finder_master/feature_finder_master.json
  10. 4
      smart_service/phase_2/doctype/feature_finder_publish_data/feature_finder_publish_data.json
  11. 4
      smart_service/phase_2/doctype/feature_finder_publish_docs/feature_finder_publish_docs.json
  12. 4
      smart_service/phase_2/doctype/module_publish_mapping/module_publish_mapping.json
  13. 5
      smart_service/phase_2/doctype/mst_information_assets/mst_information_assets.json
  14. 64
      smart_service/phase_2/doctype/special_tool_information/special_tool_information.js
  15. 2
      smart_service/phase_2/doctype/special_tool_information/special_tool_information.json
  16. 33
      smart_service/phase_2/doctype/training_information/training_information.js
  17. 40
      smart_service/public/js/common_fun.js
  18. 700
      smart_service/transactions/doctype/publish/publish.js
  19. 5
      smart_service/transactions/doctype/publish/publish.json
  20. 384
      smart_service/transactions/doctype/publish/publish.py

3
smart_service/apis/addon_api.py

@ -99,8 +99,9 @@ def addon(args=None):
return api
@frappe.whitelist()
@frappe.whitelist(allow_guest=1)
def bookmark(args=None, request=None):
frappe.set_user('Administrator')
rate_res = custom_rate_limit(limit=5, seconds=15)
if rate_res != 1:
return rate_res

368
smart_service/apis/app_user_login.py

@ -416,152 +416,16 @@ def grant_user_access(userdata=None, iid=None):
@frappe.whitelist(allow_guest=True)
def new_app_user_validation(usr=None, pwd=None, iid=None, device_data=None):
def new_grant_user_access(userdata=None, iid=None):
rate_res = custom_rate_limit(limit=5, seconds=15)
if rate_res != 1:
return rate_res
val = input_validation(usr=usr, pwd=pwd, iid=iid, device_data=device_data)
val = input_validation(userdata=userdata, iid=iid)
if val != '':
return {'status': 0, 'error': "Parameter's missing: " + val}
preference = frappe.get_last_doc('App Preference')
mahindra_login = preference.mahindra_login_api
technician_login = preference.technician_login_api
# ISmartAuth API - Email available
device_data = json.loads(device_data)
try:
data = {'LoginID': usr, 'Password': pwd}
headers = {"Content-Type": "application/x-www-form-urlencoded"}
if technician_login == 1 and mahindra_login == 0:
response = requests.post(
"http://www.mahindramile.com/ISmartAuth/Service.asmx/ValidateCredential", data=data, headers=headers)
decoded = response.content.decode('utf-8')
if len(decoded) > 165:
frappe.set_user("Administrator")
da = re.search("{", decoded)
da1 = re.search("}", decoded)
trunData = decoded[da.span()[0]:da1.span()[1]]
dicData = json.loads(trunData)
if dicData['ID'] == "":
dicData['ID'] = "100"
dicData.update(device_data)
return new_grant_user_access(dicData, iid)
else:
return {'status': 0, 'error': 'Invalid Credentials'}
elif technician_login == 0 and mahindra_login == 1:
response1 = requests.post("http://www.mahindramile.com/WindowAuth/Service.asmx/ValidateCredential",
data=data, headers=headers)
decoded1 = response1.content.decode('utf-8')
node = ET.fromstring(decoded1)
dictValue = xml_to_dict(node)
frappe.set_user("Administrator")
dicData = {
"ID": "{}@email.com".format(usr),
"LoginName": usr,
"FirstName": usr,
"LastName": "",
"IsActive": "True",
"UserType": "",
"SkillID": "",
"SkillName": "",
"UserTypeDesc": "",
"PasswordChanged": "",
"AreaName": "",
"Zone": "",
"Code": "",
"LocationName": "",
"ChannelNo": "",
"ServerDate": "",
"ServerTime": "",
"DealerName": "",
"EmailId": "{}@email.com".format(usr),
"isLDAPAuthenticated": ""}
dicData.update(device_data)
msgDic = {}
try:
msgDic['UserName'] = dictValue['children']['UserName']['text']
msgDic['IsSuccessfull'] = dictValue['children']['IsSuccessfull']['text']
if dicData['ID'] == "":
dicData['ID'] = "100"
return new_grant_user_access(dicData, iid)
except:
msgDic['IsSuccessfull'] = node.text
return {'status': 0, 'error': 'Invalid Credentials'}
elif technician_login == 1 and mahindra_login == 1:
response = requests.post(
"http://www.mahindramile.com/ISmartAuth/Service.asmx/ValidateCredential", data=data, headers=headers)
decoded = response.content.decode('utf-8')
response1 = requests.post("http://www.mahindramile.com/WindowAuth/Service.asmx/ValidateCredential",
data=data, headers=headers)
decoded1 = response1.content.decode('utf-8')
node = ET.fromstring(decoded1)
dictValue = xml_to_dict(node)
dicData = {
"ID": "",
"LoginName": usr,
"FirstName": usr,
"LastName": "",
"IsActive": "True",
"UserType": "",
"SkillID": "",
"SkillName": "",
"UserTypeDesc": "Mahindra User",
"PasswordChanged": "",
"AreaName": "Mahindra",
"Zone": "Mahindra",
"LocationName": "Mahindra",
"ChannelNo": "",
"ServerDate": "",
"ServerTime": "",
"DealerName": "Mahindra",
"EmailId": "{}@mahindra.com".format(usr),
"isLDAPAuthenticated": ""}
msgDic = {}
if len(decoded) > 165:
frappe.set_user("Administrator")
da = re.search("{", decoded)
da1 = re.search("}", decoded)
trunData = decoded[da.span()[0]:da1.span()[1]]
dicData = json.loads(trunData)
dicData['Code'] = ""
if dicData['ID'] == "":
dicData['ID'] = "100"
dicData.update(device_data)
return new_grant_user_access(dicData, iid)
else:
frappe.set_user("Administrator")
msgDic['UserName'] = dictValue['children']['UserName']['text']
msgDic['IsSuccessfull'] = dictValue['children']['IsSuccessfull']['text']
if dicData['ID'] == "":
dicData['ID'] = "100"
dicData['Code'] = ''
dicData.update(device_data)
return new_grant_user_access(dicData, iid)
else:
return {'status': 0, 'error': 'Login Blocked'}
except:
return {'status': 0, 'error': 'Site Error'}
def new_grant_user_access(userdata=None, iid=None):
rate_res = custom_rate_limit(limit=5, seconds=15)
if rate_res != 1:
return rate_res
try:
userdata = json.loads(userdata)
user_id = userdata['ID']
email = userdata['EmailId']
first_name = userdata['FirstName']
@ -592,15 +456,17 @@ def new_grant_user_access(userdata=None, iid=None):
frappe.set_user("Administrator")
user_name = frappe.db.sql('''SELECT name FROM {0}.tabUser where email='{1}';'''.format(
current_db_name, email), as_dict=1)
# return user_name
if user_name:
token = generate_keys(user_name[0]['name'])
""" New Refresh token update """
access_token = generate_access_token(user_name[0]['name'])
refresh_token = generate_refresh_token()
token_details = update_tokens_in_doc(
user_name[0]['name'], access_token, refresh_token)
# token = generate_keys(user_name[0]['name'])
try:
""" New Refresh token update """
access_token = generate_access_token(user_name[0]['name'])
refresh_token = generate_refresh_token()
token_details = update_tokens_in_doc(
user_name[0]['name'], access_token, refresh_token)
except:
return {'status': 0, 'error': "Failed to Create token"}
else:
user = frappe.new_doc('User')
@ -615,13 +481,15 @@ def new_grant_user_access(userdata=None, iid=None):
user_name = frappe.db.sql('''SELECT name FROM {0}.tabUser where email='{1}';'''.format(
current_db_name, email), as_dict=1)
if user_name:
token = generate_keys(user_name[0]['name'])
""" New Refresh token update """
access_token = generate_access_token(user_name[0]['name'])
refresh_token = generate_refresh_token()
token_details = update_tokens_in_doc(
user_name[0]['name'], access_token, refresh_token)
# token = generate_keys(user_name[0]['name'])
try:
""" New Refresh token update """
access_token = generate_access_token(user_name[0]['name'])
refresh_token = generate_refresh_token()
token_details = update_tokens_in_doc(
user_name[0]['name'], access_token, refresh_token)
except:
return {'status': 0, 'error': "Failed to Create token"}
'''Inserting Dealer Data'''
if frappe.db.exists({'doctype': 'App Dealer', 'dealer_code': dealer_code}):
@ -760,11 +628,182 @@ def new_grant_user_access(userdata=None, iid=None):
user_details = {}
user_details['Installation ID'] = lst[0][0]
user_details['User ID'] = lst1[0][0]
user_details['token'] = token
# user_details['token'] = token
user_details['status'] = 1
user_details['token_details'] = token_details
return user_details
except Exception as e1:
return {'status': 0, 'error': 'Failed to verify user'}
return {'status': 0, 'error': "Invalid Inputs"}
@frappe.whitelist(allow_guest=True)
def new_app_user_validation(usr=None, pwd=None, iid=None, device_data=None):
rate_res = custom_rate_limit(limit=5, seconds=15)
if rate_res != 1:
return rate_res
val = input_validation(usr=usr, pwd=pwd, iid=iid, device_data=device_data)
if val != '':
return {'status': 0, 'error': "Parameter's missing: " + val}
preference = frappe.get_last_doc('App Preference')
mahindra_login = preference.mahindra_login_api
technician_login = preference.technician_login_api
# ISmartAuth API - Email available
device_data = json.loads(device_data)
try:
data = {'LoginID': usr, 'Password': pwd}
headers = {"Content-Type": "application/x-www-form-urlencoded"}
if technician_login == 1 and mahindra_login == 0:
response = requests.post(
"http://www.mahindramile.com/ISmartAuth/Service.asmx/ValidateCredential", data=data, headers=headers)
decoded = response.content.decode('utf-8')
if len(decoded) > 165:
frappe.set_user("Administrator")
da = re.search("{", decoded)
da1 = re.search("}", decoded)
trunData = decoded[da.span()[0]:da1.span()[1]]
dicData = json.loads(trunData)
if dicData['ID'] == "":
dicData['ID'] = "100"
dicData.update(device_data)
return new_grant_user_access(dicData, iid)
else:
return {'status': 0, 'error': 'Invalid Credentials'}
elif technician_login == 0 and mahindra_login == 1:
response1 = requests.post("http://www.mahindramile.com/WindowAuth/Service.asmx/ValidateCredential",
data=data, headers=headers)
decoded1 = response1.content.decode('utf-8')
node = ET.fromstring(decoded1)
dictValue = xml_to_dict(node)
frappe.set_user("Administrator")
dicData = {
"ID": "{}@email.com".format(usr),
"LoginName": usr,
"FirstName": usr,
"LastName": "",
"IsActive": "True",
"UserType": "",
"SkillID": "",
"SkillName": "",
"UserTypeDesc": "",
"PasswordChanged": "",
"AreaName": "",
"Zone": "",
"Code": "",
"LocationName": "",
"ChannelNo": "",
"ServerDate": "",
"ServerTime": "",
"DealerName": "",
"EmailId": "{}@email.com".format(usr),
"isLDAPAuthenticated": ""}
dicData.update(device_data)
msgDic = {}
try:
msgDic['UserName'] = dictValue['children']['UserName']['text']
msgDic['IsSuccessfull'] = dictValue['children']['IsSuccessfull']['text']
if dicData['ID'] == "":
dicData['ID'] = "100"
return new_grant_user_access(dicData, iid)
except:
msgDic['IsSuccessfull'] = node.text
return {'status': 0, 'error': 'Invalid Credentials'}
elif technician_login == 1 and mahindra_login == 1:
response = requests.post(
"http://www.mahindramile.com/ISmartAuth/Service.asmx/ValidateCredential", data=data, headers=headers)
decoded = response.content.decode('utf-8')
response1 = requests.post("http://www.mahindramile.com/WindowAuth/Service.asmx/ValidateCredential",
data=data, headers=headers)
decoded1 = response1.content.decode('utf-8')
node = ET.fromstring(decoded1)
dictValue = xml_to_dict(node)
dicData = {
"ID": "",
"LoginName": usr,
"FirstName": usr,
"LastName": "",
"IsActive": "True",
"UserType": "",
"SkillID": "",
"SkillName": "",
"UserTypeDesc": "Mahindra User",
"PasswordChanged": "",
"AreaName": "Mahindra",
"Zone": "Mahindra",
"LocationName": "Mahindra",
"ChannelNo": "",
"ServerDate": "",
"ServerTime": "",
"DealerName": "Mahindra",
"EmailId": "{}@mahindra.com".format(usr),
"isLDAPAuthenticated": ""}
msgDic = {}
if len(decoded) > 165:
frappe.set_user("Administrator")
da = re.search("{", decoded)
da1 = re.search("}", decoded)
trunData = decoded[da.span()[0]:da1.span()[1]]
dicData = json.loads(trunData)
dicData['Code'] = ""
if dicData['ID'] == "":
dicData['ID'] = "100"
dicData.update(device_data)
return new_grant_user_access(dicData, iid)
else:
frappe.set_user("Administrator")
msgDic['UserName'] = dictValue['children']['UserName']['text']
msgDic['IsSuccessfull'] = dictValue['children']['IsSuccessfull']['text']
if dicData['ID'] == "":
dicData['ID'] = "100"
dicData['Code'] = ''
dicData.update(device_data)
return new_grant_user_access(dicData, iid)
else:
return {'status': 0, 'error': 'Login Blocked'}
except:
return {'status': 0, 'error': 'Site Error'}
@frappe.whitelist(allow_guest=True)
def data_invalidation(email, device_id, iid=None):
rate_res = custom_rate_limit(limit=5, seconds=15)
if rate_res != 1:
return rate_res
try:
# User validation
frappe.set_user("Administrator")
user_name = frappe.db.sql('''SELECT name FROM {0}.tabUser where email='{1}';'''.format(
current_db_name, email), as_dict=1)
token_details = []
if user_name:
""" New Refresh token update """
access_token = generate_access_token(user_name[0]['name'])
refresh_token = generate_refresh_token()
token_details = update_tokens_in_doc(
user_name[0]['name'], access_token, refresh_token)
return {'status': 1, 'data': token_details, 'error': None}
except Exception as e1:
return {'status': 0, 'data': [], 'error': 'Failed to verify user'}
@frappe.whitelist(allow_guest=1)
@ -857,19 +896,18 @@ def generate_refresh_token():
@frappe.whitelist(allow_guest=1, methods=['POST'])
def refresh_token():
""" For Refresh API """
# rate_res = custom_rate_limit(limit=5, seconds=15)
# if rate_res != 1:
# return rate_res
frappe.set_user("Administrator")
req = frappe.request.data
req = json.loads(req)
refresh_token= req['refresh_token']
refresh_token = req['refresh_token']
if refresh_token:
device_id= req['DeviceID']
device_id = req['DeviceID']
ref_token = refresh_token
doc_details = frappe.db.sql('''
SELECT * FROM `tabRefresh Token`;''', as_dict=1)
@ -918,7 +956,7 @@ def invalidate_token(refresh_token):
return {'status': 0, "error": 'Failed'}
@frappe.whitelist(allow_guest=1,methods=['POST'])
@frappe.whitelist(allow_guest=1, methods=['POST'])
def deactivate_account(refresh_token):
rate_res = custom_rate_limit(limit=5, seconds=15)
if rate_res != 1:
@ -944,7 +982,6 @@ def deactivate_account(refresh_token):
return {'status': 0, "error": 'Failed'}
def update_tokens_in_doc(user_email, access, refresh):
# access_exp_hours = 15 * 60
# refresh_exp_hrs = 60 * 60 * 24
@ -982,9 +1019,9 @@ def update_tokens_in_doc(user_email, access, refresh):
frappe.db.commit()
user_token_details['access_token'] = access
user_token_details['access_expiry_time'] = access_exp_hours* 60
user_token_details['access_expiry_time'] = access_exp_hours * 60
user_token_details['refresh_token'] = refresh
user_token_details['refresh_expiry_time'] = refresh_exp_hrs* 60 * 60
user_token_details['refresh_expiry_time'] = refresh_exp_hrs * 60 * 60
return user_token_details
@ -1048,4 +1085,3 @@ def deactivate_tokens():
except Exception as e:
return e

23
smart_service/apis/update_validation.py

@ -173,11 +173,13 @@ def check_vehicle_update(vehicle_list=None):
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='{}'
and publish_status='Published' and publish_type='Global' and vehicle_status='Active'
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
publish_status='Published' and vehicle_status='Active'
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']:
if data1[0]['version'] is not None:
@ -193,7 +195,8 @@ def check_vehicle_update(vehicle_list=None):
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 > '{}' order by version ASC;'''.format(vehicle, l_id, current_version), as_dict=1)
vehicle_status='Active' and Version > '{}'
and publish_module='Automotive System' order by version ASC;'''.format(vehicle, l_id, current_version), as_dict=1)
try:
for d in data:
try:
@ -226,7 +229,8 @@ def check_vehicle_update(vehicle_list=None):
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 > '{}' order by version ASC;'''.format(vehicle, l_id, current_version), as_dict=1)
and Version > '{}' and publish_module='Automotive System'
order by version ASC;'''.format(vehicle, l_id, current_version), as_dict=1)
try:
for d in data:
file_name = None
@ -261,7 +265,8 @@ def check_vehicle_update(vehicle_list=None):
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 > '{}' order by version ASC;'''.format(vehicle, l_id, publish_type, current_version), as_dict=1)
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)
try:
for d in data:
try:
@ -296,6 +301,7 @@ def check_vehicle_update(vehicle_list=None):
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)
try:
for d in data:
@ -334,7 +340,8 @@ 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 > '{}'
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)
try:
for d in data:
@ -378,6 +385,7 @@ def check_vehicle_update(vehicle_list=None):
else:
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 publish_module='Automotive System'
and version > '{}' order by version ASC;'''.format(vehicle, l_id, publish_type, current_version), as_dict=1)
try:
for d in data:
@ -479,7 +487,8 @@ def calculate_step(data):
def get_publish_ver(vehicle, l_id):
return frappe.db.sql('''SELECT format(max(version),2) as version,publish_type as version,vehicle_id,language FROM `tabPublish` where vehicle='{}' and language='{}' and
publish_status='Published' and vehicle_status='Active' ;'''.format(vehicle, l_id), as_dict=1)
publish_status='Published' and vehicle_status='Active'
and publish_module='Automotive System' ;'''.format(vehicle, l_id), as_dict=1)
@frappe.whitelist()

6
smart_service/masters/doctype/app_labels/app_labels.js

@ -39,7 +39,7 @@ frappe.ui.form.on('App Labels', {
frappe.throw(__("Just a <b>.</b> is not prescribed!"));
frappe.validated = false;
}
var regex = /[!@#$%^&*()+\=\[\]{};`~':"\\|.<>\/]+/;
var regex = /[!@#$%^&*()+\=\[\]{};`~'"\\|.<>\/]+/;
if (frm.doc.english_label) {
if (regex.test(frm.doc.english_label) === true) {
frappe.throw(__("<b>English Label :</b> Only letters, numbers and <b> - , </b> are allowed."));
@ -66,7 +66,7 @@ frappe.ui.form.on('App Labels', {
frappe.throw(__("Just a <b>.</b> is not prescribed!"));
frappe.validated = false;
}
var regex = /[!@#$%^&*()+\=\[\]{};`~':"\\|.<>\/?]+/;
var regex = /[!@#$%^&*()+\=\[\]{};`~'"\\|.<>\/?]+/;
if (frm.doc.page_name) {
if (regex.test(frm.doc.page_name) === true) {
frappe.throw(__("<b>Page Name :</b> Only letters, numbers and <b> -,</b> are allowed."));
@ -93,7 +93,7 @@ frappe.ui.form.on('App Labels', {
frappe.throw(__("Just a <b>.</b> is not prescribed!"));
frappe.validated = false;
}
var regex = /[!@#$%^&*()+\=\[\]{};`~':"\\|.<>\/]+/;
var regex = /[!@#$%^&*()+\=\[\]{};`~'"\\|.<>\/]+/;
if (frm.doc.label) {
if (regex.test(frm.doc.label) === true) {
frappe.throw(__("<b>Translated Label :</b> Only letters, numbers and <b> -,</b> are allowed."));

31
smart_service/masters/doctype/role_master/role_master.js

@ -53,19 +53,41 @@ frappe.ui.form.on('Role Master', {
if (r.message) {
let res = cur_frm.fields_dict.module_master_html.$wrapper.empty()
let module_html = "<div class='module-container' style='float:left;display:flex'>"
module_html = "<div class='row' style='margin-left:5px !important;'>"
module_html += "<div class='row' style='margin-left:5px !important;'>"
r.message.map(val => {
var id_name = (val.name).replace(" ","_")
id_name = id_name.toLowerCase()
if (!frm.is_new() && frm.doc.modules && frm.doc.modules.includes(val.module_name)) {
module_html += "<div class='col-3' style='padding-left:0px !important;padding-right:0px !important'>"
module_html += "<input type='checkbox' id=" + "'" + val.name + "'" + " name='vehicle1' value=" + "'" + val.module_name + "'" + " checked>"
module_html += "<input type='checkbox' id=" + "'" + id_name + "'" + " name='vehicle1' value=" + "'" + val.module_name + "'" + " checked>"
module_html += "<label for=" + val.name + " style='padding-right:20px'>" + val.module_name + "</label></div>"
} else {
module_html += "<div class='col-3' style='padding-left:0px !important;padding-right:0px !important'>"
module_html += "<input type='checkbox' id=" + "'" + val.name + "'" + " name='vehicle1' value=" + "'" + val.module_name + "'" + " >"
module_html += "<input type='checkbox' id=" + "'" + id_name + "'" + " name='vehicle1' value=" + "'" + val.module_name + "'" + " >"
module_html += "<label for=" + val.name + " style='padding-right:20px'>" + val.module_name + "</label></div>"
}
})
res.append(module_html)
// $( document ).ready(function() {
// console.log(":hiiiii")
// console.log( $("#automotive_system input:checkbox"))
// $("#automotive_system").click(function(){
// if($(this).is(':checked')){
// $("#component").prop('checked', true);
// $("#feature_finder").prop('checked', true);
// $("#symptom").prop('checked', true);
// }
// else{
// $("#component").prop('checked', false)
// $("#feature_finder").prop('checked', false);
// $("#symptom").prop('checked', false);
// }
// });
// });
}
}
})
@ -77,6 +99,9 @@ frappe.ui.form.on('Role Master', {
validate: function (frm) {
//check html if has Module name value
var val = ""
$(':checkbox:checked').each(function (i) {
let value = $(this).val();

100
smart_service/phase_2/doctype/feature_finder/feature_finder.js

@ -109,34 +109,32 @@ frappe.ui.form.on('Feature Finder', {
var spec_id_dis = []
var image_id_dis = []
var cont_id_dis = []
$(document).ready(function () {
$('.specification_bl').find('table > tbody > tr').each(function (index, tr) {
spec_id_dis.push(this.id);
});
if(spec_id_dis && spec_id_dis.length>0){
console.log(spec_id_dis,"----spec_id_dis")
set_display_order_child("Feature Finder Specification", spec_id_dis)
}
})
$(document).ready(function () {
$('.feature_imgbl').find('table > tbody > tr').each(function (index, tr) {
image_id_dis.push(this.id);
});
if(image_id_dis && image_id_dis.length>0){
console.log(image_id_dis,"----image_id_dis")
set_display_order_child("Feature Finder Images", image_id_dis)
}
})
$(document).ready(function () {
$('.feature_contbl').find('table > tbody > tr').each(function (index, tr) {
cont_id_dis.push(this.id);
});
if(cont_id_dis && cont_id_dis.length>0){
console.log(cont_id_dis,"----cont_id_dis")
set_display_order_child("Feature Finder Content", cont_id_dis)
}
})
//end swap child table
if (frm.doc.language == "en") {
@ -187,7 +185,6 @@ frappe.ui.form.on('Feature Finder', {
}
});
function set_display_order_child(doctype_name, values) {
console.log(doctype_name,values)
if (values.length>0){
frappe.call({
method: "smart_service.phase_2.doctype.feature_finder.feature_finder.set_display_order",
@ -196,9 +193,9 @@ function set_display_order_child(doctype_name, values) {
values: values
},
callback: function (r) {
console.log(r.message,"r.message")
if (r.message.status == "success") {
cur_frm.reload_doc()
if (r.message) {
// console.log(r.message,"---r.message")
cur_frm.refresh()
}
}
})
@ -218,7 +215,7 @@ function show_images(frm) {
img_html += "<div class='col-3' style='padding-top:13px;'><img src=" + "'" + val.image + "'" + "></div>"
}
});
console.log(frm.doc.feature_finder_images,"---")
img_html += "</div></div>"
$(res).append(img_html)
}
@ -356,6 +353,23 @@ function custom_tab_html(frm) {
function all_tabs() {
//heading
// var spec_custom_dt = ""
// spec_custom_dt += `<label class="control-label">Specification</label><table class="table table-bordered table-editable spec-table" style='margin:0px !important'>
// <thead>
// <tr>
// <th style="width: 7%;" class="specifiction"><input type="checkbox" id="checkAll"' class="grid-row-check pull-left"><span class='spec_check'>No</span></th>
// <th>Specification</th>
// <th>Value</th>
// <th>Active Status</th>
// <th id='postvin1'>Post Vin CutOff Name</th>
// <th><a><svg class="icon icon-sm" style="filter: opacity(0.5)">
// <use class="" href="#icon-setting-gear"></use>
// </svg></a></th>
// </tr>
// </thead>`
spec_custom_dt += "<tbody>"
var spec_custom_dt = ""
spec_custom_dt += `<label class="control-label">Specification</label><table class="table table-bordered table-editable spec-table" style='margin:0px !important'>
<thead>
@ -365,7 +379,6 @@ function custom_tab_html(frm) {
<th>Value</th>
<th>Active Status</th>
<th id='postvin1'>Post Vin CutOff Name</th>
<th><a><svg class="icon icon-sm" style="filter: opacity(0.5)">
<use class="" href="#icon-setting-gear"></use>
</svg></a></th>
@ -382,7 +395,6 @@ function custom_tab_html(frm) {
<th>Image</th>
<th>Active Status</th>
<th id='postvin2'>Post Vin CutOff Name</th>
<th><a><svg class="icon icon-sm" style="filter: opacity(0.5)">
<use class="" href="#icon-setting-gear"></use>
</svg></a></th>
@ -399,7 +411,6 @@ function custom_tab_html(frm) {
<th>Content</th>
<th>Active Status</th>
<th id='postvin3'>Post Vin CutOff Name</th>
<th><a><svg class="icon icon-sm" style="filter: opacity(0.5)">
<use class="" href="#icon-setting-gear"></use>
</svg></a></th>
@ -417,19 +428,19 @@ function custom_tab_html(frm) {
if (specification.length > 0) {
specification.map(val => {
specification_count += 1
spec_custom_dt += '<tr id=' + val.name + ' draggable="true" ondragstart="dragstartFunction(event)" ondragover="dragovertFunction(event)">'
spec_custom_dt += '<tr id=' + val.name + ' draggable="true" ondragstart="dragstartFunction(event)" ondragover="dragovertFunction(event)" class="dragclass">'
// spec_custom_dt += '<tr>'
spec_custom_dt += '<td style="width: 7%;" id="spec_count"><input id=' + val.name + ' type="checkbox" class="speccheck grid-row-check pull-left"><span class="spec_check">' + specification_count + '</span></td>'
spec_custom_dt += '<td>' + val.specification + '</td>'
spec_custom_dt += '<td>' + val.value + '</td>'
spec_custom_dt += '<td>' + val.active_status + '</td>'
// spec_custom_dt += '<td>' + val.feature_type + '</td>'
if (val.post_vin_cutoff_name) {
spec_custom_dt += '<td>' + val.post_vin_cutoff_name + '</td>'
}
else {
// if (val.post_vin_cutoff_name) {
// spec_custom_dt += '<td>' + val.post_vin_cutoff_name + '</td>'
// }
// else {
// spec_custom_dt += '<td> </td>'
}
// }
spec_custom_dt += '<td id=' + val.name + ' class="spec_edit_row"><a><svg class="icon icon-xs" style=""><use class="" href="#icon-edit"></use></svg>Edit</a></td>'
@ -445,18 +456,18 @@ function custom_tab_html(frm) {
if (feature_finder_images.length) {
feature_finder_images.map(val => {
image_count += 1
image_custom_dt += '<tr id=' + val.name + ' draggable="true" ondragstart="dragstartFunction_1(event)" ondragover="dragovertFunction_1(event)">'
image_custom_dt += '<tr id=' + val.name + ' draggable="true" ondragstart="dragstartFunction_1(event)" ondragover="dragovertFunction_1(event)" class="dragclass">'
// image_custom_dt += '<tr>'
image_custom_dt += '<td style="width: 7%;" id="image_count"><input id=' + val.name + ' type="checkbox" class="imagecheck grid-row-check pull-left"><span class="image_check">' + image_count + '</span></td>'
image_custom_dt += '<td>' + val.image + '</td>'
image_custom_dt += '<td>' + val.active_status + '</td>'
// image_custom_dt += '<td>' + val.feature_type + '</td>'
if (val.post_vin_cutoff_name) {
image_custom_dt += '<td>' + val.post_vin_cutoff_name + '</td>'
}
else {
// if (val.post_vin_cutoff_name) {
// image_custom_dt += '<td>' + val.post_vin_cutoff_name + '</td>'
// }
// else {
// image_custom_dt += '<td> </td>'
}
// }
image_custom_dt += '<td id=' + val.name + ' class="image_edit_row"><a><svg class="icon icon-xs" style=""><use class="" href="#icon-edit"></use></svg>Edit</a></td>'
image_custom_dt += '</tr>'
@ -471,18 +482,18 @@ function custom_tab_html(frm) {
if (feature_finder_content.length) {
feature_finder_content.map(val => {
content_count += 1
content_custom_dt += '<tr id=' + val.name + ' draggable="true" ondragstart="dragstartFunction_2(event)" ondragover="dragovertFunction_2(event)">'
content_custom_dt += '<tr id=' + val.name + ' draggable="true" ondragstart="dragstartFunction_2(event)" ondragover="dragovertFunction_2(event)" class="dragclass">'
// content_custom_dt += '<tr>'
content_custom_dt += '<td style="width: 7%;" id="cont_count"><input id=' + val.name + ' type="checkbox" class="contentcheck grid-row-check pull-left"><span class="content_check">' + content_count + '</span></td>'
content_custom_dt += '<td>' + val.content + '</td>'
content_custom_dt += '<td>' + val.active_status + '</td>'
// content_custom_dt += '<td>' + val.feature_type + '</td>'
if (val.post_vin_cutoff_name) {
content_custom_dt += '<td>' + val.post_vin_cutoff_name + '</td>'
}
else {
// if (val.post_vin_cutoff_name) {
// content_custom_dt += '<td>' + val.post_vin_cutoff_name + '</td>'
// }
// else {
// content_custom_dt += '<td> </td>'
}
// }
content_custom_dt += '<td id=' + val.name + ' class="content_edit_row"><a><svg class="icon icon-xs" style=""><use class="" href="#icon-edit"></use></svg>Edit</a></td>'
content_custom_dt += '</tr>'
@ -571,12 +582,14 @@ function custom_tab_html(frm) {
//save function
// $(res).find('.specification_bl').click(function (event) {
// frm.doc.__unsaved = 0
// })
// $(res).find('.feature_imgbl').click(function (event) {
// frm.doc.__unsaved = 0
// })
// $(document).ready(function () {
// $('.specification_bl').find('.dragclass').click(function (event) {
// frm.doc.__unsaved = 0
// })
// $('.feature_imgbl').find('.dragclass').click(function (event) {
// frm.doc.__unsaved = 0
// })
// });
$(res).find('.specification_bl').find('.spec_custom_save').click(function (event) {
var spec_id_dis = []
@ -892,6 +905,7 @@ function custom_tab_html(frm) {
fieldtype: 'Data',
default: spec_dialog_value.post_vin_cutoff_name,
depends_on: "eval:doc.feature_type=='Post Vin CutOff'",
hidden:1
},
],
@ -962,7 +976,8 @@ function custom_tab_html(frm) {
fieldtype: 'Data',
default: image_dialog_value.post_vin_cutoff_name,
depends_on: "eval:doc.feature_type=='Post Vin CutOff'",
read_only: 1
read_only: 1,
hidden:1
},
],
// size: 'small', // small, large, extra-large
@ -1032,7 +1047,8 @@ function custom_tab_html(frm) {
fieldtype: 'Data',
default: content_dialog_value.post_vin_cutoff_name,
depends_on: "eval:doc.feature_type=='Post Vin CutOff'",
read_only: 1
read_only: 1,
hidden:1
},
],
// size: 'small', // small, large, extra-large

4
smart_service/phase_2/doctype/feature_finder/feature_finder.json

@ -119,7 +119,7 @@
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Active Status",
"options": "Active\nIn Active"
"options": "Active\nInactive"
},
{
"fieldname": "specification",
@ -196,7 +196,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-08-22 11:07:57.233280",
"modified": "2023-08-28 11:16:20.751560",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Feature Finder",

25
smart_service/phase_2/doctype/feature_finder/feature_finder.py

@ -249,17 +249,19 @@ def set_display_order(doctype_name, values):
count_val = 0
for k in val:
count_val += 1
frappe.msprint(str(k)+"--"+str(doctype_name))
res = frappe.get_doc(doctype_name, k)
# frappe.msgprint(str(k)+"-"+str(count_val))
res.display_order = count_val
res.save()
frappe.db.commit()
frappe.log_error("k",(str(k)))
if k:
res = frappe.get_doc(doctype_name, k)
# frappe.msgprint(str(k)+"-"+str(count_val))
res.display_order = count_val
res.save()
frappe.db.commit()
return {"status": "success"}
else:
return{"status":"fail"}
except Exception as e:
frappe.log_error("set_display_order", str(e))
frappe.log_error("set_display_order", frappe.get_traceback())
pass
@ -272,6 +274,9 @@ def get_specification_list():
@frappe.whitelist()
def insert_tab_ref(docname,tab_ref):
if docname and tab_ref:
frappe.db.sql(f"""UPDATE `tabFeature Finder` set tab_ref='{tab_ref}' WHERE name ='{docname}'""")
frappe.db.commit()
try:
if docname and tab_ref:
frappe.db.sql(f"""UPDATE `tabFeature Finder` set tab_ref='{tab_ref}' WHERE name ='{docname}'""")
frappe.db.commit()
except Exception as e:
frappe.log_error("insert_tab",frappe.get_traceback())

4
smart_service/phase_2/doctype/feature_finder_master/feature_finder_master.json

@ -30,7 +30,7 @@
{
"fieldname": "feature_pdf",
"fieldtype": "Attach",
"label": "PDF"
"label": "Compare PDF"
},
{
"fieldname": "feature_finder_disclaimer",
@ -75,7 +75,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-08-14 18:38:57.870551",
"modified": "2023-08-22 14:02:41.878119",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Feature Finder Master",

4
smart_service/phase_2/doctype/feature_finder_publish_data/feature_finder_publish_data.json

@ -61,7 +61,7 @@
"fieldtype": "Select",
"in_list_view": 1,
"label": "Active Status",
"options": "Active\nIn Active",
"options": "Active\nInactive",
"read_only": 1
},
{
@ -135,7 +135,7 @@
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-08-22 10:45:25.154430",
"modified": "2023-08-28 11:26:13.293732",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Feature Finder Publish Data",

4
smart_service/phase_2/doctype/feature_finder_publish_docs/feature_finder_publish_docs.json

@ -48,7 +48,7 @@
"fieldtype": "Select",
"in_list_view": 1,
"label": "Active Status",
"options": "Active\nIn Active"
"options": "Active\nInactive"
},
{
"fetch_from": "variant.vehicle",
@ -108,7 +108,7 @@
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-08-22 11:39:51.208775",
"modified": "2023-08-28 11:23:50.811405",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Feature Finder Publish Docs",

4
smart_service/phase_2/doctype/module_publish_mapping/module_publish_mapping.json

@ -108,13 +108,15 @@
{
"fieldname": "publish_type",
"fieldtype": "Select",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Publish Type",
"options": "\nInternal\nGlobal"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-08-22 13:37:59.088802",
"modified": "2023-08-29 10:19:35.892128",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Module Publish Mapping",

5
smart_service/phase_2/doctype/mst_information_assets/mst_information_assets.json

@ -29,7 +29,8 @@
"fieldtype": "Select",
"in_list_view": 1,
"label": "Asset Type",
"options": "Content\nImage\nVideo"
"options": "Content\nImage\nVideo",
"set_only_once": 1
},
{
"fieldname": "active_status",
@ -42,7 +43,7 @@
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-08-22 13:06:58.987728",
"modified": "2023-08-22 17:30:12.423559",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "MST Information Assets",

64
smart_service/phase_2/doctype/special_tool_information/special_tool_information.js

@ -48,21 +48,11 @@ frappe.ui.form.on('Special Tool Information', {
}
});
}
$.each(frm.doc.tool_usage_content, function (index, row) {
let my_row = frm.fields_dict.tool_usage_content.grid.grid_rows[index];
set_row_read_only(my_row, index + 1);
});
},
videos_on_form_rendered: function (frm) {
$.each(frm.doc.tool_usage_content, function (index, row) {
let my_row = frm.fields_dict.tool_usage_content.grid.grid_rows[index];
set_row_read_only(my_row, index + 1);
});
after_save: function (frm) {
cur_frm.refresh_fields("display_order")
},
});
function set_display_order(frm){
@ -85,20 +75,40 @@ function set_display_order(frm){
}
});
}
function set_row_read_only(row, index) {
let task_index = row.docfields.findIndex(x => x.fieldname === "image");
let task1_index = row.docfields.findIndex(x => x.fieldname === "content");
if (row.doc.asset_type == 'Content') {
row.docfields[task_index].read_only = 0;
} else {
row.docfields[task_index].read_only = 1;
}
if (row.doc.asset_type == 'Image' && row.doc.asset_type == 'Video' ){
row.docfields[task1_index].read_only = 0;
}else{
row.docfields[task1_index].read_only=1;
frappe.ui.form.on('MST Information Assets',{
asset_type: function (frm, cdt, cdn) {
var select_value = locals[cdt][cdn]
var x = select_value.idx - 1;
let my_row = frm.fields_dict.tool_usage_content.grid.grid_rows[x];
let task_index = my_row.docfields.findIndex(x => x.fieldname === "content");
if (select_value.asset_type == 'Image' || select_value.asset_type == 'Video') {
cur_frm.get_field("tool_usage_content").grid.grid_rows[x].columns.image.df.read_only = 0;
cur_frm.get_field("tool_usage_content").grid.grid_rows[x].columns.content.df.read_only = 1;
cur_frm.refresh_fields("tool_usage_content")
}
else {
cur_frm.get_field("tool_usage_content").grid.grid_rows[x].columns.image.df.read_only = 1;
cur_frm.get_field("tool_usage_content").grid.grid_rows[x].columns.content.df.read_only = 0;
cur_frm.refresh_fields("tool_usage_content")
}
cur_frm.refresh_field("tool_usage_content");
cur_frm.refresh_field();
},
validate:function(frm){
let task_index = row.docfields.findIndex(x => x.fieldname === "content");
if (row.doc.asset_type == 'Image' || row.doc.asset_type == 'Video') {
row.docfields[task_index].read_only = 0;
// cur_frm.get_field("tool_usage_content").grid.grid_rows[x].columns.content.df.set="";
} else {
row.docfields[task_index].read_only = 1;
}
row.toggle_editable_row(true);
refresh_field("tool_usage_content");
cur_frm.refresh_field("image");
cur_frm.refresh_field("content");
refresh_field();
}
row.toggle_editable_row(false);
refresh_field("Tool Usage Content");
}
})

2
smart_service/phase_2/doctype/special_tool_information/special_tool_information.json

@ -77,7 +77,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-08-17 12:30:22.392056",
"modified": "2023-08-22 17:00:30.454597",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Special Tool Information",

33
smart_service/phase_2/doctype/training_information/training_information.js

@ -36,3 +36,36 @@ function set_display_order(frm){
}
});
}
frappe.ui.form.on('Training Information Content Reference',{
content_type: function (frm, cdt, cdn) {
var select_value = locals[cdt][cdn]
var x = select_value.idx - 1;
let my_row = frm.fields_dict.content.grid.grid_rows[x];
if (select_value.content_type == 'Image' || select_value.content_type == 'Video'){
cur_frm.get_field("content").grid.grid_rows[x].columns.image_video.df.read_only = 0;
cur_frm.get_field("content").grid.grid_rows[x].columns.content.df.read_only = 1;
cur_frm.refresh_fields("content")
}
else {
cur_frm.get_field("content").grid.grid_rows[x].columns.image_video.df.read_only = 1;
cur_frm.get_field("content").grid.grid_rows[x].columns.content.df.read_only = 0;
cur_frm.refresh_fields("content")
}
cur_frm.refresh_field("content");
cur_frm.refresh_field();
},
validate:function(frm){
let task_index = row.docfields.findIndex(x => x.fieldname === "content");
if (row.doc.asset_type == 'Image' || row.doc.asset_type == 'Video') {
row.docfields[task_index].read_only = 0;
// cur_frm.get_field("tool_usage_content").grid.grid_rows[x].columns.content.df.set=[];
} else {
row.docfields[task_index].read_only = 1;
}
row.toggle_editable_row(true);
refresh_field("content");
cur_frm.refresh_field("content");
refresh_field();
}
})

40
smart_service/public/js/common_fun.js

@ -16,12 +16,20 @@ function dragovertFunction(evt){
children.map(h => {
var html = '<input id='+count+' type="checkbox" class="speccheck grid-row-check pull-left"><span class="spec_check">'+count+'</span>'
$(h).find('#spec_count').html(html)
$( document ).ready(function() {
// $('.specification_bl').find('.spec_custom_save').css("display","inline-block")
})
count +=1
})
$( document ).ready(function() {
// cur_frm.doc.__unsaved = 1
// $('.title-area').find('.indicator-pill').remove()
$('.title-area').find('.indicator-pill').removeClass("hide");
$('.title-area').find('.indicator-pill').addClass("orange");
console.log("hiii")
$('.title-area').find('.indicator-pill').find('span').remove()
$('.title-area').find('.indicator-pill').append("<span>Not Saved</span>");
// $('.specification_bl').find('.spec_custom_save').css("display","inline-block")
})
//end
if(children.indexOf(e.target.parentNode)>children.indexOf(row)){
e.target.parentNode.after(row);
@ -47,12 +55,19 @@ function dragovertFunction_1(evt){
children.map(h => {
var html = '<input id='+count+' type="checkbox" class="imagecheck grid-row-check pull-left"><span class="image_check">'+count+'</span>'
$(h).find('#image_count').html(html)
$( document ).ready(function() {
// $('.feature_imgbl').find('.image_custom_save').css("display","inline-block")
})
count +=1
})
$( document ).ready(function() {
// cur_frm.doc.__unsaved = 1
// $('.title-area').find('.indicator-pill').remove()
$('.title-area').find('.indicator-pill').removeClass("hide");
$('.title-area').find('.indicator-pill').addClass("orange");
$('.title-area').find('.indicator-pill').find('span').remove()
$('.title-area').find('.indicator-pill').append("<span>Not Saved</span>");
// $('.feature_imgbl').find('.image_custom_save').css("display","inline-block")
})
//end
if(children.indexOf(e.target.parentNode)>children.indexOf(row1)){
e.target.parentNode.after(row1);
@ -79,12 +94,19 @@ function dragovertFunction_2(evt){
children.map(h => {
var html = '<input id='+count+' type="checkbox" class="contentcheck grid-row-check pull-left"><span class="content_check">'+count+'</span>'
$(h).find('#cont_count').html(html)
$( document ).ready(function() {
// $('.feature_contbl').find('.content_custom_save').css("display","inline-block")
})
count +=1
})
$( document ).ready(function() {
// cur_frm.doc.__unsaved = 1
// $('.title-area').find('.indicator-pill').remove()
$('.title-area').find('.indicator-pill').removeClass("hide");
$('.title-area').find('.indicator-pill').addClass("orange");
$('.title-area').find('.indicator-pill').find('span').remove()
$('.title-area').find('.indicator-pill').append("<span>Not Saved</span>");
// $('.feature_contbl').find('.content_custom_save').css("display","inline-block")
})
//end
if(children.indexOf(e.target.parentNode)>children.indexOf(row2)){
e.target.parentNode.after(row2);

700
smart_service/transactions/doctype/publish/publish.js

@ -20,68 +20,66 @@ frappe.ui.form.on('Publish', {
onload: function (frm) {
if(frm.doc.repiar_checksheet_publish_docs.length>0){
frm.set_df_property('repiar_checksheet_publish_docs','hidden',0)
if (frm.doc.hasOwnProperty('repiar_checksheet_publish_docs') && frm.doc.repiar_checksheet_publish_docs.length > 0 ) {
frm.set_df_property('repiar_checksheet_publish_docs', 'hidden', 0)
frm.refresh_field('repiar_checksheet_publish_docs')
cur_frm.set_df_property('repiar_checksheet_publish_docs','read_only',1)
cur_frm.set_df_property('repiar_checksheet_publish_docs', 'read_only', 1)
}
if(frm.doc.feature_finder_publish_docs.length>0){
frm.set_df_property('feature_finder_publish_docs','hidden',0)
cur_frm.set_df_property('feature_finder_publish_docs','read_only',1)
if (frm.doc.hasOwnProperty('feature_finder_publish_docs') && frm.doc.feature_finder_publish_docs.length > 0 ) {
frm.set_df_property('feature_finder_publish_docs', 'hidden', 0)
cur_frm.set_df_property('feature_finder_publish_docs', 'read_only', 1)
frm.refresh_field('feature_finder_publish_docs')
}
if(frm.doc.docstatus==1 && frm.doc.publish_module=='Feature Finder' ){
debugger
cur_frm.set_df_property('kilometer_mapping_details','hidden',1)
cur_frm.set_df_property('feature_finder_publish_docs','read_only',1)
if (frm.doc.docstatus == 1 && frm.doc.publish_module == 'Feature Finder') {
cur_frm.set_df_property('kilometer_mapping_details', 'hidden', 1)
cur_frm.set_df_property('feature_finder_publish_docs', 'read_only', 1)
cur_frm.refresh_field('feature_finder_publish_docs')
cur_frm.refresh_field('kilometer_mapping_details')
cur_frm.remove_custom_button('Add To Publish');
if(frm.doc.feature_finder_publish.length>0){
frm.set_df_property('feature_finder_publish','hidden',1)
if (frm.doc.feature_finder_publish.length > 0) {
frm.set_df_property('feature_finder_publish', 'hidden', 1)
frm.refresh_field('feature_finder_publish')
cur_frm.set_df_property('feature_finder_publish','read_only',1)
cur_frm.set_df_property('feature_finder_publish', 'read_only', 1)
}
}
if(frm.doc.docstatus==1 && frm.doc.publish_module=='Repair service' ){
cur_frm.set_df_property('repiar_checksheet_publish_docs','read_only',1)
if (frm.doc.docstatus == 1 && frm.doc.publish_module == 'Repair service') {
cur_frm.set_df_property('repiar_checksheet_publish_docs', 'read_only', 1)
cur_frm.refresh_field('repiar_checksheet_publish_docs')
cur_frm.set_df_property('feature_finder_publish_docs','hidden',1)
cur_frm.remove_custom_button('Add To Publish');
if(frm.doc.repiar_checksheet_publish_docs.length>0){
frm.set_df_property('repiar_checksheet_publish_docs','hidden',0)
cur_frm.set_df_property('feature_finder_publish_docs', 'hidden', 1)
cur_frm.remove_custom_button('Add To Publish');
if (frm.doc.repiar_checksheet_publish_docs.length > 0) {
frm.set_df_property('repiar_checksheet_publish_docs', 'hidden', 0)
frm.refresh_field('repiar_checksheet_publish_docs')
cur_frm.set_df_property('repiar_checksheet_publish_docs','read_only',1)
cur_frm.set_df_property('repiar_checksheet_publish_docs', 'read_only', 1)
}
// cur_frm.set_df_property('repiar_checksheet_publish_docs','hidden',0)
// cur_frm.refresh_field('repiar_checksheet_publish_docs')
}
if(frm.doc.publish_module=='Feature Finder' || frm.doc.publish_type=='Internal' || frm.doc.publish_type=='Global' || frm.doc.docstatus!=1){
debugger
cur_frm.set_df_property('kilometer_mapping_details','hidden',1)
if (frm.doc.docstatus != 1 && frm.doc.publish_module == 'Feature Finder' && frm.doc.feature_finder_publish_docs.length>0 && frm.doc.publish_type == 'Internal' || frm.doc.publish_type == 'Global') {
cur_frm.set_df_property('kilometer_mapping_details', 'hidden', 1)
cur_frm.refresh_field('feature_finder_publish_docs')
cur_frm.refresh_field('kilometer_mapping_details')
cur_frm.remove_custom_button('Add To Publish');
cur_frm.set_df_property('feature_finder_publish_docs','hidden',0)
cur_frm.set_df_property('feature_finder_publish_docs', 'hidden', 0)
cur_frm.refresh_field('feature_finder_publish_docs')
}
if(frm.doc.publish_module=='Repair service' || frm.doc.publish_type=='Internal' || frm.doc.publish_type=='Global' || frm.doc.docstatus!=1){
if (frm.doc.docstatus != 1 && frm.doc.publish_module == 'Repair service' || frm.doc.publish_type == 'Internal' || frm.doc.publish_type == 'Global') {
cur_frm.refresh_field('repiar_checksheet_publish_docs')
cur_frm.refresh_field('kilometer_mapping_details')
cur_frm.remove_custom_button('Add To Publish');
cur_frm.set_df_property('repiar_checksheet_publish_docs','hidden',0)
cur_frm.set_df_property('repiar_checksheet_publish_docs', 'hidden', 0)
cur_frm.refresh_field('repiar_checksheet_publish_docs')
}
// $('[data-route="Form/Publish/' + frm.doc.name + '"]').find('.primary-action').html("Internal Publish")
if (frm.doc.docstatus == 0 && !frm.is_new() && frm.doc.publish_type != "Global" && frm.doc.publish_module != 'Automotive System') {
$('[data-route="Form/Publish/' + frm.doc.name + '"]').find('.primary-action').html("Internal Publish")
@ -98,6 +96,7 @@ frappe.ui.form.on('Publish', {
lang_set_first_time = true;
frm.get_field('publish_documents').grid.cannot_add_rows = true;
},
planned_publish_date: function (frm) {
let date = (frappe.datetime.nowdate())
@ -110,52 +109,52 @@ frappe.ui.form.on('Publish', {
},
refresh: function (frm) {
if (frm.doc.docstatus == 0 && !frm.is_new() && frm.doc.publish_type != "Global" && frm.doc.publish_module!="Automotive System") {
if (frm.doc.docstatus == 0 && !frm.is_new() && frm.doc.publish_type != "Global" && frm.doc.publish_module != "Automotive System") {
$('[data-route="Form/Publish/' + frm.doc.name + '"]').find('.primary-action').html("Internal Publish")
}
if (frm.doc.docstatus == 0 && frm.doc.publish_type == "Global" && frm.doc.publish_module!="Automotive System") {
if (frm.doc.docstatus == 0 && frm.doc.publish_type == "Global" && frm.doc.publish_module != "Automotive System") {
$('[data-route="Form/Publish/' + frm.doc.name + '"]').find('.primary-action').html("Global Publish")
}
if (frm.doc.docstatus === 1 && frm.doc.publish_type == "Internal" && frm.doc.publish_status == 'Published' && frm.doc.publish_module!='Automotive System' && !frm.doc.global_publish && frappe.user.has_role('_Publisher')) {
frappe.call({
method: "smart_service.transactions.doctype.publish.publish.max_publish_new_module",
args: {
"doc": frm.doc.name,
},
callback: function (r) {
if (r.message==frm.doc.version) {
if (frm.doc.docstatus === 1 && frm.doc.publish_type == "Internal" && frm.doc.publish_status == 'Published' && frm.doc.publish_module != 'Automotive System' && !frm.doc.global_publish && frappe.user.has_role('_Publisher')) {
frappe.call({
method: "smart_service.transactions.doctype.publish.publish.max_publish_new_module",
args: {
"doc": frm.doc.name,
},
callback: function (r) {
if (r.message == frm.doc.version) {
frm.add_custom_button(__('Global Publish'), function () {
frappe.confirm('Are you sure you want to Publish?',
() => {
frappe.call({
method: "smart_service.transactions.doctype.publish.publish.generate_global_publish",
args: {
"name": frm.doc.name,
"module_name":frm.doc.publish_module
},
callback: function (r) {
debugger
window.location.href = r.message.url + "/app/publish" + "/" + r.message.message
}
});
})
}).addClass("btn-warning").css({ 'background-color': '#f5b0cd', 'color': 'black' });
if (r.message == frm.doc.version) {
frm.add_custom_button(__('Global Publish'), function () {
frappe.confirm('Are you sure you want to Publish?',
() => {
frappe.call({
method: "smart_service.transactions.doctype.publish.publish.generate_global_publish",
args: {
"name": frm.doc.name,
"module_name": frm.doc.publish_module
},
callback: function (r) {
debugger
window.location.href = r.message.url + "/app/publish" + "/" + r.message.message
}
});
})
}).addClass("btn-warning").css({ 'background-color': '#f5b0cd', 'color': 'black' });
}
}
}
}
})
}
})
}
if (frm.doc.publish_module == 'Automotive System') {
cur_frm.set_df_property('system_mapping', "read_only", 1);
@ -187,8 +186,8 @@ frappe.ui.form.on('Publish', {
document.querySelectorAll("[data-fieldname='km_report']")[1].style.color = "#FFFFFF";
document.querySelectorAll("[data-fieldname='add_variant_mapping_to_publish']")[1].style.backgroundColor = "#e31a37";
document.querySelectorAll("[data-fieldname='add_variant_mapping_to_publish']")[1].style.color = "#FFFFFF";
if (frm.doc.docstatus === 1 && frm.doc.publish_type == "Internal" && frm.doc.publish_status == 'Published' && frm.doc.publish_module=='Automotive System' && !frm.doc.global_publish && frappe.user.has_role('_Publisher')) {
if (frm.doc.docstatus === 1 && frm.doc.publish_type == "Internal" && frm.doc.publish_status == 'Published' && frm.doc.publish_module == 'Automotive System' && !frm.doc.global_publish && frappe.user.has_role('_Publisher')) {
debugger
frappe.call({
method: "smart_service.transactions.doctype.publish.publish.max_publish",
args: {
@ -196,7 +195,7 @@ frappe.ui.form.on('Publish', {
},
callback: function (r) {
if (r.message) {
if (r.message == frm.doc.version) {
frm.add_custom_button(__('Global Publish'), function () {
frappe.call({
@ -216,15 +215,15 @@ 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') {
debugger
frm.add_custom_button(__('Publish'), function () {
frappe.confirm('Are you sure you want to Publish?',
() => {
// action to perform if Yes is selected
if (frm.doc.vehicle && frm.doc.language && frm.doc.publish_type && frm.doc.publish_module == 'Automotive System') {
frappe.call({
method: 'smart_service.transactions.doctype.publish.publish.cal_ver',
args: {
@ -234,7 +233,7 @@ frappe.ui.form.on('Publish', {
doc: frm.doc.name
},
callback: (r) => {
debugger
frm.set_value('version', r.message);
cur_frm.refresh_field('version')
if (frm.doc.docstatus === 1 && frm.doc.publish_status == 'To Publish') {
@ -272,45 +271,7 @@ frappe.ui.form.on('Publish', {
}
}
});
// }
// else {
// frappe.msgprint({
// title: __('Notification'),
// message: __('<b>Not Successfully Published:</b> ' + r.message[1]),
// // primary_action: {
// // action(values) {
// // frm.save('Update');
// // }
// // }
// });
// }
// if (r.message != "Failed to save file") {
// frm.set_value('publish_status', 'Published');
// frm.set_value('actual_published_date', frappe.datetime.nowdate());
// frappe.call({
// method: "smart_service.transactions.doctype.publish.publish.update_procedure_value",
// args: {
// "name": frm.doc.name,
// "file_path": r.message,
// },
// callback: (r) => {
// // frm.save('Update');
// }
// })
// frappe.msgprint({
// title: __('Notification'),
// message: __('<b>Successfully Published:</b> ' + r.message),
// primary_action: {
// action(values) {
// frm.save('Update');
// }
// }
// });
// } else {
// frappe.msgprint('Publish Failed')
// }
}
});
}
@ -321,13 +282,13 @@ frappe.ui.form.on('Publish', {
// action to perform if No is selected
});
}).addClass("btn-warning").css({ 'background-color': '#f5b0cd', 'color': 'black' });
}
}
else if (frm.doc.publish_status == 'Published') {
frm.set_read_only();
frm.set_df_property('add_variant_mapping_to_publish', 'hidden', 1);
}
if (frm.doc.docstatus === 0 && frm.doc.publish_status == 'To Publish') {
frm.get_field('system_mapping').grid.add_custom_button(__('Add to Publish'), function () {
@ -400,19 +361,19 @@ frappe.ui.form.on('Publish', {
frm.fields_dict.variant_mapping_assets.grid.grid_buttons.find('.btn-custom').removeClass('btn-default').addClass('btn-primary');
}
if (frm.doc.docstatus == 1) {
$(".grid-buttons").hide();
}
}
if (frm.doc.docstatus == 1 && frm.doc.publish_status == 'To Publish' && !frm.is_new() && frm.doc.publish_module != 'Automotive System') {
frappe.call({
if (frm.doc.docstatus == 1 && frm.doc.publish_status == 'To Publish' && !frm.is_new() && frm.doc.publish_module != 'Automotive System') {
frappe.call({
method: "smart_service.transactions.doctype.publish.publish.cal_ver_new_module",
args: {
vehicle: frm.doc.vehicle,
@ -421,21 +382,21 @@ frappe.ui.form.on('Publish', {
doc: frm.doc.name
},
callback: function (r) {
if (r.message) {
frm.set_value('version', r.message);
cur_frm.refresh_field('version')
frm.set_value('actual_published_date', frappe.datetime.nowdate());
window.location.reload();
}
}
})
}
},
validate: function (frm) {
@ -463,20 +424,92 @@ frappe.ui.form.on('Publish', {
}
},
variant_mapping: function (frm) {
if (frm.doc.docstatus === 0 && frm.doc.publish_status == 'To Publish') {
frm.get_field('system_mapping').grid.add_custom_button(__('Add to Publish'), function () {
let added = 0;
let topublish = [];
if (frm.doc.publish_type == 'Global') { topublish = ['Publish Ready']; } else { topublish = ['Review Pending', 'Publish Ready', 'Approval Pending']; }
frm.doc.system_mapping.forEach(row => {
if (topublish.indexOf(row.procedure_status) > -1) {
let dulicate = false;
if (frm.doc.publish_documents) {
frm.doc.publish_documents.forEach(publishrow => {
if (frm.doc.variant_mapping == publishrow.variant_mapping &&
row.systems == publishrow.system &&
row.sub_systems == publishrow.sub_system && row.procedure == publishrow.procedure_link) {
dulicate = true;
}
});
}
if (dulicate === false) {
let child = cur_frm.add_child("publish_documents");
child.variant_mapping = frm.doc.variant_mapping;
child.system = row.systems;
child.sub_system = row.sub_systems;
child.procedure_link = row.procedure;
child.procedure_status = row.procedure_status;
child.update_procedure_status = row.procedure_status;
child.item_category = "System Mapping";
child.variant = frm.doc.variant;
refresh_field("publish_documents");
added += 1;
}
}
});
if (added) { frappe.msgprint(__(added + " Doc(s) Added")); }
else { frappe.msgprint(__("No Doc Added")); }
});
frm.fields_dict.system_mapping.grid.grid_buttons.find('.btn-custom').removeClass('btn-default').addClass('btn-primary');
}
if (frm.doc.docstatus === 0 && frm.doc.publish_status == 'To Publish') {
frm.get_field('variant_mapping_assets').grid.add_custom_button(__('Add to Publish'), function () {
let added = 0;
frm.doc.variant_mapping_assets.forEach(row => {
if (row.active_status == "Active" || row.active_status == "Inactive") {
let dulicate = false;
if (frm.doc.publish_documents) {
frm.doc.publish_documents.forEach(publishrow => {
if (frm.doc.variant_mapping == publishrow.variant_mapping &&
row.category == publishrow.asset_category && row.attach_file == publishrow.attach_file) {
dulicate = true;
}
});
}
if (dulicate === false) {
let child = cur_frm.add_child("publish_documents");
child.variant_mapping = frm.doc.variant_mapping;
child.asset_category = row.category;
child.item_category = "Variant Mapping Assets";
child.variant = frm.doc.variant;
child.attach_file = row.attach_file;
refresh_field("publish_documents");
added += 1;
}
}
});
if (added) { frappe.msgprint(__(added + " Doc(s) Added")); }
else { frappe.msgprint(__("No Doc Added")); }
});
frm.fields_dict.variant_mapping_assets.grid.grid_buttons.find('.btn-custom').removeClass('btn-default').addClass('btn-primary');
}
frappe.db.get_value('Variant Mapping', { name: frm.doc.variant_mapping }, ['fuel', 'transmission', 'drive'], (r) => {
frm.doc.variant = r.fuel + ',' + r.transmission + ',' + r.drive;
cur_frm.refresh_field('variant');
})
if(frm.doc.publish_module=='Feature Finder'){
if (frm.doc.publish_module == 'Feature Finder') {
add_feature_finder(frm)
}
// if (frm.doc.docstatus === 0 && frm.doc.publish_status == 'To Publish' && frm.doc.publish_module=='Feature Finder') {
// frm.get_field('feature_finder_publish').grid.add_custom_button(__('Add to Publish'), function () {
// let added = 0;
// frm.doc.feature_finder_publish.forEach(row => {
@ -517,40 +550,40 @@ frappe.ui.form.on('Publish', {
// cur_frm.refresh_field("feature_finder_publish"); }
// else if(added==0) { frappe.msgprint(__("No Doc Added")); }
// });
// frm.fields_dict.repair_checksheet_publish.grid.grid_buttons.find('.btn-custom').removeClass('btn-default').addClass('btn-primary');
// }
if (frm.doc.publish_module=='Automotive System') {
let km_name = frm.doc.variant_mapping + "-" + frm.doc.language + "-KM";
frappe.db.get_value('Kilometer Mapping', { name: km_name }, 'workflow_state', (r) => {
if (r.workflow_state == "Draft") {
frm.doc.kilometer_mapping = '';
frm.doc.variant_mapping = '';
frm.doc.system_mapping = '';
frm.doc.variant_mapping_status = '';
frm.refresh_field('kilometer_mapping');
frm.refresh_field('variant_mapping');
frm.refresh_field('system_mapping');
frappe.msgprint("System Mapping details cannot be loaded due to kilometer mapping in draft state");
frappe.validated = false;
}
if (frm.doc.publish_module == 'Automotive System') {
let km_name = frm.doc.variant_mapping + "-" + frm.doc.language + "-KM";
frappe.db.get_value('Kilometer Mapping', { name: km_name }, 'workflow_state', (r) => {
if (r.workflow_state == "Draft") {
frm.doc.kilometer_mapping = '';
frm.doc.variant_mapping = '';
frm.doc.system_mapping = '';
frm.doc.variant_mapping_status = '';
frm.refresh_field('kilometer_mapping');
frm.refresh_field('variant_mapping');
frm.refresh_field('system_mapping');
frappe.msgprint("System Mapping details cannot be loaded due to kilometer mapping in draft state");
frappe.validated = false;
}
else {
if (frm.doc.variant_mapping === undefined) { return; }
frm.set_value('system_mapping', null);
frm.set_value('variant_mapping_assets', null);
frappe.db.exists('Kilometer Mapping', frm.doc.variant_mapping + "-" + frm.doc.language + "-KM")
.then(exists => {
if (exists) {
frm.set_value("kilometer_mapping", frm.doc.variant_mapping + "-" + frm.doc.language + "-KM");
frm.refresh_field('kilometer_mapping')
} else {
frm.set_value("km_active_status", "Not Configured!");
}
});
}
})
}
else {
if (frm.doc.variant_mapping === undefined) { return; }
// frm.set_value('system_mapping', null);
// frm.set_value('variant_mapping_assets', null);
frappe.db.exists('Kilometer Mapping', frm.doc.variant_mapping + "-" + frm.doc.language + "-KM")
.then(exists => {
if (exists) {
frm.set_value("kilometer_mapping", frm.doc.variant_mapping + "-" + frm.doc.language + "-KM");
frm.refresh_field('kilometer_mapping')
} else {
frm.set_value("km_active_status", "Not Configured!");
}
});
}
})
}
},
km_active_status: function (frm) {
@ -687,46 +720,46 @@ frappe.ui.form.on('Publish', {
// }
},
km_report: function (frm, cdt, cdn) {
if (frm.doc.publish_module=='Automotive System') {
if (frm.doc.publish_module == 'Automotive System') {
frappe.set_route("query-report", 'Kilometer Mapping', { 'kilometer_mapping': frm.doc.kilometer_mapping });
}
},
after_save: function (frm) {
frm.set_df_property('repair_checksheet_publish', 'hidden', 0)
frm.refresh_field('repair_checksheet_publish')
},
vehicle: function (frm) {
frm.set_df_property('vehicle','set_only_once','1')
frm.set_df_property('vehicle', 'set_only_once', '1')
frm.refresh_fields('vehicle')
if (frm.doc.publish_module=='Automotive System') {
if (frm.doc.publish_module == 'Automotive System') {
frappe.call({
method: "smart_service.transactions.doctype.publish.publish.old_publish",
async: false,
args: {
"vehicle": frm.doc.vehicle,
"language": frm.doc.language
},
callback: function (r) {
if (r.message) {
let vehicle = frm.doc.vehicle;
cur_frm.doc.vehicle = '';
cur_frm.doc.vehicle_status = '';
cur_frm.refresh_field('vehicle');
cur_frm.refresh_field('vehicle_status');
frappe.msgprint("Already publish record " + r.message[0]['name'] + " created for " + vehicle + " vehicle. Please edit already available " + r.message[0]['publish_type'] + " publish!")
frappe.call({
method: "smart_service.transactions.doctype.publish.publish.old_publish",
async: false,
args: {
"vehicle": frm.doc.vehicle,
"language": frm.doc.language
},
callback: function (r) {
if (r.message) {
let vehicle = frm.doc.vehicle;
cur_frm.doc.vehicle = '';
cur_frm.doc.vehicle_status = '';
cur_frm.refresh_field('vehicle');
cur_frm.refresh_field('vehicle_status');
frappe.msgprint("Already publish record " + r.message[0]['name'] + " created for " + vehicle + " vehicle. Please edit already available " + r.message[0]['publish_type'] + " publish!")
}
}
}
});
}
if (frm.doc.publish_module=='Repair service') {
});
}
if (frm.doc.publish_module == 'Repair service') {
add_to_publish(frm)
}
add_to_publish(frm)
}
if (frm.doc.vehicle === undefined || frm.doc.vehicle === null && frm.doc.publish_module == 'Automotive System') { return; }
$("[data-fieldname=variant_mapping]").focus();
// if (frm.doc.vehicle) {
@ -740,45 +773,45 @@ frappe.ui.form.on('Publish', {
cur_frm.refresh_fields('repair_checksheet_publish');
}
}
},
language: function (frm) {
frm.doc.vehicle=''
frm.doc.vehicle = ''
frm.refresh_field('vehicle')
frm.set_value('repair_checksheet_publish','')
frm.set_value('feature_finder_publish','')
frm.set_value('repiar_checksheet_publish_docs','')
frm.set_value('feature_finder_publish_docs','')
frm.set_value('repair_checksheet_publish', '')
frm.set_value('feature_finder_publish', '')
frm.set_value('repiar_checksheet_publish_docs', '')
frm.set_value('feature_finder_publish_docs', '')
if (frm.doc.publish_module == 'Repair service' && frm.doc.vehicle) {
add_to_publish(frm)
if (frm.doc.repair_checksheet_publish && frm.doc.repair_checksheet_publish.length > 0) {
cur_frm.clear_table("repair_checksheet_publish");
cur_frm.refresh_fields('repair_checksheet_publish');
}
}
if (frm.doc.publish_module == 'Feature Finder' && frm.doc.vehicle && frm.doc.variant_mapping) {
if (frm.doc.feature_finder_publish && frm.doc.feature_finder_publish.length > 0) {
cur_frm.clear_table("feature_finder_publish");
cur_frm.refresh_fields('feature_finder_publish');
}
}
if (!lang_set_first_time && frm.doc.publish_module=='Automotive System') {
}
if (!lang_set_first_time && frm.doc.publish_module == 'Automotive System') {
frappe.confirm('This will clear all the data, are you sure you want to proceed?',
() => {
// action to perform if Yes is selected
@ -792,8 +825,8 @@ frappe.ui.form.on('Publish', {
// action to perform if No is selected
});
}
if (!lang_set_first_time && frm.doc.publish_module=='Repair service') {
}
if (!lang_set_first_time && frm.doc.publish_module == 'Repair service') {
frappe.confirm('This will clear all the data, are you sure you want to proceed?',
() => {
// action to perform if Yes is selected
@ -803,14 +836,14 @@ frappe.ui.form.on('Publish', {
// action to perform if No is selected
});
}
if (!lang_set_first_time && frm.doc.publish_module=='Feature Finder') {
if (!lang_set_first_time && frm.doc.publish_module == 'Feature Finder') {
frappe.confirm('This will clear all the data, are you sure you want to proceed?',
() => {
// action to perform if Yes is selected
frm.set_value('feature_finder_publish', null);
frm.set_value('variant_mapping','')
frm.set_value('variant_mapping', '')
lang_set_first_time = false;
}, () => {
// action to perform if No is selected
@ -820,7 +853,7 @@ frappe.ui.form.on('Publish', {
else { lang_set_first_time = false; }
},
auto_version_update: function (frm) {
if (frm.doc.vehicle && frm.doc.language && frm.doc.publish_type && frm.doc.publish_module=='Automotive System') {
if (frm.doc.vehicle && frm.doc.language && frm.doc.publish_type && frm.doc.publish_module == 'Automotive System') {
frappe.call({
method: 'smart_service.transactions.doctype.publish.publish.cal_ver',
args: {
@ -838,28 +871,29 @@ frappe.ui.form.on('Publish', {
}
});
}
else{
else {
}
}
},
publish_module:function(frm){
frm.doc.vehicle=''
frm.doc.variant_mapping=''
frm.doc.repair_checksheet_publish=''
frm.doc.feature_finder_publish=''
frm.set_value('feature_finder_publish_docs','')
frm.set_value('repiar_checksheet_publish_docs','')
publish_module: function (frm) {
frm.doc.vehicle = ''
frm.doc.variant_mapping = ''
frm.doc.repair_checksheet_publish = ''
frm.doc.feature_finder_publish = ''
frm.set_value('feature_finder_publish_docs', '')
frm.set_value('repiar_checksheet_publish_docs', '')
frm.set_df_property('repiar_checksheet_publish_docs','hidden',1)
frm.refresh_fields()
if(frm.doc.publish_module=='Repair service'){
if (frm.doc.publish_module == 'Repair service') {
add_to_publish(frm)
}
if(frm.doc.publish_module=='Automotive System'){
if (frm.doc.publish_module == 'Automotive System') {
}
if(frm.doc.publish_module=='Feature Finder'){
if (frm.doc.publish_module == 'Feature Finder') {
add_feature_finder(frm)
}
@ -882,15 +916,15 @@ frappe.ui.form.on('Publish_Temp Doc', {
function add_to_publish(frm) {
cur_frm.clear_table("repair_checksheet_publish")
cur_frm.refresh_fields();
document.getElementsByClassName('btn btn-xs btn-secondary grid-add-row')[4] .setAttribute("style","display:none;");
if(frm.doc.vehicle){
document.getElementsByClassName('btn btn-xs btn-secondary grid-add-row')[4].setAttribute("style", "display:none;");
if (frm.doc.vehicle) {
frappe.call({
method: "smart_service.transactions.doctype.publish.publish.get_service_repair",
args: { vehicle: frm.doc.vehicle, language_label: frm.doc.language, publish_type: frm.doc.publish_type },
callback: function (r) {
if (r.message.length>0) {
if (r.message.length > 0) {
var records = r.message
records.map(v => {
var childTable = cur_frm.add_child("repair_checksheet_publish");
@ -900,14 +934,14 @@ function add_to_publish(frm) {
childTable.lang_myid = v['lang_myid'];
childTable.display_order = v['display_order'];
childTable.check_list_name = v['check_list_name'];
childTable.active_status = v['active_status'];
childTable.my_id = v['my_id'];
childTable.lang_myid = v['lang_myid'];
})
//add to repair service published doc table
if (frm.doc.docstatus === 0 && frm.doc.publish_status == 'To Publish' && frm.doc.publish_module=='Repair service') {
if (frm.doc.docstatus === 0 && frm.doc.publish_status == 'To Publish' && frm.doc.publish_module == 'Repair service') {
frm.get_field('repair_checksheet_publish').grid.add_custom_button(__('Add to Publish'), function () {
let added = 0;
frm.doc.repair_checksheet_publish.forEach(row => {
@ -930,122 +964,128 @@ function add_to_publish(frm) {
child.active_status = row.active_status;
// refresh_field("repiar_checksheet_publish_docs");
added += 1;
frm.set_df_property('repiar_checksheet_publish_docs','hidden',0)
frm.set_df_property('repiar_checksheet_publish_docs', 'hidden', 0)
refresh_field("repiar_checksheet_publish_docs");
document.getElementsByClassName('btn btn-xs btn-secondary grid-add-row')[4] .setAttribute("style","display:none;");
document.getElementsByClassName('btn btn-xs btn-secondary grid-add-row')[5] .setAttribute("style","display:none;");
document.getElementsByClassName('btn btn-xs btn-secondary grid-add-row')[4].setAttribute("style", "display:none;");
document.getElementsByClassName('btn btn-xs btn-secondary grid-add-row')[5].setAttribute("style", "display:none;");
}
else{
else {
frappe.msgprint(__(row.parent_name + 'Alraeady Added'))
}
}
});
if (added) { frappe.msgprint(__(added + " Doc(s) Added"));
cur_frm.set_df_property('repair_checksheet_publish','read_only',1)
cur_frm.refresh_field("repair_checksheet_publish"); }
else if(added==0) { frappe.msgprint(__("No Doc Added")); }
if (added) {
frappe.msgprint(__(added + " Doc(s) Added"));
cur_frm.set_df_property('repair_checksheet_publish', 'read_only', 1)
cur_frm.refresh_field("repair_checksheet_publish");
}
else if (added == 0) { frappe.msgprint(__("No Doc Added")); }
});
frm.fields_dict.repair_checksheet_publish.grid.grid_buttons.find('.btn-custom').removeClass('btn-default').addClass('btn-primary');
}
cur_frm.set_df_property('repair_checksheet_publish', 'hidden', 0)
cur_frm.refresh_field("repair_checksheet_publish");
cur_frm.set_df_property('repiar_checksheet_publish_docs', 'read_only', 1)
cur_frm.refresh_field("repiar_checksheet_publish_docs",'read_only',1);
document.getElementsByClassName('btn btn-xs btn-secondary grid-add-row')[4] .setAttribute("style","display:none;");
document.getElementsByClassName('btn btn-xs btn-secondary grid-add-row')[5] .setAttribute("style","display:none;");
cur_frm.refresh_field("repiar_checksheet_publish_docs", 'read_only', 1);
document.getElementsByClassName('btn btn-xs btn-secondary grid-add-row')[4].setAttribute("style", "display:none;");
document.getElementsByClassName('btn btn-xs btn-secondary grid-add-row')[5].setAttribute("style", "display:none;");
}
}
})
}
}
function add_feature_finder(frm){
function add_feature_finder(frm) {
cur_frm.clear_table("feature_finder_publish")
cur_frm.refresh_fields();
var fin_add_btn=document.getElementsByClassName('btn btn-xs btn-secondary grid-add-row')[3].setAttribute("style","display:none;")
frappe.call({
method: "smart_service.transactions.doctype.publish.publish.get_feature_finder",
args: { vehicle: frm.doc.vehicle,variant:frm.doc.variant_mapping, language_label: frm.doc.language, publish_type: frm.doc.publish_type },
callback: function (r) {
if (r.message.length>0) {
cur_frm.set_df_property('feature_finder_publish', 'hidden', 0)
var records = r.message
records.map(v => {
var childTable = cur_frm.add_child("feature_finder_publish");
childTable.parent1 = v['name'];
childTable.vehicle = v['vehicle'];
childTable.language = v['language'];
childTable.variant = v['variant'];
childTable.active_status = v['active_status'];
})
//add to repair service published doc table
if (frm.doc.docstatus === 0 && frm.doc.publish_status == 'To Publish' && frm.doc.publish_module=='Feature Finder') {
frm.get_field('feature_finder_publish').grid.add_custom_button(__('Add to Publish'), function () {
let added = 0;
frm.doc.feature_finder_publish.forEach(row => {
if (row.active_status == "Active" || row.active_status == "Inactive") {
let dulicate = false;
if (frm.doc.feature_finder_publish_docs) {
frm.doc.feature_finder_publish_docs.forEach(publishrow => {
if (row.parent1 == publishrow.parent1) {
var fin_add_btn = document.getElementsByClassName('btn btn-xs btn-secondary grid-add-row')[3].setAttribute("style", "display:none;")
frappe.call({
method: "smart_service.transactions.doctype.publish.publish.get_feature_finder",
args: { vehicle: frm.doc.vehicle, variant: frm.doc.variant_mapping, language_label: frm.doc.language, publish_type: frm.doc.publish_type },
callback: function (r) {
if (r.message.length > 0) {
cur_frm.set_df_property('feature_finder_publish', 'hidden', 0)
var records = r.message
records.map(v => {
var childTable = cur_frm.add_child("feature_finder_publish");
childTable.parent1 = v['name'];
childTable.vehicle = v['vehicle'];
childTable.language = v['language'];
childTable.variant = v['variant'];
childTable.active_status = v['active_status'];
dulicate = true;
}
});
}
if (dulicate === false) {
let child = cur_frm.add_child("feature_finder_publish_docs");
child.vehicle = frm.doc.vehicle;
child.parent1 = row.parent1;
child.language = row.language;
child.variant = row.variant;
child.active_status = row.active_status;
added += 1;
frm.set_df_property('feature_finder_publish_docs','hidden',0)
cur_frm.refresh_field("feature_finder_publish",'read_only',1);
refresh_field("feature_finder_publish_docs");
cur_frm.set_df_property("feature_finder_publish",'read_only',1);
document.getElementsByClassName('btn btn-xs btn-secondary grid-add-row')[4] .setAttribute("style","display:none;");
document.getElementsByClassName('btn btn-xs btn-secondary grid-add-row')[5] .setAttribute("style","display:none;");
}
else{
frappe.msgprint(__(row.parent1 + 'Alraeady Added'))
}
cur_frm.refresh_field("feature_finder_publish_docs",'read_only',1);
})
//add to repair service published doc table
if (frm.doc.docstatus === 0 && frm.doc.publish_status == 'To Publish' && frm.doc.publish_module == 'Feature Finder') {
frm.get_field('feature_finder_publish').grid.add_custom_button(__('Add to Publish'), function () {
let added = 0;
frm.doc.feature_finder_publish.forEach(row => {
if (row.active_status == "Active" || row.active_status == "Inactive") {
let dulicate = false;
if (frm.doc.feature_finder_publish_docs) {
frm.doc.feature_finder_publish_docs.forEach(publishrow => {
if (row.parent1 == publishrow.parent1) {
dulicate = true;
}
});
}
});
if (added) { frappe.msgprint(__(added + " Doc(s) Added"));
cur_frm.set_df_property('feature_finder_publish','read_only',1)
cur_frm.set_df_property("feature_finder_publish_docs",'read_only',1);
cur_frm.refresh_field("feature_finder_publish"); }
else if(added==0) { frappe.msgprint(__("No Doc Added")); }
if (dulicate === false) {
let child = cur_frm.add_child("feature_finder_publish_docs");
child.vehicle = frm.doc.vehicle;
child.parent1 = row.parent1;
child.language = row.language;
child.variant = row.variant;
child.active_status = row.active_status;
added += 1;
frm.set_df_property('feature_finder_publish_docs', 'hidden', 0)
cur_frm.refresh_field("feature_finder_publish", 'read_only', 1);
refresh_field("feature_finder_publish_docs");
cur_frm.set_df_property("feature_finder_publish", 'read_only', 1);
document.getElementsByClassName('btn btn-xs btn-secondary grid-add-row')[4].setAttribute("style", "display:none;");
document.getElementsByClassName('btn btn-xs btn-secondary grid-add-row')[5].setAttribute("style", "display:none;");
frm.fields_dict.repair_checksheet_publish.grid.grid_buttons.find('.btn-custom').removeClass('btn-default').addClass('btn-primary');
}
else {
frappe.msgprint(__(row.parent1 + 'Alraeady Added'))
}
cur_frm.refresh_field("feature_finder_publish_docs", 'read_only', 1);
}
});
frm.fields_dict.repair_checksheet_publish.grid.grid_buttons.find('.btn-custom').removeClass('btn-default').addClass('btn-primary');
}
cur_frm.set_df_property('feature_finder_publish', 'hidden', 0)
cur_frm.refresh_field("feature_finder_publish");
let find_add_btn=document.getElementsByClassName('btn btn-xs btn-secondary grid-add-row')[3].setAttribute("style","display:none;");
if (added) {
frappe.msgprint(__(added + " Doc(s) Added"));
cur_frm.set_df_property('feature_finder_publish', 'read_only', 1)
cur_frm.set_df_property("feature_finder_publish_docs", 'read_only', 1);
cur_frm.refresh_field("feature_finder_publish");
}
else if (added == 0) { frappe.msgprint(__("No Doc Added")); }
});
frm.fields_dict.feature_finder_publish.grid.grid_buttons.find('.btn-custom').removeClass('btn-default').addClass('btn-primary');
}
cur_frm.set_df_property('feature_finder_publish', 'hidden', 0)
cur_frm.refresh_field("feature_finder_publish");
let find_add_btn = document.getElementsByClassName('btn btn-xs btn-secondary grid-add-row')[3].setAttribute("style", "display:none;");
}
})
}
})
}

5
smart_service/transactions/doctype/publish/publish.json

@ -98,7 +98,8 @@
"in_standard_filter": 1,
"label": "Vehicle",
"options": "Vehicle",
"reqd": 1
"reqd": 1,
"set_only_once": 1
},
{
"depends_on": "eval:doc.vehicle && doc.docstatus == 0 && doc.publish_module=='Automotive System' || doc.publish_module=='Feature Finder'",
@ -356,7 +357,7 @@
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2023-08-22 11:01:05.537725",
"modified": "2023-08-28 10:37:21.374827",
"modified_by": "Administrator",
"module": "Transactions",
"name": "Publish",

384
smart_service/transactions/doctype/publish/publish.py

@ -1,6 +1,6 @@
# Copyright (c) 2021, Hard n Soft Technologies Pvt Ltd and contributors
# For license information, please see license.txt
import copy
import sys
from html import unescape
import frappe
@ -10,10 +10,10 @@ import json
from datetime import date
from frappe.utils import cstr
from frappe.utils import logger
current_db_name = frappe.conf.get("db_name")
sys.tracebacklimit = 0
site_name = cstr(frappe.local.site)
import pandas as pd
base_url = os.path.expanduser(
"~") + "/frappe-bench/sites/" + site_name + "/public" + "/files" + "/json_files" + "/phase2"
@ -27,7 +27,7 @@ module_name = 'feature_finder'
class Publish(Document):
def validate(self):
self.published_date = str(date.today())
self.published_by = frappe.session.email
self.published_by = frappe.session.user
# Selected variant and kilometer mapping details list
variant = []
for vm in self.get('publish_documents'):
@ -37,26 +37,24 @@ class Publish(Document):
# variant.append(vm.variant_mapping)
if vm.variant_mapping not in variant:
variant.append(vm.variant_mapping)
if self.publish_module == 'Feature Finder' and self.feature_finder_publish_docs:
if self.publish_module=='Feature Finder' and self.feature_finder_publish_docs:
for vm in self.get('feature_finder_publish_docs'):
if vm.variant not in variant:
variant.append(vm.variant)
if vm.variant not in variant:
variant.append(vm.variant)
self.variant_mapping_details = ''
self.kilometer_mapping_details = ''
for v in variant:
self.variant_mapping_details = self.variant_mapping_details + \
str(v) + '\n'
km_mapping_record = frappe.db.sql("""select name from {0}.`tabKilometer Mapping` where variant_mapping = "{1}"
and language = '{2}'""".format(current_db_name, str(v), self.language),
as_dict=1)
km_mapping_record = frappe.db.sql("""select name from {0}.`tabKilometer Mapping` where variant_mapping = "{1}" and
language = '{2}'""".format(current_db_name, str(v), self.language), as_dict=1)
for km_mapping in km_mapping_record:
self.kilometer_mapping_details = self.kilometer_mapping_details + \
str(km_mapping.name) + '\n'
def on_submit(self):
if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Repair service' and \
self.publish_type == 'Internal':
if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Repair service' and self.publish_type == 'Internal':
repair_checksheet_publish(self.vehicle, self.vehicle_id,
self.language, self.publish_type,
self.release_description, self.variant,
@ -64,8 +62,7 @@ class Publish(Document):
update_publish_status = frappe.db.sql(
"""update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name))
if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Feature Finder' \
and self.publish_type == 'Internal' and self.feature_finder_publish_docs:
if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Feature Finder' and self.publish_type == 'Internal' and self.feature_finder_publish_docs:
feature_finder_publish(self.vehicle, self.vehicle_id,
self.language, self.publish_type,
self.release_description, self.feature_finder_publish_docs, self.variant)
@ -80,17 +77,17 @@ class Publish(Document):
update_feature_published_docs(self)
update_publish_status = frappe.db.sql(
"""update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name))
if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Repair service' \
and self.publish_type == 'Global' and self.repiar_checksheet_publish_docs:
if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Repair service' and self.publish_type == 'Global' and self.repiar_checksheet_publish_docs:
repair_checksheet_publish(self.vehicle, self.vehicle_id,
self.language, self.publish_type,
self.release_description, self.variant,
self.repiar_checksheet_publish_docs)
update_repair_published_docs(self)
update_publish_status = frappe.db.sql(
"""update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name))
variant = self.variant_mapping_details.split('/n')
frappe.log_error('variant', str(variant))
# for v in variant:
# frappe.log_error('v', str(v))
@ -101,12 +98,10 @@ class Publish(Document):
def onload1(self):
current_db_name = frappe.conf.get("db_name")
# To validate updated procedure status
procedure_status = frappe.db.sql("""select p.name,p.update_procedure_status,pro.name,p.variant_mapping,p.system,
p.sub_system,p.asset_category,p.item_category,p.variant,p.procedure_link,
p.procedure_status,pro.name,pro.workflow_state from {0}.`tabPublish_Docs`
as p,{0}.`tabProcedure` as pro where p.parent = '{1}' and
p.procedure_link = pro.name and p.procedure_link is not null""".format(
current_db_name, self.name), as_dict=1)
procedure_status = frappe.db.sql("""select p.name,p.update_procedure_status,pro.name,p.variant_mapping,p.system,p.sub_system,p.asset_category,
p.item_category,p.variant,p.procedure_link,p.procedure_status,pro.name,pro.workflow_state
from {0}.`tabPublish_Docs` as p,{0}.`tabProcedure` as pro where p.parent = '{1}' and
p.procedure_link = pro.name and p.procedure_link is not null""".format(current_db_name, self.name), as_dict=1)
l = len(procedure_status)
if procedure_status and self.publish_status == "Published":
@ -115,24 +110,18 @@ class Publish(Document):
if y.procedure_link:
if x.procedure_link == y.procedure_link and y.update_procedure_status != y.procedure_status:
y.update_procedure_status = x.workflow_state
frappe.db.sql(
"""update `tabPublish_Docs` set update_procedure_status = %s where parent = %s and procedure_link = %s ; """,
(
x.workflow_state, self.name, x.procedure_link))
frappe.db.sql("""update `tabPublish_Docs` set update_procedure_status = %s where parent = %s and procedure_link = %s ; """, (
x.workflow_state, self.name, x.procedure_link))
frappe.db.commit()
if x.procedure_link == y.procedure_link and x.workflow_state != y.procedure_status:
y.update_procedure_status = x.workflow_state
frappe.db.sql(
"""update `tabPublish_Docs` set update_procedure_status = %s where parent = %s and procedure_link = %s""",
(
x.workflow_state, self.name, x.procedure_link))
frappe.db.sql("""update `tabPublish_Docs` set update_procedure_status = %s where parent = %s and procedure_link = %s""", (
x.workflow_state, self.name, x.procedure_link))
frappe.db.commit()
if y.procedure_status == "Publish Ready":
if x.procedure_link == y.procedure_link and x.workflow_state != y.procedure_status and not\
y.excluded_global:
if x.procedure_link == y.procedure_link and x.workflow_state != y.procedure_status and not y.excluded_global:
y.excluded_global = "1"
if x.procedure_link == y.procedure_link and x.workflow_state != y.procedure_status and \
x.workflow_state == "Draft" and y.procedure_status != "Publish Ready":
if x.procedure_link == y.procedure_link and x.workflow_state != y.procedure_status and x.workflow_state == "Draft" and y.procedure_status != "Publish Ready":
y.excluded_internal = "1"
y.save()
frappe.db.commit()
@ -140,9 +129,8 @@ class Publish(Document):
# Update system and variant mapping ststus
if self.publish_status == "Published" and self.publish_type == "Global":
current_db_name = frappe.conf.get("db_name")
global_publish = frappe.db.sql(
"""select name from {0}.`tabPublish` where global_publish = "{1}"; """.format(
current_db_name, self.name), as_dict=True)
global_publish = frappe.db.sql("""select name from {0}.`tabPublish` where global_publish = "{1}"; """.format(
current_db_name, self.name), as_dict=True)
for global_name in global_publish:
update_mapping(self.variant_mapping, global_name.name)
@ -167,13 +155,11 @@ def update_procedure(vehicle, lang, publish_type, doc):
# To validate updated procedure status
doc = frappe.get_doc("Publish", doc)
current_db_name = frappe.conf.get("db_name")
procedure_status = frappe.db.sql("""select p.name,p.update_procedure_status,pro.name,p.variant_mapping,p.system,
p.sub_system,p.asset_category,p.item_category,p.variant,p.procedure_link,
p.procedure_status,pro.name,pro.workflow_state from {0}.`tabPublish_Docs` as p,
{0}.`tabProcedure` as pro where p.parent = "{1}" and p.procedure_link = pro.name
and pro.workflow_state != p.update_procedure_status
and p.procedure_link is not null""".format(current_db_name, doc.name),
as_dict=1)
procedure_status = frappe.db.sql("""select p.name,p.update_procedure_status,pro.name,p.variant_mapping,p.system,p.sub_system,p.asset_category,
p.item_category,p.variant,p.procedure_link,p.procedure_status,pro.name,pro.workflow_state
from {0}.`tabPublish_Docs` as p,{0}.`tabProcedure` as pro
where p.parent = "{1}" and p.procedure_link = pro.name and pro.workflow_state != p.update_procedure_status
and p.procedure_link is not null""".format(current_db_name, doc.name), as_dict=1)
l = len(procedure_status)
if procedure_status:
for x in procedure_status:
@ -181,16 +167,13 @@ def update_procedure(vehicle, lang, publish_type, doc):
if y.procedure_link:
if x.procedure_link == y.procedure_link and x.workflow_state != y.update_procedure_status:
y.update_procedure_status = x.workflow_state
frappe.db.sql(
"""update `tabPublish_Docs` set update_procedure_status = %s where procedure_link = %s""", (
x.workflow_state, x.procedure_link))
frappe.db.sql("""update `tabPublish_Docs` set update_procedure_status = %s where procedure_link = %s""", (
x.workflow_state, x.procedure_link))
frappe.db.commit()
if y.procedure_status == "Publish Ready":
if x.procedure_link == y.procedure_link and x.workflow_state != y.procedure_status and \
not y.excluded_global:
if x.procedure_link == y.procedure_link and x.workflow_state != y.procedure_status and not y.excluded_global:
y.excluded_global = "1"
if x.procedure_link == y.procedure_link and x.workflow_state != y.procedure_status and \
x.workflow_state == "Draft" and y.procedure_status != "Publish Ready":
if x.procedure_link == y.procedure_link and x.workflow_state != y.procedure_status and x.workflow_state == "Draft" and y.procedure_status != "Publish Ready":
y.excluded_internal = "1"
y.save()
@ -218,47 +201,57 @@ def update_procedure(vehicle, lang, publish_type, doc):
if str(table_len) == str(len_publish):
frappe.throw("There is no item for global publish")
# Generate Publish versions
def update_publish_mapping(vehicle, variant, language, module):
def update_publish_mapping(vehicle, variant, language, module,publish_type):
frappe.set_user('Administrator')
pub_data = frappe.db.get_list('Module Publish Mapping', filters={
"vehicle": vehicle,
"variant": variant,
"language": language
}, fields=['name'])
if pub_data:
doc = frappe.get_doc('Module Publish Mapping', pub_data[0]['name'])
if module == 'Repair service':
pub_data = frappe.db.get_list('Module Publish Mapping', filters={
"vehicle": vehicle,
"language": language,
"publish_type":publish_type
}, fields=['name'])
if len(pub_data)>0:
for d in pub_data:
if d['name']:
frappe.db.sql(f"""UPDATE `tabModule Publish Mapping` set repairservice_check_sheet='1' and publish_type='1' where name ='{d['name']}'""",as_dict=1)
frappe.db.commit()
else:
doc = frappe.get_doc({
'doctype': 'Module Publish Mapping',
pub_data = frappe.db.get_list('Module Publish Mapping', filters={
"vehicle": vehicle,
"variant": variant,
"language": language
})
if module == 'Automotive System':
doc.automotive_system = 1
doc.tsb = 1
doc.fsa = 1
doc.tekalert = 1
elif module == 'Feature Finder':
doc.feature_finder = 1
elif module == 'Repair service':
doc.repairservice_check_sheet = 1
doc.save()
"language": language,
"publish_type":publish_type
}, fields=['name'])
if pub_data:
doc = frappe.get_doc('Module Publish Mapping', pub_data[0]['name'])
else:
doc = frappe.get_doc({
'doctype': 'Module Publish Mapping',
"vehicle": vehicle,
"variant": variant,
"language": language
})
if module == 'Automotive System':
doc.automotive_system = 1
doc.tsb = 1
doc.fsa = 1
doc.tekalert = 1
def update_publish_status(self):
try:
update_status = frappe.db.sql(
"""update `tabPublish` set publish_status="Published" where name='{0}' """.format(self.name))
except Exception as e:
return e
elif module == 'Feature Finder':
doc.feature_finder = 1
doc.save()
# def update_publish_status(self):
# try:
# update_status = frappe.db.sql(
# """update `tabPublish Test` set publish_status="Published" where name='{0}' """.format(self.name))
# except Exception as e:
# return e
@frappe.whitelist()
@ -287,7 +280,6 @@ def cal_ver(vehicle, lang, publish_type, doc):
frappe.db.commit()
return v
# Create global publish document for publish ready procedures
@ -296,10 +288,10 @@ def global_publish(doc):
doc = frappe.get_doc("Publish", doc)
current_db_name = frappe.conf.get("db_name")
procedure = frappe.db.sql(
"""select parent,name from {0}.`tabPublish_Docs` where parent = "{1}" and update_procedure_status='Publish Ready'
and procedure_link is not null; """.format(current_db_name, doc.name))
asset = frappe.db.sql("""select parent,name from {0}.`tabPublish_Docs` where parent = "{1}" and variant_mapping is
not null and procedure_link is null""".format(current_db_name, doc.name))
"""select parent,name from {0}.`tabPublish_Docs` where parent = "{1}" and update_procedure_status='Publish Ready' and
procedure_link is not null; """.format(current_db_name, doc.name))
asset = frappe.db.sql("""select parent,name from {0}.`tabPublish_Docs` where parent = "{1}" and variant_mapping is not null
and procedure_link is null""".format(current_db_name, doc.name))
if not procedure and not asset:
frappe.throw("There is no item for global publish")
@ -342,28 +334,28 @@ def global_publish(doc):
@frappe.whitelist()
def generate_global_publish(name, module_name):
def generate_global_publish(name,module_name):
try:
res = frappe.get_doc("Publish", name)
if module_name == 'Feature Finder':
if module_name=='Feature Finder':
ret = frappe.get_doc({
"doctype": "Publish",
"vehicle": res.vehicle,
"publish_type": "Global",
"language": res.language,
"variant_mapping_details": res.variant_mapping_details,
"variant_mapping_details":res.variant_mapping_details,
"publish_status": 'To Publish',
"release_description": res.release_description,
"publish_module": res.publish_module,
"feature_finder_publish_docs": res.feature_finder_publish_docs
})
elif module_name == 'Repair service':
ret = frappe.get_doc({
ret = frappe.get_doc({
"doctype": "Publish",
"vehicle": res.vehicle,
"publish_type": "Global",
"language": res.language,
"variant_mapping_details": res.variant_mapping,
"variant_mapping_details":res.variant_mapping,
"publish_status": 'To Publish',
"release_description": res.release_description,
"publish_module": res.publish_module,
@ -390,7 +382,6 @@ def old_publish(vehicle, language):
if global_publish_record:
return global_publish_record
# Update System and Variant Mapping and its called from publish client script
@ -405,37 +396,31 @@ def update_mapping(variant_mapping, doc):
for v in vm.get('assets'):
if v.category == variant.asset_category:
v.published = '1'
frappe.db.sql(
"""update {0}.`tabVariant Mapping_Assets` set published = '1' where parent = "{1}" and
category = "{2}";""".format(current_db_name, variant.variant_mapping, variant.asset_category))
frappe.db.sql("""update {0}.`tabVariant Mapping_Assets` set published = '1' where parent = "{1}" and category = "{2}";""".format(
current_db_name, variant.variant_mapping, variant.asset_category))
frappe.db.commit()
if variant.item_category == "System Mapping":
system_mapping = frappe.db.sql(
"""select name from {0}.`tabSystem Mapping` where variant_mapping = "{1}" and language = "{2}";""".format(
current_db_name, variant.variant_mapping, doc.language), as_dict=1)
system_mapping = frappe.db.sql("""select name from {0}.`tabSystem Mapping` where variant_mapping = "{1}" and language = "{2}";""".format(
current_db_name, variant.variant_mapping, doc.language), as_dict=1)
if system_mapping:
for system_map in system_mapping:
sm = frappe.get_doc("System Mapping", system_map.name)
for sys_asset in sm.get('systems_assets'):
if sys_asset.systems == variant.system:
sys_asset.published = '1'
frappe.db.sql(
"""update {0}.`tabSystem Mapping_System Assets` set published = '1' where
parent = "{1}" and systems = "{2}";""".format(
current_db_name, sm.name, variant.system))
frappe.db.sql("""update {0}.`tabSystem Mapping_System Assets` set published = '1' where parent = "{1}" and systems = "{2}";""".format(
current_db_name, sm.name, variant.system))
frappe.db.commit()
for sm_item in sm.get("system_sub_systems"):
if sm_item.systems == variant.system and sm_item.sub_systems == variant.sub_system and \
sm_item.procedure == variant.procedure_link:
if sm_item.systems == variant.system and sm_item.sub_systems == variant.sub_system and sm_item.procedure == variant.procedure_link:
sm_item.procedure_is_published = '1'
frappe.db.sql("""update {0}.`tabSystem Mapping_Sub System` set procedure_is_published =
'1' where parent = "{1}" and systems = "{2}" and sub_systems = "{3}";""".format(
frappe.db.sql("""update {0}.`tabSystem Mapping_Sub System` set procedure_is_published = '1' where parent = "{1}"
and systems = "{2}" and sub_systems = "{3}";""".format(
current_db_name, sm.name, variant.system, variant.sub_system))
frappe.db.commit()
# Set filter for latest modified document
@ -443,37 +428,31 @@ def update_mapping(variant_mapping, doc):
def get_vm_asset(doc, lang):
doc = frappe.get_doc("Variant Mapping", doc)
vm_assets = frappe.db.sql("""select category,language,attach_file,active_status from {0}.`tabVariant Mapping_Assets`
where parent = "{1}" and language ='{2}' and published = 0; """.format(current_db_name,
doc.name, lang),
as_dict=1)
where parent = "{1}" and language ='{2}' and published = 0; """.format(current_db_name, doc.name, lang), as_dict=1)
return vm_assets
@frappe.whitelist()
def get_sm_asset(doc, name, lang):
system_map = frappe.db.sql(
"""select name from {0}.`tabSystem Mapping` where variant_mapping="{1}" and name = "{2}" and language = '{3}'; """.format(
current_db_name, doc, name, lang), as_dict=1)
system_map = frappe.db.sql("""select name from {0}.`tabSystem Mapping` where variant_mapping="{1}" and name = "{2}" and language = '{3}'; """.format(
current_db_name, doc, name, lang), as_dict=1)
if system_map:
for s in system_map:
doc = frappe.get_doc("System Mapping", s.name)
system_asset = frappe.db.sql("""select systems,language,active_status,system_asset from {0}.`tabSystem Mapping_System Assets`
where parent = "{1}" and language = "{2}" and published = '0'; """.format(current_db_name, s.name,
lang), as_dict=1)
where parent = "{1}" and language = "{2}" and published = '0'; """.format(current_db_name, s.name, lang), as_dict=1)
return system_asset
@frappe.whitelist()
def get_system(doc, name, lang):
system_map = frappe.db.sql(
"""select name from {0}.`tabSystem Mapping` where variant_mapping="{1}" and name = "{2}" and language = "{3}";""".format(
current_db_name, doc, name, lang), as_dict=1)
system_map = frappe.db.sql("""select name from {0}.`tabSystem Mapping` where variant_mapping="{1}" and name = "{2}" and language = "{3}";""".format(
current_db_name, doc, name, lang), as_dict=1)
if system_map:
for s in system_map:
doc = frappe.get_doc("System Mapping", s.name)
system = frappe.db.sql("""select systems,sub_systems,active_status,symptom,component,estimate_time,rts,
component,mat,procedure_status,`procedure` from {0}.`tabSystem Mapping_Sub System`
where parent = "{1}" and procedure_status != "Draft" and
system = frappe.db.sql("""select systems,sub_systems,active_status,symptom,component,estimate_time,rts,component,mat,
procedure_status,`procedure` from {0}.`tabSystem Mapping_Sub System` where parent = "{1}" and procedure_status != "Draft" and
procedure_is_published = "0";""".format(current_db_name, s.name), as_dict=1)
return system
@ -481,9 +460,8 @@ 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(
current_db_name, doc.vehicle, doc.language))
ver = frappe.db.sql("""select max(version) from {0}.tabPublish where vehicle = "{1}" and language = "{2}";""".format(
current_db_name, doc.vehicle, doc.language))
if ver:
return ver
@ -492,11 +470,9 @@ def max_publish(doc):
def variant(doctype, txt, searchfield, start, page_len, filters):
vehicle = filters.get('vehicle')
return frappe.db.sql(""" select name,family_code,fuel,transmission,vehicle_segment,active_status
FROM {0}.`tabVariant Mapping` where vehicle = "{1}" and
(active_status like "%%%(txt)s%%" or vehicle_segment like "%%%(txt)s%%" or name like "%%%(txt)s%%" or
variant like "%%%(txt)s%%" or family_code like "%%%(txt)s%%" or fuel like "%%%(txt)s%%" or
transmission like "%%%(txt)s%%") order by modified desc limit %(start)s, %(page_len)s """.format(
current_db_name, vehicle) % {'txt': txt, 'start': start, 'page_len': page_len})
FROM {0}.`tabVariant Mapping` where vehicle = "{1}" and
(active_status like "%%%(txt)s%%" or vehicle_segment like "%%%(txt)s%%" or name like "%%%(txt)s%%" or variant like "%%%(txt)s%%" or
family_code like "%%%(txt)s%%" or fuel like "%%%(txt)s%%" or transmission like "%%%(txt)s%%") order by modified desc limit %(start)s, %(page_len)s """.format(current_db_name, vehicle) % {'txt': txt, 'start': start, 'page_len': page_len})
@frappe.whitelist()
@ -508,12 +484,10 @@ def update_procedure_value(name, file_path):
frappe.db.commit()
current_db_name = frappe.conf.get("db_name")
# To validate updated procedure status
procedure_status = frappe.db.sql("""select p.name,p.update_procedure_status,pro.name,p.variant_mapping,p.system,
p.sub_system,p.asset_category,p.item_category,p.variant,p.procedure_link,
p.procedure_status,pro.name,pro.workflow_state
procedure_status = frappe.db.sql("""select p.name,p.update_procedure_status,pro.name,p.variant_mapping,p.system,p.sub_system,
p.asset_category,p.item_category,p.variant,p.procedure_link,p.procedure_status,pro.name,pro.workflow_state
from {0}.`tabPublish_Docs` as p,{0}.`tabProcedure` as pro where p.parent = "{1}" and
p.procedure_link = pro.name and p.procedure_link is not null""".format(
current_db_name, self.name), as_dict=1)
p.procedure_link = pro.name and p.procedure_link is not null""".format(current_db_name, self.name), as_dict=1)
# l = len(procedure_status)
if procedure_status:
@ -522,23 +496,18 @@ def update_procedure_value(name, file_path):
if y.procedure_link:
if x.procedure_link == y.procedure_link and y.update_procedure_status != y.procedure_status:
y.update_procedure_status = x.workflow_state
frappe.db.sql(
"""update `tabPublish_Docs` set update_procedure_status = %s where parent = %s and procedure_link = %s ; """,
(
x.workflow_state, self.name, x.procedure_link))
frappe.db.sql("""update `tabPublish_Docs` set update_procedure_status = %s where parent = %s and procedure_link = %s ; """, (
x.workflow_state, self.name, x.procedure_link))
frappe.db.commit()
if x.procedure_link == y.procedure_link and x.workflow_state != y.procedure_status:
y.update_procedure_status = x.workflow_state
frappe.db.sql(
"""update `tabPublish_Docs` set update_procedure_status = %s where parent = %s and procedure_link = %s""",
(
x.workflow_state, self.name, x.procedure_link))
frappe.db.sql("""update `tabPublish_Docs` set update_procedure_status = %s where parent = %s and procedure_link = %s""", (
x.workflow_state, self.name, x.procedure_link))
frappe.db.commit()
if y.procedure_status == "Publish Ready":
if x.procedure_link == y.procedure_link and x.workflow_state != y.procedure_status and not y.excluded_global:
y.excluded_global = "1"
if x.procedure_link == y.procedure_link and x.workflow_state != y.procedure_status and \
x.workflow_state == "Draft" and y.procedure_status != "Publish Ready":
if x.procedure_link == y.procedure_link and x.workflow_state != y.procedure_status and x.workflow_state == "Draft" and y.procedure_status != "Publish Ready":
y.excluded_internal = "1"
y.save()
frappe.db.commit()
@ -567,6 +536,7 @@ def update_feature_published_docs(self):
try:
for d in self.feature_finder_publish_docs:
frappe.db.sql(
"""UPDATE `tabFeature Finder` set is_published=1 where name='{0}'""".format(d.parent1))
frappe.db.commit()
@ -579,6 +549,7 @@ def update_repair_published_docs(self):
try:
for d in self.repair_checksheet_publish:
frappe.db.sql(
"""UPDATE `tabRepair Service Mapping` set published=1 where name='{0}'""".format(d.parent_name))
frappe.db.commit()
@ -612,14 +583,29 @@ def get_service_repair(vehicle,
select * from `tabRepair Service Mapping` where vehicle = '{vehicle}' and language='{language_label}' and published = 0;
''', as_dict=1)
return data
def create_df(data_set):
# with open(base_url+'data.json', 'w') as outfile:
# outfile.write(json.dumps(feature_finder_tmp, indent=4, default=str))
# with open(base_url+'data.json') as f:
# feature_finder_tmp = json.load(f)
feature_finder_tmp=json.dumps(data_set)
df = pd.DataFrame(json.loads(feature_finder_tmp))
filter_group=df.groupby('variant')
keys=filter_group.groups.keys()
res={}
for i in keys:
res[i]=(filter_group.get_group(i))
res1={}
for key,value in res.items():
res1[key]=value.to_dict('records')
return res1
@frappe.whitelist()
def get_feature_finder(vehicle=None, variant=None, language_label=None):
try:
data = frappe.db.sql(
f"""select * from `tabFeature Finder` where vehicle='{vehicle}' and variant_id='{variant}' and language='{language_label}'
and is_published=0""", as_dict=1)
f"""select * from `tabFeature Finder` where vehicle='{vehicle}' and variant_id='{variant}' and language='{language_label}' and is_published=0""", as_dict=1)
return data
except Exception as e:
return str(e)
@ -634,8 +620,7 @@ def repair_checksheet_publish(vehicle, vehicle_id,
logger.info(
f'Repair Checksheet Started-{vehicle}-{language}-{publish_type}-{parent}')
folder_url = base_url + "/" + \
vehicle.replace(' ', '-') + "/" + language
folder_url = base_url+"/"+vehicle.replace(' ', '-') + "/"+language
logger.info(f'Created Folder-{vehicle}-{language}-{publish_type}')
'''Publish Ready Flags'''
@ -672,7 +657,7 @@ def repair_checksheet_publish(vehicle, vehicle_id,
repair_checksheet['data'][0])
repair_checksheet_tmp = get_latest_data({'data': published_data['data']}, {
'data': repair_checksheet_tmp})
'data': repair_checksheet_tmp})
else:
for i in parent:
@ -714,8 +699,7 @@ def feature_finder_publish(vehicle=None, vehicle_id=None,
logger.info(
f"start of fetching repair checksheet data - {vehicle} - {language} - {module_name} - {variant}")
folder_url = base_url + "/" + \
vehicle.replace(' ', '-') + "/" + language
folder_url = base_url+"/"+vehicle.replace(' ', '-') + "/"+language
logger.info(f'Created Folder-{vehicle}-{language}-{publish_type}')
'''Final Json'''
@ -751,10 +735,13 @@ def feature_finder_publish(vehicle=None, vehicle_id=None,
publish_repair_checksheet = 1
feature_finder_tmp.append(
feature_finder['data'][0])
feature_finder_tmp=create_df(feature_finder_tmp)
# frappe.msgprint(str(json.dumps(feature_finder_tmp)))
feature_finder_tmp = get_latest_data(
{'data': published_data['data']}, {'data': feature_finder_tmp})
# feature_finder_tmp = get_latest_data(
# {'data': published_data['data']}, {'data': feature_finder_tmp})
vehi_data = compare_get_data( {'data': published_data['data']}, {'data': feature_finder_tmp})
else:
for i in parent:
@ -771,10 +758,12 @@ def feature_finder_publish(vehicle=None, vehicle_id=None,
feature_finder_tmp = get_latest_data(
{'data': feature_finder_tmp}, {'data': []})
vehi_data=create_df(feature_finder_tmp)
# if publish_feature_finder == 1:
""" Save publish file """
vehicle_data['data'] = feature_finder_tmp
vehicle_data['data'] = vehi_data
with open(file_path, 'w') as outfile:
outfile.write(json.dumps(vehicle_data, indent=4, default=str))
logger.info(
@ -801,7 +790,6 @@ def get_latest_data(prev_data, latest_data):
data_dic2 = get_key_value_data(latest_data)
final_dic = data_dic1.copy()
for d1 in data_dic1:
if data_dic1[d1]['active_status'] == 'Inactive':
final_dic.pop(d1)
@ -813,11 +801,30 @@ def get_latest_data(prev_data, latest_data):
final_dic.update({d2: data_dic2[d2]})
final_list = list(final_dic.values())
return final_list
except Exception as e:
frappe.throw(str(e))
def compare_get_data(prev_data, latest_data):
try:
final_dic={}
for key,value in prev_data.items():
prev_data[key]=latest_data.get(key)
final_dic=copy.deepcopy(prev_data)
for key,value in final_dic["data"].items():
for i in value:
if i['active_status']=="Inactive":
value.remove(i)
return final_dic["data"]
except Exception as e:
frappe.throw(str(e))
def repair_checksheet_data(vehicle=None, language=None,
publish_type=None, parent=None):
@ -867,59 +874,52 @@ def feature_finder_data(vehicle=None, language=None,
f"start of fetching feature finder checksheet data - {vehicle} - {language} - {variant} - {module_name}")
feature_finder_details = []
if language == 'en':
feature_finder_details = frappe.db.sql(f"""select ff.name,ff.vehicle,ff.vehicle_id,ff.variant,ff.variant_id,
ff.language,ff.features_names as feature_name,ff.feature_category,
ff.display_order,ff.active_status,ffm.feature_pdf as pdf from `tabFeature Finder` ff
left join `tabFeature Finder Master` ffm on ff.features_names = ffm.feature_name
feature_finder_details = frappe.db.sql(f"""select ff.name,ff.vehicle,ff.vehicle_id,ff.variant,ff.variant_id,ff.language,
ff.features_names as feature_name,ff.feature_category,ff.display_order,ff.active_status,
ffm.feature_pdf as pdf from `tabFeature Finder` ff left join `tabFeature Finder Master` ffm on
ff.features_names = ffm.feature_name
where ff.vehicle = "THAR" and ffm.vehicle = "{vehicle}"
and ff.variant = "{variant}" and ff.language = "{language}" and
ffm.language = "{language}" and ff.name="{parent}";
and ff.variant = "{variant}"
and ff.language = "{language}" and ffm.language = "{language}" and ff.name="{parent}";
""", as_dict=1)
logger.info(feature_finder_details)
else:
feature_finder_details = frappe.db.sql(f"""select ff.name,ff.vehicle,ff.vehicle_id,ff.variant,ff.variant_id,
ff.language,ff.translated_feature_name as feature_name,
ff.feature_category,ff.display_order,ff.active_status,
ffm.feature_pdf as pdf from `tabFeature Finder` ff
feature_finder_details = frappe.db.sql(f"""select ff.name,ff.vehicle,ff.vehicle_id,ff.variant,ff.variant_id,ff.language,
ff.translated_feature_name as feature_name,ff.feature_category,
ff.display_order,ff.active_status,ffm.feature_pdf as pdf from `tabFeature Finder` ff
left join `tabFeature Finder Master` ffm on ff.features_names = ffm.feature_name
where ff.vehicle = "{vehicle}" and ffm.vehicle = "{vehicle}"
and ff.variant = "{variant}" and ff.language = "{language}"
and ff.name="{parent}" ; """, as_dict=1)
where ff.vehicle = "{vehicle}" and ffm.vehicle = "{vehicle}" and ff.variant = "{variant}"
and ff.language = "{language}" and ff.name="{parent}" ; """, as_dict=1)
for f in feature_finder_details:
f['disclaimer'] = frappe.db.sql(f'''
SELECT name,content,active_status,idx as display_order FROM `tabFeature Finder Disclaimer`
where parent = '{str(f['vehicle']) + str('-') + str(f['feature_name']) + str('-') + str(f['language'])}';
where parent = '{str(f['vehicle'])+ str('-')+ str(f['feature_name']) +str('-')+str(f['language'])}';
''', as_dict=1)
sop_images = frappe.db.sql(f""" select image,display_order,active_status from `tabFeature Finder Images` where
parent = '{f['name']}' and feature_type ='SOP' order by display_order desc;""",
as_dict=1)
parent = '{f['name']}' and feature_type ='SOP' order by display_order desc;""", as_dict=1)
sop_content = frappe.db.sql(f"""select content,display_order, active_status from `tabFeature Finder Content`
where parent = '{f['name']}' and feature_type ='SOP' order by display_order desc;""",
as_dict=1)
where parent = '{f['name']}' and feature_type ='SOP' order by display_order desc;""", as_dict=1)
sop_specification = frappe.db.sql(f"""select specification,value,display_order,active_status from `tabFeature Finder Specification`
where parent = '{f['name']}' and feature_type ='SOP' order by display_order desc;""",
as_dict=1)
where parent = '{f['name']}' and feature_type ='SOP' order by display_order desc;""", as_dict=1)
f['sop'] = {'content': sop_content, 'images': sop_images,
'specificaton': sop_specification}
post_vin_data = frappe.db.sql(f'''select name,idx as display_order,post_vin_cutoff_name,post_vin_cutoff_id
from `tabPost Vin Cutoff ID` where parent = '{f['name']}';''', as_dict=1)
for p in post_vin_data:
vin_content = frappe.db.sql(f"""select content,display_order, active_status from `tabFeature Finder Content`
where parent = '{f['name']}' and post_vin_cutoff_name ='{p['post_vin_cutoff_name']}' order by display_order desc;""",
as_dict=1)
where parent = '{f['name']}' and post_vin_cutoff_name ='{p['post_vin_cutoff_name']}' order by display_order desc;""", as_dict=1)
vin_images = frappe.db.sql(f""" select image,display_order,active_status from `tabFeature Finder Images` where
parent = '{f['name']}' and post_vin_cutoff_name ='{p['post_vin_cutoff_name']}' order by display_order desc;""",
as_dict=1)
parent = '{f['name']}' and post_vin_cutoff_name ='{p['post_vin_cutoff_name']}' order by display_order desc;""", as_dict=1)
vin_specification = frappe.db.sql(f"""select specification,value,display_order,active_status from `tabFeature Finder Specification`
where parent = '{f['name']}' and post_vin_cutoff_name ='{p['post_vin_cutoff_name']}' order by display_order desc;""",
as_dict=1)
where parent = '{f['name']}' and post_vin_cutoff_name ='{p['post_vin_cutoff_name']}' order by display_order desc;""", as_dict=1)
p['content'] = vin_content
p['images'] = vin_images
p['specificaton'] = vin_specification
@ -943,9 +943,8 @@ def feature_finder_data(vehicle=None, language=None,
@frappe.whitelist()
def max_publish_new_module(doc):
doc = frappe.get_doc("Publish", doc)
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))
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
@ -954,9 +953,8 @@ def max_publish_new_module(doc):
def cal_ver_new_module(vehicle, lang, publish_type, doc):
current_db_name = frappe.conf.get("db_name")
doc = frappe.get_doc("Publish", doc)
ver = frappe.db.sql(
"""select max(version) from `tabPublish` where vehicle = "{vehi}" and language = "{lang}" and publish_module!="Automotive System";"""
.format(vehi=vehicle, lang=lang))
ver = frappe.db.sql("""select max(version) from `tabPublish` where vehicle = "{vehi}" and language = "{lang}" and publish_module!="Automotive System";"""
.format(vehi=vehicle, lang=lang))
v = 0.0
if publish_type == 'Global':
if ver[0][0] == None:

Loading…
Cancel
Save