Browse Source

Update vehicle publish flags

master
venkataakhil 11 months ago
parent
commit
3f2ee8509f
  1. 13
      smart_service/transactions/doctype/publish/publish.py

13
smart_service/transactions/doctype/publish/publish.py

@ -6,12 +6,16 @@ from html import unescape
import frappe
from frappe.model.document import Document
import json
from datetime import date
current_db_name = frappe.conf.get("db_name")
sys.tracebacklimit = 0
class Publish(Document):
def validate(self):
self.published_date = str(date.today())
self.published_by = frappe.session.user
# Selected variant and kilometer mapping details list
variant = []
for vm in self.get('publish_documents'):
@ -83,6 +87,15 @@ class Publish(Document):
"Publish", self.name, "published_by", str(name))
frappe.db.commit()
def on_submit(self):
if self.publish_type == 'Internal':
frappe.db.sql(
'''update tabVehicle set internal_publish = 1 where vehicle= '{0}'; '''.format(self.vehicle))
else:
frappe.db.sql(
'''update tabVehicle set global_publish = 1 where vehicle= '{0}'; '''.format(self.vehicle))
def on_cancel(self):
# Published document should not allow to cancel
if self.publish_status == "Published":

Loading…
Cancel
Save