brotherton-erpnext/erpnext/patches/v11_0/make_quality_inspection_template.py
Chillar Anand 915b34391c
chore: Clean up imports (#27302)
* chore: Added isort to pre-commit config

* chore: Sort imports with isort

* chore: Clean up imports with pycln

* chore: Sort imports with isort

* chore: Fix import issues

* chore: Clean up sider issues

* chore: Remove import errors from flake8 ignore list

* chore: Clean up lint issues
2021-09-02 16:44:59 +05:30

28 lines
1.1 KiB
Python

# Copyright (c) 2017, Frappe and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
frappe.reload_doc('stock', 'doctype', 'quality_inspection_template')
frappe.reload_doc('stock', 'doctype', 'item')
for data in frappe.get_all('Item Quality Inspection Parameter',
fields = ["distinct parent"], filters = {'parenttype': 'Item'}):
qc_doc = frappe.new_doc("Quality Inspection Template")
qc_doc.quality_inspection_template_name = 'QIT/%s' % data.parent
qc_doc.flags.ignore_mandatory = True
qc_doc.save(ignore_permissions=True)
frappe.db.set_value('Item', data.parent, "quality_inspection_template", qc_doc.name, update_modified=False)
frappe.db.sql(""" update `tabItem Quality Inspection Parameter`
set parentfield = 'item_quality_inspection_parameter', parenttype = 'Quality Inspection Template',
parent = %s where parenttype = 'Item' and parent = %s""", (qc_doc.name, data.parent))
# update field in item variant settings
frappe.db.sql(""" update `tabVariant Field` set field_name = 'quality_inspection_template'
where field_name = 'quality_parameters'""")