mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-09 16:21:19 +00:00
[production] update planned and produced ty
This commit is contained in:
@@ -18,6 +18,9 @@ class DocType:
|
||||
self.doclist = doclist
|
||||
|
||||
def validate(self):
|
||||
if self.doc.docstatus == 0:
|
||||
self.doc.status = "Draft"
|
||||
|
||||
import utilities
|
||||
utilities.validate_status(self.doc.status, ["Draft", "Submitted", "Stopped",
|
||||
"In Process", "Completed", "Cancelled"])
|
||||
@@ -149,12 +152,6 @@ def get_item_details(item):
|
||||
@webnotes.whitelist()
|
||||
def make_stock_entry(production_order_id, purpose):
|
||||
production_order = webnotes.bean("Production Order", production_order_id)
|
||||
|
||||
# validate already existing
|
||||
ste = webnotes.conn.get_value("Stock Entry", {
|
||||
"production_order":production_order_id,
|
||||
"purpose": purpose
|
||||
}, "name")
|
||||
|
||||
stock_entry = webnotes.new_bean("Stock Entry")
|
||||
stock_entry.doc.purpose = purpose
|
||||
@@ -171,4 +168,4 @@ def make_stock_entry(production_order_id, purpose):
|
||||
stock_entry.doc.to_warehouse = production_order.doc.fg_warehouse
|
||||
|
||||
stock_entry.run_method("get_items")
|
||||
return [d.fields for d in stock_entry.doclist]
|
||||
return [d.fields for d in stock_entry.doclist]
|
||||
@@ -0,0 +1,75 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import unittest
|
||||
import webnotes
|
||||
from stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory
|
||||
from manufacturing.doctype.production_order.production_order import make_stock_entry
|
||||
|
||||
|
||||
class TestProductionOrder(unittest.TestCase):
|
||||
def test_planned_qty(self):
|
||||
set_perpetual_inventory(0)
|
||||
webnotes.conn.sql("delete from `tabStock Ledger Entry`")
|
||||
webnotes.conn.sql("""delete from `tabBin`""")
|
||||
webnotes.conn.sql("""delete from `tabGL Entry`""")
|
||||
|
||||
pro_bean = webnotes.bean(copy = test_records[0])
|
||||
pro_bean.insert()
|
||||
pro_bean.submit()
|
||||
|
||||
from stock.doctype.stock_entry.test_stock_entry import test_records as se_test_records
|
||||
mr1 = webnotes.bean(copy = se_test_records[0])
|
||||
mr1.insert()
|
||||
mr1.submit()
|
||||
|
||||
mr2 = webnotes.bean(copy = se_test_records[0])
|
||||
mr2.doclist[1].item_code = "_Test Item Home Desktop 100"
|
||||
mr2.insert()
|
||||
mr2.submit()
|
||||
|
||||
stock_entry = make_stock_entry(pro_bean.doc.name, "Manufacture/Repack")
|
||||
stock_entry = webnotes.bean(stock_entry)
|
||||
|
||||
stock_entry.doc.fg_completed_qty = 4
|
||||
stock_entry.run_method("get_items")
|
||||
stock_entry.submit()
|
||||
|
||||
self.assertEqual(webnotes.conn.get_value("Production Order", pro_bean.doc.name,
|
||||
"produced_qty"), 4)
|
||||
self.assertEqual(webnotes.conn.get_value("Bin", {"item_code": "_Test FG Item",
|
||||
"warehouse": "_Test Warehouse 1 - _TC"}, "planned_qty"), 6)
|
||||
|
||||
return pro_bean.doc.name
|
||||
|
||||
def test_over_production(self):
|
||||
from stock.doctype.stock_entry.stock_entry import StockOverProductionError
|
||||
pro_order = self.test_planned_qty()
|
||||
|
||||
stock_entry = make_stock_entry(pro_order, "Manufacture/Repack")
|
||||
stock_entry = webnotes.bean(stock_entry)
|
||||
|
||||
stock_entry.doc.fg_completed_qty = 15
|
||||
stock_entry.run_method("get_items")
|
||||
stock_entry.insert()
|
||||
|
||||
self.assertRaises(StockOverProductionError, stock_entry.submit)
|
||||
|
||||
|
||||
|
||||
test_records = [
|
||||
[
|
||||
{
|
||||
"bom_no": "BOM/_Test FG Item/001",
|
||||
"company": "_Test Company",
|
||||
"doctype": "Production Order",
|
||||
"production_item": "_Test FG Item",
|
||||
"qty": 10.0,
|
||||
"fg_warehouse": "_Test Warehouse 1 - _TC",
|
||||
"wip_warehouse": "_Test Warehouse - _TC",
|
||||
"stock_uom": "Nos"
|
||||
}
|
||||
]
|
||||
]
|
||||
Reference in New Issue
Block a user