|
@ -6,12 +6,16 @@ from html import unescape |
|
|
import frappe |
|
|
import frappe |
|
|
from frappe.model.document import Document |
|
|
from frappe.model.document import Document |
|
|
import json |
|
|
import json |
|
|
|
|
|
from datetime import date |
|
|
|
|
|
|
|
|
current_db_name = frappe.conf.get("db_name") |
|
|
current_db_name = frappe.conf.get("db_name") |
|
|
sys.tracebacklimit = 0 |
|
|
sys.tracebacklimit = 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Publish(Document): |
|
|
class Publish(Document): |
|
|
def validate(self): |
|
|
def validate(self): |
|
|
|
|
|
self.published_date = str(date.today()) |
|
|
|
|
|
self.published_by = frappe.session.user |
|
|
# Selected variant and kilometer mapping details list |
|
|
# Selected variant and kilometer mapping details list |
|
|
variant = [] |
|
|
variant = [] |
|
|
for vm in self.get('publish_documents'): |
|
|
for vm in self.get('publish_documents'): |
|
@ -83,6 +87,15 @@ class Publish(Document): |
|
|
"Publish", self.name, "published_by", str(name)) |
|
|
"Publish", self.name, "published_by", str(name)) |
|
|
frappe.db.commit() |
|
|
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): |
|
|
def on_cancel(self): |
|
|
# Published document should not allow to cancel |
|
|
# Published document should not allow to cancel |
|
|
if self.publish_status == "Published": |
|
|
if self.publish_status == "Published": |
|
|