remove old stock entry method/rewrite test case

This commit is contained in:
pawan 2018-02-12 21:15:46 +05:30
parent 1b8c13b175
commit 471a018e67
2 changed files with 6 additions and 24 deletions

View File

@ -396,25 +396,6 @@ def make_purchase_invoice(source_name, target_doc=None):
return doc
@frappe.whitelist()
def make_stock_entry(purchase_order, item_code):
purchase_order = frappe.get_doc("Purchase Order", purchase_order)
stock_entry = frappe.new_doc("Stock Entry")
stock_entry.purpose = "Subcontract"
stock_entry.purchase_order = purchase_order.name
stock_entry.supplier = purchase_order.supplier
stock_entry.supplier_name = purchase_order.supplier_name
stock_entry.supplier_address = purchase_order.supplier_address
stock_entry.address_display = purchase_order.address_display
stock_entry.company = purchase_order.company
stock_entry.from_bom = 1
po_item = [d for d in purchase_order.items if d.item_code == item_code][0]
stock_entry.fg_completed_qty = po_item.qty
stock_entry.bom_no = po_item.bom
stock_entry.get_items()
return stock_entry.as_dict()
@frappe.whitelist()
def make_rm_stock_entry(purchase_order, rm_items):

View File

@ -6,8 +6,9 @@ import unittest
import frappe
import frappe.defaults
from frappe.utils import flt, add_days, nowdate
from erpnext.buying.doctype.purchase_order.purchase_order import (make_purchase_receipt, make_purchase_invoice, make_stock_entry as make_subcontract_transfer_entry)
from erpnext.buying.doctype.purchase_order.purchase_order import (make_purchase_receipt, make_purchase_invoice, make_rm_stock_entry as make_subcontract_transfer_entry)
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry
import json
class TestPurchaseOrder(unittest.TestCase):
def test_make_purchase_receipt(self):
@ -202,11 +203,11 @@ class TestPurchaseOrder(unittest.TestCase):
self.assertEquals(bin2.projected_qty, bin1.projected_qty - 10)
# Create stock transfer
se = frappe.get_doc(make_subcontract_transfer_entry(po.name, "_Test FG Item"))
rm_item = [{"item_code":"_Test FG Item","rm_item_code":"_Test Item","item_name":"_Test Item",
"qty":6,"warehouse":"_Test Warehouse - _TC","rate":100,"amount":600,"stock_uom":"Nos"}]
rm_item_string = json.dumps(rm_item)
se = frappe.get_doc(make_subcontract_transfer_entry(po.name, rm_item_string))
se.to_warehouse = "_Test Warehouse 1 - _TC"
for d in se.get("items"):
if d.item_code == "_Test Item":
d.qty = 6
se.save()
se.submit()