diff --git a/smart_service/transactions/doctype/publish/publish.js b/smart_service/transactions/doctype/publish/publish.js index 0c99cfd..19c4ecb 100644 --- a/smart_service/transactions/doctype/publish/publish.js +++ b/smart_service/transactions/doctype/publish/publish.js @@ -514,7 +514,7 @@ frappe.ui.form.on('Publish', { cur_frm.doc.vehicle_status = ''; cur_frm.refresh_field('vehicle'); cur_frm.refresh_field('vehicle_status'); - 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!") } } }); diff --git a/smart_service/transactions/doctype/publish/publish.py b/smart_service/transactions/doctype/publish/publish.py index a7e2bcb..2859c46 100644 --- a/smart_service/transactions/doctype/publish/publish.py +++ b/smart_service/transactions/doctype/publish/publish.py @@ -163,9 +163,9 @@ def cal_ver(vehicle,lang,publish_type,doc): 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'""".format(current_db_name,doc.name)) - - if not procedure: + 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)) + if not procedure and not asset: 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) @@ -198,12 +198,18 @@ def global_publish(doc): publish_table.asset_category = table.asset_category publish_table.item_category = table.item_category publish_table.variant = table.variant - for asset in doc.get('variant_mapping_assets'): - asset_table = publish_record.append('variant_mapping_assets',{}) - asset_table.category = asset.category - asset_table.language = asset.language - asset_table.attach_file = asset.attach_file - asset_table.active_status = asset.active_status + if table.variant_mapping and not table.procedure_link: + publish_table = publish_record.append('publish_documents',{}) + publish_table.variant_mapping = table.variant_mapping + publish_table.asset_category = table.asset_category + publish_table.item_category = table.item_category + publish_table.variant = table.variant + # for asset in doc.get('variant_mapping_assets'): + # asset_table = publish_record.append('variant_mapping_assets',{}) + # asset_table.category = asset.category + # asset_table.language = asset.language + # asset_table.attach_file = asset.attach_file + # asset_table.active_status = asset.active_status publish_record.save() doc.global_publish = publish_record.name @@ -213,10 +219,10 @@ def global_publish(doc): @frappe.whitelist() def old_publish(vehicle,language): current_db_name = frappe.conf.get("db_name") - 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) if publish_record: return publish_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) if global_publish_record: return global_publish_record ###Update System and Variant Mapping and its called from publish client script