Browse Source

db name globa;

master
venkataakhil 2 years ago
parent
commit
d0cd373bec
  1. 41
      smart_service/transactions/doctype/publish/publish.py

41
smart_service/transactions/doctype/publish/publish.py

@ -33,8 +33,9 @@ class Publish(Document):
str(km_mapping.name) + '\n' str(km_mapping.name) + '\n'
def onload(self): def onload(self):
current_db_name = frappe.conf.get("db_name")
if self.child_table_updated == 1: if self.child_table_updated == 1:
current_db_name = frappe.conf.get("db_name")
# To validate updated procedure status # 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 from {0}.`tabPublish_Docs` as p,{0}.`tabProcedure` as pro
@ -60,28 +61,28 @@ class Publish(Document):
y.excluded_global = "1" 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.excluded_internal = "1"
self.child_table_updated = '0' # self.child_table_updated = '0'
y.save() y.save()
frappe.db.commit() frappe.db.commit()
# Update system and variant mapping ststus # Update system and variant mapping ststus
if self.publish_status == "Published" and self.publish_type == "Global": if self.publish_status == "Published" and self.publish_type == "Global":
current_db_name = frappe.conf.get("db_name") current_db_name = frappe.conf.get("db_name")
global_publish = frappe.db.sql("""select name from {0}.`tabPublish` where global_publish = '{1}'""".format( global_publish = frappe.db.sql("""select name from {0}.`tabPublish` where global_publish = '{1}'""".format(
current_db_name, self.name), as_dict=True) current_db_name, self.name), as_dict=True)
for global_name in global_publish: for global_name in global_publish:
update_mapping(self.variant_mapping, global_name.name) update_mapping(self.variant_mapping, global_name.name)
u_id = frappe.get_all( u_id = frappe.get_all(
"User", filters={"name": frappe.session.user}, fields=["username"]) "User", filters={"name": frappe.session.user}, fields=["username"])
if u_id: if u_id:
for i in u_id: for i in u_id:
name = i.username name = i.username
if not self.published_by and self.publish_status == "Published": if not self.published_by and self.publish_status == "Published":
self.published_by = str(name) self.published_by = str(name)
frappe.db.set_value( frappe.db.set_value(
"Publish", self.name, "published_by", str(name)) "Publish", self.name, "published_by", str(name))
frappe.db.commit() frappe.db.commit()
def on_cancel(self): def on_cancel(self):
# Published document should not allow to cancel # Published document should not allow to cancel

Loading…
Cancel
Save