fix: Failing search util import and patch

- Use simple function import instead of global variable to check if field is valid to index
- Commit after every 20 items in patch to  create web items from items
This commit is contained in:
marination
2021-09-02 14:30:37 +05:30
parent c5efb6dc35
commit 10a450cb2c
3 changed files with 16 additions and 12 deletions

View File

@@ -15,12 +15,12 @@ def execute():
item_table_fields = frappe.db.sql("desc `tabItem`", as_dict=1)
item_table_fields = [d.get('Field') for d in item_table_fields]
# prepare fields to query from Item, check if the field exists in Item master
# prepare fields to query from Item, check if the web field exists in Item master
web_query_fields = []
for field in web_fields_to_map:
if field in item_table_fields:
web_query_fields.append(field)
item_fields.append(field)
for web_field in web_fields_to_map:
if web_field in item_table_fields:
web_query_fields.append(web_field)
item_fields.append(web_field)
# check if the filter fields exist in Item master
or_filters = {}
@@ -39,6 +39,7 @@ def execute():
or_filters=or_filters
)
count = 0
for item in items:
if frappe.db.exists("Website Item", {"item_code": item.item_code}):
continue
@@ -62,4 +63,8 @@ def execute():
where
parenttype = 'Item'
and parent = '{item_code}'
""")
""")
count += 1
if count % 20 == 0: # commit after every 20 items
frappe.db.commit()