mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-08 15:42:52 +00:00
refactor: use helper method to fetch item details
This commit is contained in:
@@ -233,17 +233,8 @@ class TransactionBase(StatusUpdater):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@frappe.whitelist()
|
def fetch_item_details(self, item: dict) -> dict:
|
||||||
def item_code_trigger(self, item):
|
return get_item_details(
|
||||||
# 'item' - child table row from UI. Possibly has user-set values
|
|
||||||
# Convert it to Frappe doc for better attribute access
|
|
||||||
item = frappe.get_doc(item)
|
|
||||||
|
|
||||||
# Server side 'item' doc. Update this to reflect in UI
|
|
||||||
item_obj = self.get("items", {"name": item.name})[0]
|
|
||||||
|
|
||||||
# 'item_details' has values fetched by system for backend
|
|
||||||
item_details = get_item_details(
|
|
||||||
frappe._dict(
|
frappe._dict(
|
||||||
{
|
{
|
||||||
"item_code": item.get("item_code"),
|
"item_code": item.get("item_code"),
|
||||||
@@ -295,6 +286,18 @@ class TransactionBase(StatusUpdater):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def item_code_trigger(self, item):
|
||||||
|
# 'item' - child table row from UI. Possibly has user-set values
|
||||||
|
# Convert it to Frappe doc for better attribute access
|
||||||
|
item = frappe.get_doc(item)
|
||||||
|
|
||||||
|
# Server side 'item' doc. Update this to reflect in UI
|
||||||
|
item_obj = self.get("items", {"name": item.name})[0]
|
||||||
|
|
||||||
|
# 'item_details' has values fetched by system for backend
|
||||||
|
item_details = self.fetch_item_details(item)
|
||||||
|
|
||||||
self.set_fetched_values(item_obj, item_details)
|
self.set_fetched_values(item_obj, item_details)
|
||||||
self.set_item_rate_and_discounts(item, item_obj, item_details)
|
self.set_item_rate_and_discounts(item, item_obj, item_details)
|
||||||
|
|
||||||
@@ -385,7 +388,8 @@ class TransactionBase(StatusUpdater):
|
|||||||
_matches = [
|
_matches = [
|
||||||
x
|
x
|
||||||
for x in existing_free_items
|
for x in existing_free_items
|
||||||
if x.item_code == free_item.get('item_code') and x.pricing_rules == free_item.get('pricing_rules')
|
if x.item_code == free_item.get("item_code")
|
||||||
|
and x.pricing_rules == free_item.get("pricing_rules")
|
||||||
]
|
]
|
||||||
if _matches:
|
if _matches:
|
||||||
row_to_modify = _matches[0]
|
row_to_modify = _matches[0]
|
||||||
|
|||||||
Reference in New Issue
Block a user