Skip to content

Commit

Permalink
perf: Use cached doc instead of get_doc
Browse files Browse the repository at this point in the history
- Doc is only used to iterate over items(which wont change) and change rate/amount of rows
- These changes are inserted in db via `db_update`, so no harm
- Tested locally: refetching cached doc after db update, reflects fresh data.
  • Loading branch information
marination committed May 20, 2022
1 parent d035aa2 commit faa69c9
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def update_cost() -> None:
"""Updates Cost for all BOMs from bottom to top."""
bom_list = get_boms_in_bottom_up_order()
for bom in bom_list:
bom_doc = frappe.get_doc("BOM", bom)
bom_doc = frappe.get_cached_doc("BOM", bom)
bom_doc.calculate_cost(save_updates=True, update_hour_rate=True)
# bom_doc.update_exploded_items(save=True) #TODO: edit exploded items rate
bom_doc.db_update()
Expand Down

0 comments on commit faa69c9

Please sign in to comment.