test: auto create PR on SCR submit
diff --git a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py
index 4f4a650..4d7b157 100644
--- a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py
+++ b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py
@@ -586,8 +586,8 @@
item_row = {
"item_code": po_item.item_code,
"item_name": po_item.item_name,
- "qty": item.qty * conversion_factor,
- "rejected_qty": item.rejected_qty * conversion_factor,
+ "qty": flt(item.qty) * conversion_factor,
+ "rejected_qty": flt(item.rejected_qty) * conversion_factor,
"uom": po_item.uom,
"rate": po_item.rate,
"warehouse": item.warehouse,
diff --git a/erpnext/subcontracting/doctype/subcontracting_receipt/test_subcontracting_receipt.py b/erpnext/subcontracting/doctype/subcontracting_receipt/test_subcontracting_receipt.py
index f0e4e00..1d007fe 100644
--- a/erpnext/subcontracting/doctype/subcontracting_receipt/test_subcontracting_receipt.py
+++ b/erpnext/subcontracting/doctype/subcontracting_receipt/test_subcontracting_receipt.py
@@ -5,7 +5,7 @@
import copy
import frappe
-from frappe.tests.utils import FrappeTestCase
+from frappe.tests.utils import FrappeTestCase, change_settings
from frappe.utils import add_days, cint, cstr, flt, nowtime, today
import erpnext
@@ -953,6 +953,33 @@
scr.submit()
+ @change_settings("Buying Settings", {"auto_create_purchase_receipt": 1})
+ def test_auto_create_purchase_receipt(self):
+ fg_item = "Subcontracted Item SA1"
+ service_items = [
+ {
+ "warehouse": "_Test Warehouse - _TC",
+ "item_code": "Subcontracted Service Item 1",
+ "qty": 5,
+ "rate": 100,
+ "fg_item": fg_item,
+ "fg_item_qty": 5,
+ },
+ ]
+ sco = get_subcontracting_order(service_items=service_items)
+ rm_items = get_rm_items(sco.supplied_items)
+ itemwise_details = make_stock_in_entry(rm_items=rm_items)
+ make_stock_transfer_entry(
+ sco_no=sco.name,
+ rm_items=rm_items,
+ itemwise_details=copy.deepcopy(itemwise_details),
+ )
+ scr = make_subcontracting_receipt(sco.name)
+ scr.save()
+ scr.submit()
+
+ self.assertTrue(frappe.db.get_value("Purchase Receipt", {"subcontracting_receipt": scr.name}))
+
def make_return_subcontracting_receipt(**args):
args = frappe._dict(args)