[fix] catch link validation exception in POS profile and reload fees doctype

This commit is contained in:
Saurabh 2017-11-08 13:41:10 +05:30
parent 4c617d6496
commit d2cef208fe
2 changed files with 12 additions and 5 deletions

View File

@ -5,6 +5,8 @@ from __future__ import unicode_literals
import frappe
def execute():
frappe.reload_doc("schools", "doctype", "fees")
if "total_amount" not in frappe.db.get_table_columns("Fees"):
return

View File

@ -8,12 +8,17 @@ def execute():
doctype = 'POS Profile'
frappe.reload_doctype(doctype)
for pos in frappe.get_all(doctype):
for pos in frappe.get_all(doctype, filters={'disabled': 0}):
doc = frappe.get_doc(doctype, pos.name)
if not doc.user: continue
if not doc.user and doc.pos_profile_name: continue
doc.pos_profile_name = doc.user + ' - ' + doc.company
doc.save()
try:
doc.pos_profile_name = doc.user + ' - ' + doc.company
doc.flags.ignore_validate = True
doc.flags.ignore_mandatory = True
doc.save()
frappe.rename_doc(doctype, doc.name, doc.pos_profile_name, force=True)
frappe.rename_doc(doctype, doc.name, doc.pos_profile_name, force=True)
except frappe.LinkValidationError:
frappe.db.set_value("POS Profile", doc.name, 'disabled', 1)