2017-11-02 10:34:16 +00:00
|
|
|
# Copyright (c) 2017, Frappe and Contributors
|
|
|
|
# License: GNU General Public License v3. See license.txt
|
|
|
|
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
import frappe
|
|
|
|
|
|
|
|
def execute():
|
|
|
|
doctype = 'POS Profile'
|
|
|
|
frappe.reload_doctype(doctype)
|
|
|
|
|
2017-11-08 08:11:10 +00:00
|
|
|
for pos in frappe.get_all(doctype, filters={'disabled': 0}):
|
2017-11-02 10:34:16 +00:00
|
|
|
doc = frappe.get_doc(doctype, pos.name)
|
|
|
|
|
2018-12-14 08:49:14 +00:00
|
|
|
if not doc.user: continue
|
2017-11-02 10:34:16 +00:00
|
|
|
|
2017-11-08 08:11:10 +00:00
|
|
|
try:
|
2018-12-14 08:49:14 +00:00
|
|
|
pos_profile_name = doc.user + ' - ' + doc.company
|
2017-11-08 08:11:10 +00:00
|
|
|
doc.flags.ignore_validate = True
|
|
|
|
doc.flags.ignore_mandatory = True
|
|
|
|
doc.save()
|
2017-11-02 10:34:16 +00:00
|
|
|
|
2018-12-14 08:49:14 +00:00
|
|
|
frappe.rename_doc(doctype, doc.name, pos_profile_name, force=True)
|
2017-11-08 08:11:10 +00:00
|
|
|
except frappe.LinkValidationError:
|
|
|
|
frappe.db.set_value("POS Profile", doc.name, 'disabled', 1)
|