[Fix] Purchase receipt test cases

This commit is contained in:
Rohit Waghchaure 2018-06-12 13:54:40 +05:30
parent a6b346f827
commit b6381c66d8
3 changed files with 6 additions and 4 deletions

View File

@ -339,6 +339,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"default": "Material Transferred for Subcontract",
"fieldname": "backflush_raw_materials_of_subcontract_based_on",
"fieldtype": "Select",
"hidden": 0,
@ -377,7 +378,7 @@
"issingle": 1,
"istable": 0,
"max_attachments": 0,
"modified": "2018-05-30 16:28:46.899823",
"modified": "2018-06-12 03:41:41.739193",
"modified_by": "Administrator",
"module": "Buying",
"name": "Buying Settings",

View File

@ -33,7 +33,7 @@ class StockController(AccountsController):
items, warehouses = self.get_items_and_warehouses()
update_gl_entries_after(self.posting_date, self.posting_time, warehouses, items,
warehouse_account)
elif self.doctype in ['Purchase Receipt', 'Purchase Invoice']:
elif self.doctype in ['Purchase Receipt', 'Purchase Invoice'] and self.docstatus == 1:
gl_entries = []
gl_entries = self.get_asset_gl_entry(gl_entries)
make_gl_entries(gl_entries, from_repost=from_repost)

View File

@ -92,6 +92,7 @@ class TestPurchaseReceipt(unittest.TestCase):
def test_subcontracting(self):
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry
frappe.db.set_value("Buying Settings", None, "backflush_raw_materials_of_subcontract_based_on", "BOM")
make_stock_entry(item_code="_Test Item", target="_Test Warehouse 1 - _TC", qty=100, basic_rate=100)
make_stock_entry(item_code="_Test Item Home Desktop 100", target="_Test Warehouse 1 - _TC",
qty=100, basic_rate=100)
@ -314,9 +315,10 @@ class TestPurchaseReceipt(unittest.TestCase):
asset_category = doc.name
asset_item = make_item(asset_item, {'is_stock_item':0,
item_data = make_item(asset_item, {'is_stock_item':0,
'stock_uom': 'Box', 'is_fixed_asset': 1, 'has_serial_no': 1,
'asset_category': asset_category, 'serial_no_series': 'ABC.###'})
asset_item = item_data.item_code
if not frappe.db.exists('Location', 'Test Location'):
frappe.get_doc({
@ -334,7 +336,6 @@ class TestPurchaseReceipt(unittest.TestCase):
serial_nos = frappe.get_all('Serial No', {'asset': asset}, 'name') or []
self.assertEquals(len(serial_nos), 0)
frappe.db.sql("delete from `tabLocation")
frappe.db.sql("delete from `tabAsset Category`")
frappe.db.sql("delete from `tabAsset`")
def get_gl_entries(voucher_type, voucher_no):