Skip to content

Commit

Permalink
fix: Iterate over list instead of map's output and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
marination committed Jan 31, 2023
1 parent fa9b327 commit ece6358
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions erpnext/selling/doctype/quotation/quotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def set_customer_name(self):

def validate_alternative_items(self):
items_with_alternatives = filter(lambda item: not item.is_alternative, self.get("items"))
items_with_alternatives = map(lambda item: item.item_code, items_with_alternatives)
items_with_alternatives = list(map(lambda item: item.item_code, items_with_alternatives))

alternative_items = filter(lambda item: item.is_alternative, self.get("items"))
for row in alternative_items:
Expand All @@ -114,7 +114,6 @@ def validate_alternative_items(self):
title=_("Invalid Item"),
)


def update_opportunity(self, status):
for opportunity in set(d.prevdoc_docname for d in self.get("items")):
if opportunity:
Expand Down Expand Up @@ -227,7 +226,8 @@ def _make_sales_order(source_name, target_doc=None, ignore_permissions=False):
)

alternative_map = {
x.get("original_item") : x.get("alternative_item") for x in frappe.flags.get("args", {}).get("mapping", [])
x.get("original_item"): x.get("alternative_item")
for x in frappe.flags.get("args", {}).get("mapping", [])
}

def set_missing_values(source, target):
Expand All @@ -253,7 +253,7 @@ def update_item(obj, target, source_parent):
target.blanket_order = obj.blanket_order
target.blanket_order_rate = obj.blanket_order_rate

def can_map_row(item) -> bool:
def can_map_row(item) -> bool:
"""
Row mapping from Quotation to Sales order:
1. Simple row: Map if adequate qty
Expand All @@ -275,7 +275,6 @@ def can_map_row(item) -> bool:
is_selected = alternative_map.get(item.item_code) is None
return is_selected and has_qty


doclist = get_mapped_doc(
"Quotation",
source_name,
Expand Down

0 comments on commit ece6358

Please sign in to comment.