forked from iRaySpace/erpnext-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.py
27 lines (18 loc) · 736 Bytes
/
script.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import frappe
def disable_existing_items(**kwargs):
"""Disable existing ERPNext items based on the 'not like/like' keyword given."""
items = frappe.get_all('Item', filters={'disabled': 0, 'name': (kwargs['condition'], '%{0}%'.format(kwargs['keyword']))}, fields=['name'])
print "---"
print "Disabling items..."
print "---"
# Indices for tracking items to be disabled
cur_index = 1
max_index = len(items)
for item in items:
# Logging the process
print "Processing item {0}/{1}.".format(cur_index, max_index)
frappe.db.set_value('Item', item.name, 'disabled', 1)
cur_index = cur_index + 1
print "---"
print "Finished disabling items..."
print "---"