Added href links for nextdoc on cancelling the Sales order, makes it easier to navigate

This commit is contained in:
Kanchan Chauhan 2018-11-22 15:15:06 +05:30
parent 8c7373dfd0
commit 962397e6f4

View File

@ -5,7 +5,7 @@ from __future__ import unicode_literals
import frappe import frappe
import json import json
import frappe.utils import frappe.utils
from frappe.utils import cstr, flt, getdate, comma_and, cint, nowdate, add_days from frappe.utils import cstr, flt, getdate, cint, nowdate, add_days, get_link_to_form
from frappe import _ from frappe import _
from six import string_types from six import string_types
from frappe.model.utils import get_fetch_values from frappe.model.utils import get_fetch_values
@ -221,8 +221,9 @@ class SalesOrder(SellingController):
where t1.name = t2.parent and t2.against_sales_order = %s and t1.docstatus = 1""", self.name) where t1.name = t2.parent and t2.against_sales_order = %s and t1.docstatus = 1""", self.name)
if submit_dn: if submit_dn:
submit_dn = [get_link_to_form("Delivery Note", dn) for dn in submit_dn]
frappe.throw(_("Delivery Notes {0} must be cancelled before cancelling this Sales Order") frappe.throw(_("Delivery Notes {0} must be cancelled before cancelling this Sales Order")
.format(comma_and(submit_dn))) .format(", ".join(submit_dn)))
# Checks Sales Invoice # Checks Sales Invoice
submit_rv = frappe.db.sql_list("""select t1.name submit_rv = frappe.db.sql_list("""select t1.name
@ -231,8 +232,9 @@ class SalesOrder(SellingController):
self.name) self.name)
if submit_rv: if submit_rv:
submit_rv = [get_link_to_form("Sales Invoice", si) for si in submit_rv]
frappe.throw(_("Sales Invoice {0} must be cancelled before cancelling this Sales Order") frappe.throw(_("Sales Invoice {0} must be cancelled before cancelling this Sales Order")
.format(comma_and(submit_rv))) .format(", ".join(submit_rv)))
#check maintenance schedule #check maintenance schedule
submit_ms = frappe.db.sql_list(""" submit_ms = frappe.db.sql_list("""
@ -241,8 +243,9 @@ class SalesOrder(SellingController):
where t2.parent=t1.name and t2.sales_order = %s and t1.docstatus = 1""", self.name) where t2.parent=t1.name and t2.sales_order = %s and t1.docstatus = 1""", self.name)
if submit_ms: if submit_ms:
submit_ms = [get_link_to_form("Maintenance Schedule", ms) for ms in submit_ms]
frappe.throw(_("Maintenance Schedule {0} must be cancelled before cancelling this Sales Order") frappe.throw(_("Maintenance Schedule {0} must be cancelled before cancelling this Sales Order")
.format(comma_and(submit_ms))) .format(", ".join(submit_ms)))
# check maintenance visit # check maintenance visit
submit_mv = frappe.db.sql_list(""" submit_mv = frappe.db.sql_list("""
@ -251,8 +254,9 @@ class SalesOrder(SellingController):
where t2.parent=t1.name and t2.prevdoc_docname = %s and t1.docstatus = 1""",self.name) where t2.parent=t1.name and t2.prevdoc_docname = %s and t1.docstatus = 1""",self.name)
if submit_mv: if submit_mv:
submit_mv = [get_link_to_form("Maintenance Visit", mv) for mv in submit_mv]
frappe.throw(_("Maintenance Visit {0} must be cancelled before cancelling this Sales Order") frappe.throw(_("Maintenance Visit {0} must be cancelled before cancelling this Sales Order")
.format(comma_and(submit_mv))) .format(", ".join(submit_mv)))
# check work order # check work order
pro_order = frappe.db.sql_list(""" pro_order = frappe.db.sql_list("""
@ -261,8 +265,9 @@ class SalesOrder(SellingController):
where sales_order = %s and docstatus = 1""", self.name) where sales_order = %s and docstatus = 1""", self.name)
if pro_order: if pro_order:
pro_order = [get_link_to_form("Work Order", po) for po in pro_order]
frappe.throw(_("Work Order {0} must be cancelled before cancelling this Sales Order") frappe.throw(_("Work Order {0} must be cancelled before cancelling this Sales Order")
.format(comma_and(pro_order))) .format(", ".join(pro_order)))
def check_modified_date(self): def check_modified_date(self):
mod_db = frappe.db.get_value("Sales Order", self.name, "modified") mod_db = frappe.db.get_value("Sales Order", self.name, "modified")