Merge pull request #14453 from rohitwaghchaure/item_alternative_fixes_for_backflush
[Fix] Alternative item, transferred qty issue for backflush method
This commit is contained in:
commit
7cd59a2089
@ -554,12 +554,15 @@ class WorkOrder(Document):
|
||||
consumed_qty = frappe.db.sql('''select sum(qty)
|
||||
from `tabStock Entry` entry, `tabStock Entry Detail` detail
|
||||
where
|
||||
entry.work_order = %s
|
||||
entry.work_order = %(name)s
|
||||
and (entry.purpose = "Material Consumption for Manufacture"
|
||||
or entry.purpose = "Manufacture")
|
||||
and entry.docstatus = 1
|
||||
and detail.parent = entry.name
|
||||
and detail.item_code = %s''', (self.name, d.item_code))[0][0]
|
||||
and (detail.item_code = %(item)s or detail.original_item = %(item)s)''', {
|
||||
'name': self.name,
|
||||
'item': d.item_code
|
||||
})[0][0]
|
||||
|
||||
d.db_set('consumed_qty', flt(consumed_qty), update_modified = False)
|
||||
|
||||
|
@ -832,7 +832,7 @@ class StockEntry(StockController):
|
||||
def get_transfered_raw_materials(self):
|
||||
transferred_materials = frappe.db.sql("""
|
||||
select
|
||||
item_name, item_code, sum(qty) as qty, sed.t_warehouse as warehouse,
|
||||
item_name, original_item, item_code, sum(qty) as qty, sed.t_warehouse as warehouse,
|
||||
description, stock_uom, expense_account, cost_center
|
||||
from `tabStock Entry` se,`tabStock Entry Detail` sed
|
||||
where
|
||||
@ -866,8 +866,9 @@ class StockEntry(StockController):
|
||||
|
||||
for item in transferred_materials:
|
||||
qty= item.qty
|
||||
item_code = item.original_item or item.item_code
|
||||
req_items = frappe.get_all('Work Order Item',
|
||||
filters={'parent': self.work_order, 'item_code': item.item_code},
|
||||
filters={'parent': self.work_order, 'item_code': item_code},
|
||||
fields=["required_qty", "consumed_qty"]
|
||||
)
|
||||
req_qty = flt(req_items[0].required_qty)
|
||||
@ -912,6 +913,7 @@ class StockEntry(StockController):
|
||||
"stock_uom": item.stock_uom,
|
||||
"expense_account": item.expense_account,
|
||||
"cost_center": item.buying_cost_center,
|
||||
"original_item": item.original_item
|
||||
}
|
||||
})
|
||||
|
||||
@ -986,6 +988,7 @@ class StockEntry(StockController):
|
||||
se_child.cost_center = item_dict[d].get("cost_center") or cost_center
|
||||
se_child.allow_alternative_item = item_dict[d].get("allow_alternative_item", 0)
|
||||
se_child.subcontracted_item = item_dict[d].get("main_item_code")
|
||||
se_child.original_item = item_dict[d].get("original_item")
|
||||
|
||||
if item_dict[d].get("idx"):
|
||||
se_child.idx = item_dict[d].get("idx")
|
||||
|
Loading…
x
Reference in New Issue
Block a user