Browse Source

Publish route

version2
venkataakhil 1 year ago
parent
commit
4ca858d373
  1. 32
      smart_service/transactions/doctype/publish/publish.js
  2. 4
      smart_service/transactions/doctype/publish/publish.py

32
smart_service/transactions/doctype/publish/publish.js

@ -53,17 +53,16 @@ frappe.ui.form.on('Publish', {
},
refresh: function (frm) {
console.log("calling")
if (frm.doc.docstatus == 0 && !frm.is_new() && frm.doc.publish_type != "Global" && frm.doc.publish_module!="Automotive System") {
debugger
$('[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") {
debugger
$('[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')) {
debugger
frappe.call({
method: "smart_service.transactions.doctype.publish.publish.max_publish_new_module",
args: {
@ -71,7 +70,7 @@ frappe.ui.form.on('Publish', {
},
callback: function (r) {
if (r.message==frm.doc.version) {
debugger
if (r.message == frm.doc.version) {
frm.add_custom_button(__('Global Publish'), function () {
frappe.call({
@ -80,7 +79,8 @@ frappe.ui.form.on('Publish', {
"name": frm.doc.name,
},
callback: function (r) {
cur_frm.reload_doc();
window.location.href = r.message.url + "/app/publish" + "/" + r.message.message
}
});
}).addClass("btn-warning").css({ 'background-color': '#f5b0cd', 'color': 'black' });
@ -129,7 +129,7 @@ frappe.ui.form.on('Publish', {
},
callback: function (r) {
if (r.message) {
debugger
if (r.message == frm.doc.version) {
frm.add_custom_button(__('Global Publish'), function () {
frappe.call({
@ -151,13 +151,13 @@ 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') {
debugger
frappe.call({
method: 'smart_service.transactions.doctype.publish.publish.cal_ver',
args: {
@ -167,7 +167,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') {
@ -343,7 +343,7 @@ frappe.ui.form.on('Publish', {
if (frm.doc.docstatus == 1 && frm.doc.publish_status == 'To Publish' && !frm.is_new() && frm.doc.publish_module != 'Automotive System') {
debugger
frappe.call({
method: "smart_service.transactions.doctype.publish.publish.cal_ver_new_module",
args: {
@ -353,13 +353,13 @@ frappe.ui.form.on('Publish', {
doc: frm.doc.name
},
callback: function (r) {
debugger
if (r.message) {
frm.set_value('version', r.message);
cur_frm.refresh_field('version')
frm.page.clear_primary_action("Global Publish");
// if(frm.doc.publish_type == 'Internal'){
// debugger
//
// frm.page.clear_primary_action("Global Publish");
// }
@ -722,7 +722,7 @@ function add_to_publish(frm) {
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) {
debugger
if (r.message.length>0) {
var records = r.message
@ -756,7 +756,7 @@ function add_feature_finder(frm){
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) {
debugger
if (r.message.length>0) {
cur_frm.set_df_property('feature_finder_publish', 'hidden', 0)
var records = r.message

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

@ -693,7 +693,7 @@ def feature_finder_publish(vehicle=None, vehicle_id=None,
feature_finder_tmp = get_latest_data(
{'data': published_data['data']}, {'data': feature_finder_tmp})
frappe.msgprint(str(feature_finder_tmp))
else:
@ -715,8 +715,6 @@ def feature_finder_publish(vehicle=None, vehicle_id=None,
# if publish_feature_finder == 1:
""" Save publish file """
vehicle_data['data'] = feature_finder_tmp
frappe.msgprint(str(file_path))
with open(file_path, 'w') as outfile:
outfile.write(json.dumps(vehicle_data, indent=4, default=str))
logger.info(

Loading…
Cancel
Save