Browse Source

Child table validation check field ON Load validation

master
venkataakhil 1 year ago
parent
commit
050dbf73ab
  1. 1
      smart_service/transactions/doctype/publish/publish.js
  2. 9
      smart_service/transactions/doctype/publish/publish.json
  3. 57
      smart_service/transactions/doctype/publish/publish.py

1
smart_service/transactions/doctype/publish/publish.js

@ -126,6 +126,7 @@ frappe.ui.form.on('Publish', {
if (r.message != "Failed to save file") {
frm.set_value('publish_status', 'Published');
frm.set_value('actual_published_date', frappe.datetime.nowdate());
frm.set_value('child_table_updated', '1');
frappe.msgprint({
title: __('Notification'),
message: __('Successfully Published' + r.message),

9
smart_service/transactions/doctype/publish/publish.json

@ -10,6 +10,7 @@
"planned_publish_date",
"actual_published_date",
"publish_type",
"child_table_updated",
"publish_status",
"column_break_3",
"release_description",
@ -296,12 +297,18 @@
"fieldtype": "Small Text",
"label": "Kilometer Mapping List",
"read_only": 1
},
{
"fieldname": "child_table_updated",
"fieldtype": "Select",
"label": "Child Table Updated",
"options": "0\n1"
}
],
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2022-10-18 16:02:09.597920",
"modified": "2023-05-16 14:02:25.547907",
"modified_by": "Administrator",
"module": "Transactions",
"name": "Publish",

57
smart_service/transactions/doctype/publish/publish.py

@ -33,33 +33,36 @@ class Publish(Document):
str(km_mapping.name) + '\n'
def onload(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=True)
l = len(procedure_status)
if procedure_status and self.publish_status == "Published":
for x in procedure_status:
for y in self.get("publish_documents"):
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.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.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":
y.excluded_internal = "1"
y.save()
frappe.db.commit()
if self.child_table_updated = 1:
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=True)
l = len(procedure_status)
if procedure_status and self.publish_status == "Published":
for x in procedure_status:
for y in self.get("publish_documents"):
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.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.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":
y.excluded_internal = "1"
self.child_table_updated = '0'
y.save()
frappe.db.commit()
# Update system and variant mapping ststus
if self.publish_status == "Published" and self.publish_type == "Global":

Loading…
Cancel
Save