frappe.throw("Already publish record "+r.message+" created for "+vehicle+" vehicle. Please edit already available publish!")
frappe.throw("Already publish record "+r.message[0]['name']+" created for "+vehicle+" vehicle. Please edit already available "+r.message[0]['publish_type']+" publish!")
procedure=frappe.db.sql("""select parent,name from {0}.`tabPublish_Docs` where parent = '{1}' and update_procedure_status='Publish Ready'""".format(current_db_name,doc.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))
ifnotprocedure:
ifnotprocedureandnotasset:
frappe.throw("There is no item for global publish")
frappe.throw("There is no item for global publish")
# max_internal_ver = frappe.db.sql('''SELECT max(version) as max_version,name as name,publish_status as p FROM {}.tabPublish where vehicle='{}' and language ='{}' and publish_status = 'To Publish' and publish_type ='Internal';'''.format(current_db_name,doc.vehicle,doc.language),as_dict=True)
# max_internal_ver = frappe.db.sql('''SELECT max(version) as max_version,name as name,publish_status as p FROM {}.tabPublish where vehicle='{}' and language ='{}' and publish_status = 'To Publish' and publish_type ='Internal';'''.format(current_db_name,doc.vehicle,doc.language),as_dict=True)
publish_record=frappe.db.sql("""select name from {0}.`tabPublish` where vehicle = '{1}' and language = '{2}' and publish_status='To Publish' and publish_type = 'Internal' and docstatus != '2'""".format(current_db_name,vehicle,language),as_list=True)
publish_record=frappe.db.sql("""select name,publish_type from {0}.`tabPublish` where vehicle = '{1}' and language = '{2}' and publish_status='To Publish' and publish_type = 'Internal' and docstatus != '2'""".format(current_db_name,vehicle,language),as_dict=True)
ifpublish_record:
ifpublish_record:
returnpublish_record
returnpublish_record
global_publish_record=frappe.db.sql("""select name,vehicle from {0}.`tabPublish` where vehicle = '{1}' and language = '{2}' and publish_status='To Publish' and publish_type = 'Global' and docstatus != '2'""".format(current_db_name,vehicle,language),as_list=True)
global_publish_record=frappe.db.sql("""select name,publish_type from {0}.`tabPublish` where vehicle = '{1}' and language = '{2}' and publish_status='To Publish' and publish_type = 'Global' and docstatus != '2'""".format(current_db_name,vehicle,language),as_dict=True)
ifglobal_publish_record:
ifglobal_publish_record:
returnglobal_publish_record
returnglobal_publish_record
###Update System and Variant Mapping and its called from publish client script
###Update System and Variant Mapping and its called from publish client script