Skip to content

Commit

Permalink
fix: alternative item not working for subcontract
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitwaghchaure committed Jun 22, 2020
1 parent 92f97b6 commit 1716995
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions erpnext/stock/doctype/stock_entry/stock_entry.py
Expand Up @@ -571,9 +571,7 @@ def validate_purchase_order(self):
{"parent": self.purchase_order, "item_code": se_item.subcontracted_item},
"bom")

allow_alternative_item = frappe.get_value("BOM", bom_no, "allow_alternative_item")

if allow_alternative_item:
if se_item.allow_alternative_item:
original_item_code = frappe.get_value("Item Alternative", {"alternative_item_code": item_code}, "item_code")

required_qty = sum([flt(d.required_qty) for d in purchase_order.supplied_items \
Expand Down Expand Up @@ -736,7 +734,7 @@ def _validate_work_order(pro_doc):

def get_item_details(self, args=None, for_update=False):
item = frappe.db.sql("""select i.name, i.stock_uom, i.description, i.image, i.item_name, i.item_group,
i.has_batch_no, i.sample_quantity, i.has_serial_no,
i.has_batch_no, i.sample_quantity, i.has_serial_no, i.allow_alternative_item,
id.expense_account, id.buying_cost_center
from `tabItem` i LEFT JOIN `tabItem Default` id ON i.name=id.parent and id.company=%s
where i.name=%s
Expand Down Expand Up @@ -770,6 +768,9 @@ def get_item_details(self, args=None, for_update=False):
'sample_quantity' : item.sample_quantity
})

if self.purpose == 'Send to Subcontractor':
ret["allow_alternative_item"] = item.allow_alternative_item

# update uom
if args.get("uom") and for_update:
ret.update(get_uom_details(args.get('item_code'), args.get('uom'), args.get('qty')))
Expand Down

0 comments on commit 1716995

Please sign in to comment.