-
Notifications
You must be signed in to change notification settings - Fork 15
/
script_11.py
33 lines (23 loc) · 960 Bytes
/
script_11.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
28
29
30
31
32
33
import frappe
def set_all_item_field_value(**kwargs):
"""Set all items based on the value given and filters"""
# Filters
filters = {
'disabled': 0,
'name': ('like', '%{0}%'.format(kwargs['keyword']))
}
# Get all Item fields based from the filters
items = frappe.get_all('Item', filters=filters, fields=['name'])
# Counters
cur_index = 1
max_index = len(items)
print "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-="
print "Setting all Item {0} field to the value {1}.".format(kwargs['field'], kwargs['value'])
print "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-="
for item in items:
print "Processing item {0}/{1}...".format(cur_index, max_index)
frappe.db.set_value('Item', item.name, kwargs['field'], kwargs['value'])
cur_index = cur_index + 1
print "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-="
print "Done setting {0} items.".format(max_index)
print "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-="