fix: purchase return without item code not working (#39014)
This commit is contained in:
parent
3b4b2275de
commit
f983e09f92
@ -1985,6 +1985,26 @@ class TestPurchaseInvoice(FrappeTestCase, StockTestMixin):
|
|||||||
|
|
||||||
self.assertEqual(pi.items[0].cost_center, "_Test Cost Center Buying - _TC")
|
self.assertEqual(pi.items[0].cost_center, "_Test Cost Center Buying - _TC")
|
||||||
|
|
||||||
|
def test_debit_note_without_item(self):
|
||||||
|
pi = make_purchase_invoice(item_name="_Test Item", qty=10, do_not_submit=True)
|
||||||
|
pi.items[0].item_code = ""
|
||||||
|
pi.save()
|
||||||
|
|
||||||
|
self.assertFalse(pi.items[0].item_code)
|
||||||
|
pi.submit()
|
||||||
|
|
||||||
|
return_pi = make_purchase_invoice(
|
||||||
|
item_name="_Test Item",
|
||||||
|
is_return=1,
|
||||||
|
return_against=pi.name,
|
||||||
|
qty=-10,
|
||||||
|
do_not_save=True,
|
||||||
|
)
|
||||||
|
return_pi.items[0].item_code = ""
|
||||||
|
return_pi.save()
|
||||||
|
return_pi.submit()
|
||||||
|
self.assertEqual(return_pi.docstatus, 1)
|
||||||
|
|
||||||
|
|
||||||
def set_advance_flag(company, flag, default_account):
|
def set_advance_flag(company, flag, default_account):
|
||||||
frappe.db.set_value(
|
frappe.db.set_value(
|
||||||
@ -2121,6 +2141,7 @@ def make_purchase_invoice(**args):
|
|||||||
"items",
|
"items",
|
||||||
{
|
{
|
||||||
"item_code": args.item or args.item_code or "_Test Item",
|
"item_code": args.item or args.item_code or "_Test Item",
|
||||||
|
"item_name": args.item_name,
|
||||||
"warehouse": args.warehouse or "_Test Warehouse - _TC",
|
"warehouse": args.warehouse or "_Test Warehouse - _TC",
|
||||||
"qty": args.qty or 5,
|
"qty": args.qty or 5,
|
||||||
"received_qty": args.received_qty or 0,
|
"received_qty": args.received_qty or 0,
|
||||||
|
@ -562,6 +562,7 @@ def make_return_doc(
|
|||||||
if default_warehouse_for_sales_return:
|
if default_warehouse_for_sales_return:
|
||||||
target_doc.warehouse = default_warehouse_for_sales_return
|
target_doc.warehouse = default_warehouse_for_sales_return
|
||||||
|
|
||||||
|
if source_doc.item_code:
|
||||||
item_details = frappe.get_cached_value(
|
item_details = frappe.get_cached_value(
|
||||||
"Item", source_doc.item_code, ["has_batch_no", "has_serial_no"], as_dict=1
|
"Item", source_doc.item_code, ["has_batch_no", "has_serial_no"], as_dict=1
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user