[fix] catch link validation exception in POS profile and reload fees doctype
diff --git a/erpnext/patches/v9_0/copy_old_fees_field_data.py b/erpnext/patches/v9_0/copy_old_fees_field_data.py
index fb11ee5..4243c5b 100644
--- a/erpnext/patches/v9_0/copy_old_fees_field_data.py
+++ b/erpnext/patches/v9_0/copy_old_fees_field_data.py
@@ -5,6 +5,8 @@
import frappe
def execute():
+ frappe.reload_doc("schools", "doctype", "fees")
+
if "total_amount" not in frappe.db.get_table_columns("Fees"):
return
diff --git a/erpnext/patches/v9_0/set_pos_profile_name.py b/erpnext/patches/v9_0/set_pos_profile_name.py
index bc6e50e..3ae3774 100644
--- a/erpnext/patches/v9_0/set_pos_profile_name.py
+++ b/erpnext/patches/v9_0/set_pos_profile_name.py
@@ -8,12 +8,17 @@
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)
\ No newline at end of file
+ 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)