mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-14 17:33:09 +00:00
test(purchase): fit the backported test to version-15-hotfix
Drop test_sales_return_validates_against_original: it came in with the new file rather than with the change being backported, covers a raw-SQL to query-builder conversion that only exists on develop, and imports erpnext.stock.doctype.delivery_note.mapper, a module this branch does not have. Base the remaining tests on FrappeTestCase, since ERPNextTestSuite does not exist here either.
This commit is contained in:
@@ -2,11 +2,10 @@
|
|||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe.tests.utils import FrappeTestCase
|
||||||
from erpnext.tests.utils import ERPNextTestSuite
|
|
||||||
|
|
||||||
|
|
||||||
class TestSalesAndPurchaseReturn(ERPNextTestSuite):
|
class TestSalesAndPurchaseReturn(FrappeTestCase):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _cancel_and_delete(doctype, name):
|
def _cancel_and_delete(doctype, name):
|
||||||
if not frappe.db.exists(doctype, name):
|
if not frappe.db.exists(doctype, name):
|
||||||
@@ -16,28 +15,6 @@ class TestSalesAndPurchaseReturn(ERPNextTestSuite):
|
|||||||
doc.cancel()
|
doc.cancel()
|
||||||
frappe.delete_doc(doctype, name, force=1)
|
frappe.delete_doc(doctype, name, force=1)
|
||||||
|
|
||||||
def test_sales_return_validates_against_original(self):
|
|
||||||
# Submitting a return Delivery Note runs validate_returned_items (Item / Packed Item lookups
|
|
||||||
# via frappe.get_all) and get_already_returned_items (qb GROUP BY of the returned qty) -- both
|
|
||||||
# converted from raw SQL here. Exercises them on both engines.
|
|
||||||
from erpnext.stock.doctype.delivery_note.mapper import make_sales_return
|
|
||||||
from erpnext.stock.doctype.delivery_note.test_delivery_note import create_delivery_note
|
|
||||||
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
|
|
||||||
|
|
||||||
se = make_stock_entry(item_code="_Test Item", target="_Test Warehouse - _TC", qty=20, basic_rate=100)
|
|
||||||
self.addCleanup(self._cancel_and_delete, "Stock Entry", se.name)
|
|
||||||
|
|
||||||
dn = create_delivery_note(qty=5)
|
|
||||||
self.addCleanup(self._cancel_and_delete, "Delivery Note", dn.name)
|
|
||||||
|
|
||||||
return_dn = make_sales_return(dn.name)
|
|
||||||
return_dn.insert()
|
|
||||||
return_dn.submit()
|
|
||||||
self.addCleanup(self._cancel_and_delete, "Delivery Note", return_dn.name)
|
|
||||||
|
|
||||||
self.assertEqual(return_dn.is_return, 1)
|
|
||||||
self.assertEqual(return_dn.items[0].qty, -5)
|
|
||||||
|
|
||||||
def test_purchase_invoice_zero_qty_return_is_rejected(self):
|
def test_purchase_invoice_zero_qty_return_is_rejected(self):
|
||||||
# A return with every item at qty 0 moves no stock and no value, so it must be
|
# A return with every item at qty 0 moves no stock and no value, so it must be
|
||||||
# rejected the same way a return with no items at all would be.
|
# rejected the same way a return with no items at all would be.
|
||||||
|
|||||||
Reference in New Issue
Block a user