fix: use checkbox instead of select field
diff --git a/erpnext/buying/doctype/buying_settings/buying_settings.json b/erpnext/buying/doctype/buying_settings/buying_settings.json
index bb2476d..eba9f24 100644
--- a/erpnext/buying/doctype/buying_settings/buying_settings.json
+++ b/erpnext/buying/doctype/buying_settings/buying_settings.json
@@ -30,9 +30,9 @@
"column_break_11",
"over_transfer_allowance",
"section_break_xcug",
- "action_on_purchase_order_submission",
+ "auto_create_subcontracting_order",
"column_break_izrr",
- "action_on_subcontracting_receipt_submission"
+ "auto_create_purchase_receipt"
],
"fields": [
{
@@ -182,20 +182,22 @@
"fieldtype": "Section Break"
},
{
- "fieldname": "action_on_purchase_order_submission",
- "fieldtype": "Select",
- "label": "Action on Purchase Order Submission",
- "options": "\nCreate Subcontracting Order\nCreate and Submit Subcontracting Order"
- },
- {
"fieldname": "column_break_izrr",
"fieldtype": "Column Break"
},
{
- "fieldname": "action_on_subcontracting_receipt_submission",
- "fieldtype": "Select",
- "label": "Action on Subcontracting Receipt Submission",
- "options": "\nCreate Purchase Receipt\nCreate and Submit Purchase Receipt"
+ "default": "0",
+ "description": "Subcontracting Order (Draft) will be auto-created on submission of Purchase Order.",
+ "fieldname": "auto_create_subcontracting_order",
+ "fieldtype": "Check",
+ "label": "Auto Create Subcontracting Order"
+ },
+ {
+ "default": "0",
+ "description": "Purchase Receipt (Draft) will be auto-created on submission of Subcontracting Receipt.",
+ "fieldname": "auto_create_purchase_receipt",
+ "fieldtype": "Check",
+ "label": "Auto Create Purchase Receipt"
}
],
"icon": "fa fa-cog",
@@ -203,7 +205,7 @@
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
- "modified": "2023-11-22 17:46:26.474708",
+ "modified": "2023-11-28 13:01:18.403492",
"modified_by": "Administrator",
"module": "Buying",
"name": "Buying Settings",
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py
index 7f764e9..f000185 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.py
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.py
@@ -488,13 +488,8 @@
def auto_create_subcontracting_order(self):
if self.is_subcontracted and not self.is_old_subcontracting_flow:
- if action := frappe.db.get_single_value(
- "Buying Settings", "action_on_purchase_order_submission"
- ):
- if action == "Create Subcontracting Order":
- make_subcontracting_order(self.name, save=True, notify=True)
- elif action == "Create and Submit Subcontracting Order":
- make_subcontracting_order(self.name, submit=True, notify=True)
+ if frappe.db.get_single_value("Buying Settings", "auto_create_subcontracting_order"):
+ make_subcontracting_order(self.name, save=True, notify=True)
def item_last_purchase_rate(name, conversion_rate, item_code, conversion_factor=1.0):
diff --git a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py
index a38acb2..3a8ce01 100644
--- a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py
+++ b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py
@@ -531,13 +531,8 @@
)
def auto_create_purchase_receipt(self):
- if action := frappe.db.get_single_value(
- "Buying Settings", "action_on_subcontracting_receipt_submission"
- ):
- if action == "Create Purchase Receipt":
- make_purchase_receipt(self, save=True, notify=True)
- elif action == "Create and Submit Purchase Receipt":
- make_purchase_receipt(self, submit=True, notify=True)
+ if frappe.db.get_single_value("Buying Settings", "auto_create_purchase_receipt"):
+ make_purchase_receipt(self, save=True, notify=True)
@frappe.whitelist()