* perf: only validate if voucher is journal entry
* perf: optimize merge GLE
- Order fields such that comparison will fail faster
- Break out of loops if not matched
* perf: don't try to match SLE if count mismatch
* refactor: simplify initialize_previous_data
* perf: use cache for fetching valuation_method
These are set only once fields
* refactor: simplify get_future_stock_vouchers
* refactor: simplify get_voucherwise_gl_entries
* perf: fetch only required fields for GL comparison
`select *` fetches all fields, output of this function is only used for
comparing.
* perf: reorder conditions in PL cost center check
* perf: reduce query while validating new gle
* perf: use cache for validating warehouse props
These properties don't change often, no need to query everytime.
* perf: use cached stock settings to validate SLE
* docs: update misleading docstring
Co-authored-by: Marica <maricadsouza221197@gmail.com>
(cherry picked from commit 9152715f90)
Co-authored-by: Ankush <ankush@iwebnotes.com>
This commit is contained in:
@@ -224,7 +224,7 @@ def get_avg_purchase_rate(serial_nos):
|
||||
|
||||
def get_valuation_method(item_code):
|
||||
"""get valuation method from item or default"""
|
||||
val_method = frappe.db.get_value('Item', item_code, 'valuation_method')
|
||||
val_method = frappe.db.get_value('Item', item_code, 'valuation_method', cache=True)
|
||||
if not val_method:
|
||||
val_method = frappe.db.get_value("Stock Settings", None, "valuation_method") or "FIFO"
|
||||
return val_method
|
||||
@@ -275,17 +275,17 @@ def get_valid_serial_nos(sr_nos, qty=0, item_code=''):
|
||||
return valid_serial_nos
|
||||
|
||||
def validate_warehouse_company(warehouse, company):
|
||||
warehouse_company = frappe.db.get_value("Warehouse", warehouse, "company")
|
||||
warehouse_company = frappe.db.get_value("Warehouse", warehouse, "company", cache=True)
|
||||
if warehouse_company and warehouse_company != company:
|
||||
frappe.throw(_("Warehouse {0} does not belong to company {1}").format(warehouse, company),
|
||||
InvalidWarehouseCompany)
|
||||
|
||||
def is_group_warehouse(warehouse):
|
||||
if frappe.db.get_value("Warehouse", warehouse, "is_group"):
|
||||
if frappe.db.get_value("Warehouse", warehouse, "is_group", cache=True):
|
||||
frappe.throw(_("Group node warehouse is not allowed to select for transactions"))
|
||||
|
||||
def validate_disabled_warehouse(warehouse):
|
||||
if frappe.db.get_value("Warehouse", warehouse, "disabled"):
|
||||
if frappe.db.get_value("Warehouse", warehouse, "disabled", cache=True):
|
||||
frappe.throw(_("Disabled Warehouse {0} cannot be used for this transaction.").format(get_link_to_form('Warehouse', warehouse)))
|
||||
|
||||
def update_included_uom_in_report(columns, result, include_uom, conversion_factors):
|
||||
|
||||
Reference in New Issue
Block a user