Fixes counting of in stock parent assemblies and formatting of csv
This commit is contained in:
parent
1c91dc4589
commit
5597f6a830
@ -363,9 +363,17 @@ class ProductionPlanningTool(Document):
|
|||||||
bom_wise_item_details[d.item_code] = d
|
bom_wise_item_details[d.item_code] = d
|
||||||
if include_sublevel:
|
if include_sublevel:
|
||||||
if (d.default_material_request_type == "Purchase" and d.is_sub_contracted \
|
if (d.default_material_request_type == "Purchase" and d.is_sub_contracted \
|
||||||
and supply_subs) or (d.default_material_request_type == "Manufacture"):
|
and supply_subs) or (d.default_material_request_type == "Manufacture"):
|
||||||
self.get_subitems(bom_wise_item_details,d.default_bom, \
|
my_qty = 0
|
||||||
d.qty, include_sublevel, only_raw, supply_subs)
|
if self.create_material_requests_for_all_required_qty:
|
||||||
|
my_qty = d.qty
|
||||||
|
elif (bom_wise_item_details[d.item_code].qty - d.qty) < self.get_item_projected_qty(d.item_code):
|
||||||
|
my_qty = bom_wise_item_details[d.item_code].qty - self.get_item_projected_qty(d.item_code)
|
||||||
|
else:
|
||||||
|
my_qty = d.qty
|
||||||
|
if my_qty > 0:
|
||||||
|
self.get_subitems(bom_wise_item_details,d.default_bom, \
|
||||||
|
my_qty, include_sublevel, only_raw, supply_subs)
|
||||||
return bom_wise_item_details
|
return bom_wise_item_details
|
||||||
|
|
||||||
def make_items_dict(self, item_list):
|
def make_items_dict(self, item_list):
|
||||||
@ -387,6 +395,8 @@ class ProductionPlanningTool(Document):
|
|||||||
flt(w.ordered_qty), flt(w.actual_qty)])
|
flt(w.ordered_qty), flt(w.actual_qty)])
|
||||||
if item_qty:
|
if item_qty:
|
||||||
item_list.append(['', '', '', '', 'Total', i_qty, o_qty, a_qty])
|
item_list.append(['', '', '', '', 'Total', i_qty, o_qty, a_qty])
|
||||||
|
else:
|
||||||
|
item_list.append(['', '', '', '', 'Total', 0, 0, 0])
|
||||||
|
|
||||||
return item_list
|
return item_list
|
||||||
|
|
||||||
@ -449,6 +459,13 @@ class ProductionPlanningTool(Document):
|
|||||||
|
|
||||||
return items_to_be_requested
|
return items_to_be_requested
|
||||||
|
|
||||||
|
def get_item_projected_qty(self,item):
|
||||||
|
item_projected_qty = frappe.db.sql("""select ifnull(sum(projected_qty),0) as qty from `tabBin`
|
||||||
|
where item_code = %(item_code)s and warehouse=%(warehouse)s""", \
|
||||||
|
{"item_code":item, "warehouse": self.purchase_request_for_warehouse},as_dict=1)
|
||||||
|
#frappe.msgprint(item_projected_qty)
|
||||||
|
return item_projected_qty[0].qty
|
||||||
|
|
||||||
def get_projected_qty(self):
|
def get_projected_qty(self):
|
||||||
items = self.item_dict.keys()
|
items = self.item_dict.keys()
|
||||||
item_projected_qty = frappe.db.sql("""select item_code, sum(projected_qty)
|
item_projected_qty = frappe.db.sql("""select item_code, sum(projected_qty)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user