refactor: pass typed arguments to get_item_details methods (#44230)

* refactor: pass proper types to get_item_details methods

* chore: excempt previous commit from git blame
This commit is contained in:
David Arnold
2024-11-20 02:31:03 +01:00
committed by GitHub
parent 4ec23b5525
commit 9673bf85ec
16 changed files with 286 additions and 244 deletions

View File

@@ -54,7 +54,7 @@ class TestQuotation(IntegrationTestCase):
def test_gross_profit(self):
from erpnext.stock.doctype.item.test_item import make_item
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
from erpnext.stock.get_item_details import insert_item_price
from erpnext.stock.get_item_details import ItemDetailsCtx, insert_item_price
item_doc = make_item("_Test Item for Gross Profit", {"is_stock_item": 1})
item_code = item_doc.name
@@ -63,7 +63,7 @@ class TestQuotation(IntegrationTestCase):
selling_price_list = frappe.get_all("Price List", filters={"selling": 1}, limit=1)[0].name
frappe.db.set_single_value("Stock Settings", "auto_insert_price_list_rate_if_missing", 1)
insert_item_price(
frappe._dict(
ItemDetailsCtx(
{
"item_code": item_code,
"price_list": selling_price_list,

View File

@@ -35,7 +35,12 @@ from erpnext.stock.doctype.stock_reservation_entry.stock_reservation_entry impor
get_sre_reserved_qty_details_for_voucher,
has_reserved_stock,
)
from erpnext.stock.get_item_details import get_bin_details, get_default_bom, get_price_list_rate
from erpnext.stock.get_item_details import (
ItemDetailsCtx,
get_bin_details,
get_default_bom,
get_price_list_rate,
)
from erpnext.stock.stock_balance import get_reserved_qty, update_bin_qty
form_grid_templates = {"items": "templates/form_grid/item_grid.html"}
@@ -849,8 +854,8 @@ def make_material_request(source_name, target_doc=None):
target.item_code, target.warehouse, source_parent.company, True
).get("actual_qty", 0)
args = target.as_dict().copy()
args.update(
ctx = ItemDetailsCtx(target.as_dict().copy())
ctx.update(
{
"company": source_parent.get("company"),
"price_list": frappe.db.get_single_value("Buying Settings", "buying_price_list"),
@@ -860,7 +865,7 @@ def make_material_request(source_name, target_doc=None):
)
target.rate = flt(
get_price_list_rate(args, item_doc=frappe.get_cached_doc("Item", target.item_code)).get(
get_price_list_rate(ctx, item_doc=frappe.get_cached_doc("Item", target.item_code)).get(
"price_list_rate"
)
)