Remove total_projected_qty (#12889)
This commit is contained in:
parent
62d6593fe7
commit
5a91989665
@ -65,7 +65,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -151,7 +150,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -237,7 +235,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -323,7 +320,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -409,7 +405,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -495,7 +490,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -581,7 +575,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -667,7 +660,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -753,7 +745,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -839,7 +830,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -925,7 +915,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -1011,7 +1000,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -1097,7 +1085,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -1183,7 +1170,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -1269,7 +1255,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -1355,7 +1340,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -1441,7 +1425,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -1527,7 +1510,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -1613,7 +1595,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -1699,7 +1680,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -1785,7 +1765,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -1871,7 +1850,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -1957,7 +1935,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -2043,7 +2020,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -2129,7 +2105,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -2215,7 +2190,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -2301,7 +2275,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -2387,7 +2360,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -2473,7 +2445,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -2559,7 +2530,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -2645,7 +2615,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -2731,7 +2700,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -2817,7 +2785,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -2903,7 +2870,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -2989,7 +2955,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -3075,7 +3040,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -3161,7 +3125,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -3247,7 +3210,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -3333,7 +3295,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -3419,7 +3380,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -3505,7 +3465,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -3591,7 +3550,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -3677,7 +3635,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -3763,7 +3720,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -3849,7 +3805,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -3935,7 +3890,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -4021,7 +3975,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -4107,7 +4060,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -4193,7 +4145,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -4279,7 +4230,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -4365,7 +4315,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -4451,7 +4400,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -4537,7 +4485,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -4623,7 +4570,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -4709,7 +4655,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -4795,7 +4740,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -4881,7 +4825,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -4967,7 +4910,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -5053,7 +4995,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -5139,7 +5080,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -5225,7 +5165,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -5311,7 +5250,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
@ -5397,7 +5335,6 @@
|
||||
"taxes": [],
|
||||
"thumbnail": null,
|
||||
"tolerance": 0.0,
|
||||
"total_projected_qty": 0.0,
|
||||
"uoms": [
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
|
@ -10,7 +10,6 @@ from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_per
|
||||
from erpnext.manufacturing.doctype.production_order.production_order \
|
||||
import make_stock_entry, ItemHasVariantError, stop_unstop
|
||||
from erpnext.stock.doctype.stock_entry import test_stock_entry
|
||||
from erpnext.stock.doctype.item.test_item import get_total_projected_qty
|
||||
from erpnext.stock.utils import get_bin
|
||||
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
|
||||
|
||||
@ -81,7 +80,7 @@ class TestProductionOrder(unittest.TestCase):
|
||||
prod_order.set_production_order_operations()
|
||||
prod_order.insert()
|
||||
prod_order.submit()
|
||||
|
||||
|
||||
d = prod_order.operations[0]
|
||||
d.completed_qty = flt(d.completed_qty)
|
||||
|
||||
@ -89,7 +88,7 @@ class TestProductionOrder(unittest.TestCase):
|
||||
time_sheet_doc = frappe.get_doc('Timesheet', name)
|
||||
self.assertEqual(prod_order.company, time_sheet_doc.company)
|
||||
time_sheet_doc.submit()
|
||||
|
||||
|
||||
|
||||
self.assertEqual(prod_order.name, time_sheet_doc.production_order)
|
||||
self.assertEqual((prod_order.qty - d.completed_qty),
|
||||
@ -108,7 +107,7 @@ class TestProductionOrder(unittest.TestCase):
|
||||
|
||||
self.assertEqual(prod_order.operations[0].actual_operation_time, 60)
|
||||
self.assertEqual(prod_order.operations[0].actual_operating_cost, 6000)
|
||||
|
||||
|
||||
time_sheet_doc1 = make_timesheet(prod_order.name, prod_order.company)
|
||||
self.assertEqual(len(time_sheet_doc1.get('time_logs')), 0)
|
||||
|
||||
@ -176,28 +175,6 @@ class TestProductionOrder(unittest.TestCase):
|
||||
self.assertEqual(self.bin1_at_start.projected_qty,
|
||||
cint(bin1_on_cancel.projected_qty))
|
||||
|
||||
def test_projected_qty_for_production_and_sales_order(self):
|
||||
before_production_order = get_bin(self.item, self.warehouse)
|
||||
before_production_order.update_reserved_qty_for_production()
|
||||
|
||||
self.pro_order = make_prod_order_test_record(item="_Test FG Item", qty=2,
|
||||
source_warehouse=self.warehouse)
|
||||
|
||||
after_production_order = get_bin(self.item, self.warehouse)
|
||||
|
||||
sales_order = make_sales_order(item = self.item, qty = 2)
|
||||
after_sales_order = get_bin(self.item, self.warehouse)
|
||||
|
||||
self.assertEqual(cint(before_production_order.reserved_qty_for_production) + 2,
|
||||
cint(after_sales_order.reserved_qty_for_production))
|
||||
self.assertEqual(cint(before_production_order.projected_qty),
|
||||
cint(after_sales_order.projected_qty) + 2)
|
||||
|
||||
total_projected_qty = get_total_projected_qty(self.item)
|
||||
|
||||
item_doc = frappe.get_doc('Item', self.item)
|
||||
self.assertEqual(total_projected_qty, item_doc.total_projected_qty)
|
||||
|
||||
def test_reserved_qty_for_production_on_stock_entry(self):
|
||||
test_stock_entry.make_stock_entry(item_code="_Test Item",
|
||||
target= self.warehouse, qty=100, basic_rate=100)
|
||||
@ -230,7 +207,7 @@ class TestProductionOrder(unittest.TestCase):
|
||||
cint(bin1_on_start_production.reserved_qty_for_production))
|
||||
self.assertEqual(cint(bin1_on_end_production.projected_qty),
|
||||
cint(bin1_on_end_production.projected_qty))
|
||||
|
||||
|
||||
def test_reserved_qty_for_stopped_production(self):
|
||||
test_stock_entry.make_stock_entry(item_code="_Test Item",
|
||||
target= self.warehouse, qty=100, basic_rate=100)
|
||||
@ -238,18 +215,18 @@ class TestProductionOrder(unittest.TestCase):
|
||||
target= self.warehouse, qty=100, basic_rate=100)
|
||||
|
||||
# 0 0 0
|
||||
|
||||
|
||||
self.test_reserved_qty_for_production_submit()
|
||||
|
||||
|
||||
#2 0 -2
|
||||
|
||||
s = frappe.get_doc(make_stock_entry(self.pro_order.name,
|
||||
"Material Transfer for Manufacture", 1))
|
||||
|
||||
s.submit()
|
||||
|
||||
|
||||
#1 -1 0
|
||||
|
||||
|
||||
bin1_on_start_production = get_bin(self.item, self.warehouse)
|
||||
|
||||
# reserved_qty_for_producion updated
|
||||
@ -259,10 +236,10 @@ class TestProductionOrder(unittest.TestCase):
|
||||
# projected qty will now be 2 less (becuase of item movement)
|
||||
self.assertEqual(cint(self.bin1_at_start.projected_qty),
|
||||
cint(bin1_on_start_production.projected_qty) + 2)
|
||||
|
||||
|
||||
# STOP
|
||||
stop_unstop(self.pro_order.name, "Stopped")
|
||||
|
||||
|
||||
bin1_on_stop_production = get_bin(self.item, self.warehouse)
|
||||
|
||||
# no change in reserved / projected
|
||||
|
@ -7,22 +7,10 @@ from erpnext.stock.doctype.bin.bin import update_item_projected_qty
|
||||
|
||||
def execute():
|
||||
repost_bin_qty()
|
||||
repost_item_projected_qty()
|
||||
|
||||
def repost_bin_qty():
|
||||
for bin in frappe.db.sql(""" select name from `tabBin`
|
||||
for bin in frappe.db.sql(""" select name from `tabBin`
|
||||
where (actual_qty + ordered_qty + indented_qty + planned_qty- reserved_qty - reserved_qty_for_production) != projected_qty """, as_dict=1):
|
||||
bin_doc = frappe.get_doc('Bin', bin.name)
|
||||
bin_doc.set_projected_qty()
|
||||
bin_doc.db_set("projected_qty", bin_doc.projected_qty, update_modified = False)
|
||||
|
||||
def repost_item_projected_qty():
|
||||
for data in frappe.db.sql(""" select
|
||||
`tabBin`.item_code as item_code,
|
||||
sum(`tabBin`.projected_qty) as projected_qty,
|
||||
`tabItem`.total_projected_qty as total_projected_qty
|
||||
from
|
||||
`tabBin`, `tabItem`
|
||||
where `tabBin`.item_code = `tabItem`.name
|
||||
group by `tabBin`.item_code having projected_qty <> total_projected_qty """, as_dict=1):
|
||||
update_item_projected_qty(data.item_code)
|
||||
|
@ -5,7 +5,6 @@ import frappe
|
||||
from frappe.utils import flt, add_days
|
||||
import frappe.permissions
|
||||
import unittest
|
||||
from erpnext.stock.doctype.item.test_item import get_total_projected_qty
|
||||
from erpnext.selling.doctype.sales_order.sales_order \
|
||||
import make_material_request, make_delivery_note, make_sales_invoice, WarehouseRequired
|
||||
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
|
||||
@ -155,17 +154,9 @@ class TestSalesOrder(unittest.TestCase):
|
||||
dn = create_dn_against_so(so.name, 15)
|
||||
self.assertEqual(get_reserved_qty(), existing_reserved_qty)
|
||||
|
||||
total_projected_qty = get_total_projected_qty('_Test Item')
|
||||
item_doc_before_cancel = frappe.get_doc('Item', '_Test Item')
|
||||
self.assertEqual(total_projected_qty, item_doc_before_cancel.total_projected_qty)
|
||||
|
||||
dn.cancel()
|
||||
self.assertEqual(get_reserved_qty(), existing_reserved_qty + 10)
|
||||
|
||||
total_projected_qty = get_total_projected_qty('_Test Item')
|
||||
item_doc_after_cancel = frappe.get_doc('Item', '_Test Item')
|
||||
self.assertEqual(total_projected_qty, item_doc_after_cancel.total_projected_qty)
|
||||
|
||||
def test_reserved_qty_for_over_delivery_via_sales_invoice(self):
|
||||
make_stock_entry(target="_Test Warehouse - _TC", qty=10, rate=100)
|
||||
|
||||
@ -183,10 +174,6 @@ class TestSalesOrder(unittest.TestCase):
|
||||
si.insert()
|
||||
si.submit()
|
||||
|
||||
total_projected_qty = get_total_projected_qty('_Test Item')
|
||||
item_doc = frappe.get_doc('Item', '_Test Item')
|
||||
self.assertEqual(total_projected_qty, item_doc.total_projected_qty)
|
||||
|
||||
self.assertEqual(get_reserved_qty(), existing_reserved_qty)
|
||||
|
||||
so.load_from_db()
|
||||
@ -195,9 +182,6 @@ class TestSalesOrder(unittest.TestCase):
|
||||
|
||||
si.cancel()
|
||||
self.assertEqual(get_reserved_qty(), existing_reserved_qty + 10)
|
||||
total_projected_qty = get_total_projected_qty('_Test Item')
|
||||
item_doc = frappe.get_doc('Item', '_Test Item')
|
||||
self.assertEqual(total_projected_qty, item_doc.total_projected_qty)
|
||||
|
||||
so.load_from_db()
|
||||
self.assertEqual(so.get("items")[0].delivered_qty, 0)
|
||||
@ -229,10 +213,6 @@ class TestSalesOrder(unittest.TestCase):
|
||||
self.assertEqual(get_reserved_qty("_Test Item"), existing_reserved_qty_item1)
|
||||
self.assertEqual(get_reserved_qty("_Test Item Home Desktop 100"), existing_reserved_qty_item2)
|
||||
|
||||
total_projected_qty = get_total_projected_qty('_Test Item')
|
||||
item_doc = frappe.get_doc('Item', '_Test Item')
|
||||
self.assertEqual(total_projected_qty, item_doc.total_projected_qty)
|
||||
|
||||
# unclose so
|
||||
so.load_from_db()
|
||||
so.update_status('Draft')
|
||||
@ -269,10 +249,6 @@ class TestSalesOrder(unittest.TestCase):
|
||||
|
||||
dn = create_dn_against_so(so.name, 15)
|
||||
|
||||
total_projected_qty = get_total_projected_qty('_Test Item')
|
||||
item_doc = frappe.get_doc('Item', '_Test Item')
|
||||
self.assertEqual(total_projected_qty, item_doc.total_projected_qty)
|
||||
|
||||
self.assertEqual(get_reserved_qty("_Test Item"), existing_reserved_qty_item1)
|
||||
self.assertEqual(get_reserved_qty("_Test Item Home Desktop 100"),
|
||||
existing_reserved_qty_item2)
|
||||
@ -495,13 +471,6 @@ class TestSalesOrder(unittest.TestCase):
|
||||
|
||||
self.assertEquals(abs(flt(reserved_qty)), existing_reserved_qty_for_dn_item)
|
||||
|
||||
def test_total_projected_qty_against_sales_order(self):
|
||||
so = make_sales_order(item = '_Test Item')
|
||||
total_projected_qty = get_total_projected_qty('_Test Item')
|
||||
|
||||
item_doc = frappe.get_doc('Item', '_Test Item')
|
||||
self.assertEqual(total_projected_qty, item_doc.total_projected_qty)
|
||||
|
||||
def test_reserved_qty_for_closing_so(self):
|
||||
bin = frappe.get_all("Bin", filters={"item_code": "_Test Item", "warehouse": "_Test Warehouse - _TC"},
|
||||
fields=["reserved_qty"])
|
||||
@ -567,12 +536,12 @@ class TestSalesOrder(unittest.TestCase):
|
||||
"item_list": [{
|
||||
"item_code": "_Test FG Item",
|
||||
"qty": 10,
|
||||
"rate":100
|
||||
"rate":100
|
||||
},
|
||||
{
|
||||
"item_code": "_Test FG Item",
|
||||
"qty": 20,
|
||||
"rate":200
|
||||
"rate":200
|
||||
}]
|
||||
})
|
||||
|
||||
@ -589,7 +558,7 @@ class TestSalesOrder(unittest.TestCase):
|
||||
})
|
||||
so_item_name[item.get("sales_order_item")]= item.get("pending_qty")
|
||||
make_production_orders(json.dumps({"items":po_items}), so.name, so.company)
|
||||
|
||||
|
||||
# Check if Production Orders were raised
|
||||
for item in so_item_name:
|
||||
po_qty = frappe.db.sql("select sum(qty) from `tabProduction Order` where sales_order=%s and sales_order_item=%s", (so.name, item))
|
||||
|
@ -11,7 +11,6 @@ def get_notification_config():
|
||||
"Warranty Claim": {"status": "Open"},
|
||||
"Task": {"status": ("in", ("Open", "Overdue"))},
|
||||
"Project": {"status": "Open"},
|
||||
"Item": {"total_projected_qty": ("<", 0)},
|
||||
"Lead": {"status": "Open"},
|
||||
"Contact": {"status": "Open"},
|
||||
"Opportunity": {"status": "Open"},
|
||||
|
@ -15,9 +15,6 @@ class Bin(Document):
|
||||
self.validate_mandatory()
|
||||
self.set_projected_qty()
|
||||
|
||||
def on_update(self):
|
||||
update_item_projected_qty(self.item_code)
|
||||
|
||||
def validate_mandatory(self):
|
||||
qf = ['actual_qty', 'reserved_qty', 'ordered_qty', 'indented_qty']
|
||||
for f in qf:
|
||||
@ -94,11 +91,5 @@ class Bin(Document):
|
||||
self.db_set('projected_qty', self.projected_qty)
|
||||
|
||||
|
||||
def update_item_projected_qty(item_code):
|
||||
'''Set total_projected_qty in Item as sum of projected qty in all warehouses'''
|
||||
frappe.db.sql('''update tabItem set
|
||||
total_projected_qty = ifnull((select sum(projected_qty) from tabBin where item_code=%s), 0)
|
||||
where name=%s''', (item_code, item_code))
|
||||
|
||||
def on_doctype_update():
|
||||
frappe.db.add_index("Bin", ["item_code", "warehouse"])
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
frappe.listview_settings['Item'] = {
|
||||
add_fields: ["item_name", "stock_uom", "item_group", "image", "variant_of",
|
||||
"has_variants", "end_of_life", "disabled", "total_projected_qty"],
|
||||
"has_variants", "end_of_life", "disabled"],
|
||||
filters: [["disabled", "=", "0"]],
|
||||
|
||||
get_indicator: function(doc) {
|
||||
@ -8,8 +8,6 @@ frappe.listview_settings['Item'] = {
|
||||
return [__("Disabled"), "grey", "disabled,=,Yes"];
|
||||
} else if (doc.end_of_life && doc.end_of_life < frappe.datetime.get_today()) {
|
||||
return [__("Expired"), "grey", "end_of_life,<,Today"];
|
||||
} else if(doc.total_projected_qty < 0) {
|
||||
return [__("Shortage"), "red", "total_projected_qty,<,0"];
|
||||
} else if (doc.has_variants) {
|
||||
return [__("Template"), "orange", "has_variants,=,Yes"];
|
||||
} else if (doc.variant_of) {
|
||||
|
@ -129,7 +129,7 @@ class TestItem(unittest.TestCase):
|
||||
|
||||
def test_copy_fields_from_template_to_variants(self):
|
||||
frappe.delete_doc_if_exists("Item", "_Test Variant Item-XL", force=1)
|
||||
|
||||
|
||||
fields = [{'field_name': 'item_group'}, {'field_name': 'is_stock_item'}]
|
||||
allow_fields = [d.get('field_name') for d in fields]
|
||||
set_item_variant_settings(fields)
|
||||
@ -293,12 +293,6 @@ def make_item_variant():
|
||||
variant.item_name = "_Test Variant Item-S"
|
||||
variant.save()
|
||||
|
||||
def get_total_projected_qty(item):
|
||||
total_qty = frappe.db.sql(""" select sum(projected_qty) as projected_qty from tabBin
|
||||
where item_code = %(item)s""", {'item': item}, as_dict=1)
|
||||
|
||||
return total_qty[0].projected_qty if total_qty else 0.0
|
||||
|
||||
test_records = frappe.get_test_records('Item')
|
||||
|
||||
def create_item(item_code, is_stock_item=None):
|
||||
|
Loading…
x
Reference in New Issue
Block a user