Fixed logic for reserved qty for subcontract and production and written a patch (#13396)
* Fixed logic for reserved qty for subcontract and production and written a patch * repost reserved qty for filtered bins
This commit is contained in:
parent
398eac3f4c
commit
651b612909
@ -498,3 +498,4 @@ erpnext.patches.v10_0.update_reserved_qty_for_purchase_order
|
|||||||
erpnext.patches.v10_0.update_hub_connector_domain
|
erpnext.patches.v10_0.update_hub_connector_domain
|
||||||
erpnext.patches.v10_0.set_student_party_type
|
erpnext.patches.v10_0.set_student_party_type
|
||||||
erpnext.patches.v10_0.update_project_in_sle
|
erpnext.patches.v10_0.update_project_in_sle
|
||||||
|
erpnext.patches.v10_0.fix_reserved_qty_for_sub_contract
|
29
erpnext/patches/v10_0/fix_reserved_qty_for_sub_contract.py
Normal file
29
erpnext/patches/v10_0/fix_reserved_qty_for_sub_contract.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
# Copyright (c) 2017, Frappe and Contributors
|
||||||
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
import frappe
|
||||||
|
from erpnext.stock.utils import get_bin
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
for d in frappe.db.sql("""
|
||||||
|
select distinct rm_item_code, reserve_warehouse
|
||||||
|
from `tabPurchase Order Item Supplied`
|
||||||
|
where docstatus=1 and reserve_warehouse is not null and reserve_warehouse != ''"""):
|
||||||
|
|
||||||
|
try:
|
||||||
|
bin_doc = get_bin(d[0], d[1])
|
||||||
|
bin_doc.update_reserved_qty_for_sub_contracting()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
for d in frappe.db.sql("""select distinct item_code, source_warehouse
|
||||||
|
from `tabProduction Order Item`
|
||||||
|
where docstatus=1 and transferred_qty > required_qty
|
||||||
|
and source_warehouse is not null and source_warehouse != ''""", as_list=1):
|
||||||
|
|
||||||
|
try:
|
||||||
|
bin_doc = get_bin(d[0], d[1])
|
||||||
|
bin_doc.update_reserved_qty_for_production()
|
||||||
|
except:
|
||||||
|
pass
|
@ -76,14 +76,16 @@ class Bin(Document):
|
|||||||
def update_reserved_qty_for_production(self):
|
def update_reserved_qty_for_production(self):
|
||||||
'''Update qty reserved for production from Production Item tables
|
'''Update qty reserved for production from Production Item tables
|
||||||
in open production orders'''
|
in open production orders'''
|
||||||
self.reserved_qty_for_production = frappe.db.sql('''select sum(required_qty - transferred_qty)
|
self.reserved_qty_for_production = frappe.db.sql('''
|
||||||
|
select sum(item.required_qty - item.transferred_qty)
|
||||||
from `tabProduction Order` pro, `tabProduction Order Item` item
|
from `tabProduction Order` pro, `tabProduction Order Item` item
|
||||||
where
|
where
|
||||||
item.item_code = %s
|
item.item_code = %s
|
||||||
and item.parent = pro.name
|
and item.parent = pro.name
|
||||||
and pro.docstatus = 1
|
and pro.docstatus = 1
|
||||||
and item.source_warehouse = %s
|
and item.source_warehouse = %s
|
||||||
and pro.status not in ("Stopped", "Completed")''', (self.item_code, self.warehouse))[0][0]
|
and pro.status not in ("Stopped", "Completed")
|
||||||
|
and item.required_qty > item.transferred_qty''', (self.item_code, self.warehouse))[0][0]
|
||||||
|
|
||||||
self.set_projected_qty()
|
self.set_projected_qty()
|
||||||
|
|
||||||
@ -123,7 +125,12 @@ class Bin(Document):
|
|||||||
and po.per_received < 100
|
and po.per_received < 100
|
||||||
""", (self.item_code))[0][0]
|
""", (self.item_code))[0][0]
|
||||||
|
|
||||||
self.db_set('reserved_qty_for_sub_contract', (reserved_qty_for_sub_contract - materials_transferred))
|
if reserved_qty_for_sub_contract > materials_transferred:
|
||||||
|
reserved_qty_for_sub_contract = reserved_qty_for_sub_contract - materials_transferred
|
||||||
|
else:
|
||||||
|
reserved_qty_for_sub_contract = 0
|
||||||
|
|
||||||
|
self.db_set('reserved_qty_for_sub_contract', reserved_qty_for_sub_contract)
|
||||||
self.set_projected_qty()
|
self.set_projected_qty()
|
||||||
self.db_set('projected_qty', self.projected_qty)
|
self.db_set('projected_qty', self.projected_qty)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user