refactor!: change "is_subcontracted" field type from "Select" to "Check"
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
index 5f6e610..ee29d2a 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
@@ -141,7 +141,7 @@
})
}, __("Get Items From"));
}
- this.frm.toggle_reqd("supplier_warehouse", this.frm.doc.is_subcontracted==="Yes");
+ this.frm.toggle_reqd("supplier_warehouse", this.frm.doc.is_subcontracted);
if (doc.docstatus == 1 && !doc.inter_company_invoice_reference) {
frappe.model.with_doc("Supplier", me.frm.doc.supplier, function() {
@@ -571,10 +571,10 @@
},
is_subcontracted: function(frm) {
- if (frm.doc.is_subcontracted === "Yes") {
+ if (frm.doc.is_subcontracted) {
erpnext.buying.get_default_bom(frm);
}
- frm.toggle_reqd("supplier_warehouse", frm.doc.is_subcontracted==="Yes");
+ frm.toggle_reqd("supplier_warehouse", frm.doc.is_subcontracted);
},
update_stock: function(frm) {
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
index bd01164..9f87c5a 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
@@ -543,11 +543,10 @@
"fieldtype": "Column Break"
},
{
- "default": "No",
+ "default": "0",
"fieldname": "is_subcontracted",
- "fieldtype": "Select",
- "label": "Raw Materials Supplied",
- "options": "No\nYes",
+ "fieldtype": "Check",
+ "label": "Is Subcontracted",
"print_hide": 1
},
{
@@ -1366,7 +1365,7 @@
"width": "50px"
},
{
- "depends_on": "eval:doc.update_stock && doc.is_subcontracted==\"Yes\"",
+ "depends_on": "eval:doc.update_stock && doc.is_subcontracted",
"fieldname": "supplier_warehouse",
"fieldtype": "Link",
"label": "Supplier Warehouse",
diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
index 843f66d..73390dd 100644
--- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
@@ -901,7 +901,7 @@
)
pi = make_purchase_invoice(
- item_code="_Test FG Item", qty=10, rate=500, update_stock=1, is_subcontracted="Yes"
+ item_code="_Test FG Item", qty=10, rate=500, update_stock=1, is_subcontracted=1
)
self.assertEqual(len(pi.get("supplied_items")), 2)
@@ -1611,7 +1611,7 @@
pi.conversion_rate = args.conversion_rate or 1
pi.is_return = args.is_return
pi.return_against = args.return_against
- pi.is_subcontracted = args.is_subcontracted or "No"
+ pi.is_subcontracted = args.is_subcontracted or 0
pi.supplier_warehouse = args.supplier_warehouse or "_Test Warehouse 1 - _TC"
pi.cost_center = args.parent_cost_center
@@ -1674,7 +1674,7 @@
pi.is_return = args.is_return
pi.is_return = args.is_return
pi.credit_to = args.return_against or "Creditors - _TC"
- pi.is_subcontracted = args.is_subcontracted or "No"
+ pi.is_subcontracted = args.is_subcontracted or 0
if args.supplier_warehouse:
pi.supplier_warehouse = "_Test Warehouse 1 - _TC"
diff --git a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json
index f9b2efd..6651195 100644
--- a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json
+++ b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json
@@ -623,7 +623,7 @@
},
{
"default": "0",
- "depends_on": "eval:parent.is_subcontracted == 'Yes'",
+ "depends_on": "eval:parent.is_subcontracted",
"fieldname": "include_exploded_items",
"fieldtype": "Check",
"label": "Include Exploded Items",
diff --git a/erpnext/accounts/report/tax_detail/test_tax_detail.json b/erpnext/accounts/report/tax_detail/test_tax_detail.json
index 3a4b175..e490316 100644
--- a/erpnext/accounts/report/tax_detail/test_tax_detail.json
+++ b/erpnext/accounts/report/tax_detail/test_tax_detail.json
@@ -302,7 +302,7 @@
"is_opening": "No",
"is_paid": 0,
"is_return": 0,
- "is_subcontracted": "No",
+ "is_subcontracted": 0,
"items": [
{
"allow_zero_valuation_rate": 0,
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.js b/erpnext/buying/doctype/purchase_order/purchase_order.js
index 1f6de1a..2cad1fb 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.js
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.js
@@ -185,7 +185,7 @@
if (doc.status != "On Hold") {
if(flt(doc.per_received) < 100 && allow_receipt) {
cur_frm.add_custom_button(__('Purchase Receipt'), this.make_purchase_receipt, __('Create'));
- if(doc.is_subcontracted==="Yes" && me.has_unsupplied_items()) {
+ if(doc.is_subcontracted && me.has_unsupplied_items()) {
cur_frm.add_custom_button(__('Material to Supplier'),
function() { me.make_stock_entry(); }, __("Transfer"));
}
@@ -653,7 +653,7 @@
frappe.provide("erpnext.buying");
frappe.ui.form.on("Purchase Order", "is_subcontracted", function(frm) {
- if (frm.doc.is_subcontracted === "Yes") {
+ if (frm.doc.is_subcontracted) {
erpnext.buying.get_default_bom(frm);
}
});
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.json b/erpnext/buying/doctype/purchase_order/purchase_order.json
index 307b576..5e4bc60 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.json
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.json
@@ -448,15 +448,18 @@
"print_hide": 1
},
{
- "default": "No",
+ "fieldname": "col_break_warehouse",
+ "fieldtype": "Column Break"
+ },
+ {
+ "default": "0",
"fieldname": "is_subcontracted",
- "fieldtype": "Select",
- "label": "Supply Raw Materials",
- "options": "No\nYes",
+ "fieldtype": "Check",
+ "label": "Is Subcontracted",
"print_hide": 1
},
{
- "depends_on": "eval:doc.is_subcontracted==\"Yes\"",
+ "depends_on": "eval:doc.is_subcontracted",
"fieldname": "supplier_warehouse",
"fieldtype": "Link",
"label": "Supplier Warehouse",
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py
index e8b8b87..1945079 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.py
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.py
@@ -307,7 +307,7 @@
self.set_status(update=True, status=status)
self.update_requested_qty()
self.update_ordered_qty()
- if self.is_subcontracted == "Yes":
+ if self.is_subcontracted:
self.update_reserved_qty_for_subcontract()
self.notify_update()
@@ -324,7 +324,7 @@
self.update_ordered_qty()
self.validate_budget()
- if self.is_subcontracted == "Yes":
+ if self.is_subcontracted:
self.update_reserved_qty_for_subcontract()
frappe.get_doc("Authorization Control").validate_approving_authority(
@@ -344,7 +344,7 @@
if self.has_drop_ship_item():
self.update_delivered_qty_in_sales_order()
- if self.is_subcontracted == "Yes":
+ if self.is_subcontracted:
self.update_reserved_qty_for_subcontract()
self.check_on_hold_or_closed_status()
diff --git a/erpnext/buying/doctype/purchase_order/test_purchase_order.py b/erpnext/buying/doctype/purchase_order/test_purchase_order.py
index e4fb970..1a7f2dd 100644
--- a/erpnext/buying/doctype/purchase_order/test_purchase_order.py
+++ b/erpnext/buying/doctype/purchase_order/test_purchase_order.py
@@ -390,7 +390,7 @@
frappe.get_doc("Item Tax Template", "Test Update Items Template - _TC").delete()
def test_update_child_uom_conv_factor_change(self):
- po = create_purchase_order(item_code="_Test FG Item", is_subcontracted="Yes")
+ po = create_purchase_order(item_code="_Test FG Item", is_subcontracted=1)
total_reqd_qty = sum([d.get("required_qty") for d in po.as_dict().get("supplied_items")])
trans_item = json.dumps(
@@ -573,7 +573,7 @@
automatically_fetch_payment_terms(enable=0)
def test_subcontracting(self):
- po = create_purchase_order(item_code="_Test FG Item", is_subcontracted="Yes")
+ po = create_purchase_order(item_code="_Test FG Item", is_subcontracted=1)
self.assertEqual(len(po.get("supplied_items")), 2)
def test_warehouse_company_validation(self):
@@ -617,7 +617,7 @@
"doctype": "Purchase Order",
"company": "_Test Company",
"supplier": "_Test Supplier",
- "is_subcontracted": "No",
+ "is_subcontracted": 0,
"schedule_date": add_days(nowdate(), 1),
"currency": frappe.get_cached_value("Company", "_Test Company", "default_currency"),
"conversion_factor": 1,
@@ -764,7 +764,7 @@
)
# Submit PO
- po = create_purchase_order(item_code="_Test FG Item", is_subcontracted="Yes")
+ po = create_purchase_order(item_code="_Test FG Item", is_subcontracted=1)
bin2 = frappe.db.get_value(
"Bin",
@@ -919,7 +919,7 @@
po = create_purchase_order(
item_code=item_code,
qty=1,
- is_subcontracted="Yes",
+ is_subcontracted=1,
supplier_warehouse="_Test Warehouse 1 - _TC",
include_exploded_items=1,
)
@@ -936,7 +936,7 @@
po1 = create_purchase_order(
item_code=item_code,
qty=1,
- is_subcontracted="Yes",
+ is_subcontracted=1,
supplier_warehouse="_Test Warehouse 1 - _TC",
include_exploded_items=0,
)
@@ -957,7 +957,7 @@
po = create_purchase_order(
item_code=item_code,
qty=order_qty,
- is_subcontracted="Yes",
+ is_subcontracted=1,
supplier_warehouse="_Test Warehouse 1 - _TC",
)
@@ -1050,7 +1050,7 @@
po = create_purchase_order(
item_code=item_code,
qty=order_qty,
- is_subcontracted="Yes",
+ is_subcontracted=1,
supplier_warehouse="_Test Warehouse 1 - _TC",
do_not_save=True,
)
@@ -1283,7 +1283,7 @@
po.schedule_date = add_days(nowdate(), 1)
po.company = args.company or "_Test Company"
po.supplier = args.supplier or "_Test Supplier"
- po.is_subcontracted = args.is_subcontracted or "No"
+ po.is_subcontracted = args.is_subcontracted or 0
po.currency = args.currency or frappe.get_cached_value("Company", po.company, "default_currency")
po.conversion_factor = args.conversion_factor or 1
po.supplier_warehouse = args.supplier_warehouse or None
@@ -1309,7 +1309,7 @@
if not args.do_not_save:
po.insert()
if not args.do_not_submit:
- if po.is_subcontracted == "Yes":
+ if po.is_subcontracted:
supp_items = po.get("supplied_items")
for d in supp_items:
if not d.reserve_warehouse:
diff --git a/erpnext/buying/doctype/purchase_order/test_records.json b/erpnext/buying/doctype/purchase_order/test_records.json
index 74b8f1b..896050c 100644
--- a/erpnext/buying/doctype/purchase_order/test_records.json
+++ b/erpnext/buying/doctype/purchase_order/test_records.json
@@ -8,7 +8,7 @@
"doctype": "Purchase Order",
"base_grand_total": 5000.0,
"grand_total": 5000.0,
- "is_subcontracted": "Yes",
+ "is_subcontracted": 1,
"naming_series": "_T-Purchase Order-",
"base_net_total": 5000.0,
"items": [
@@ -42,7 +42,7 @@
"doctype": "Purchase Order",
"base_grand_total": 5000.0,
"grand_total": 5000.0,
- "is_subcontracted": "No",
+ "is_subcontracted": 0,
"naming_series": "_T-Purchase Order-",
"base_net_total": 5000.0,
"items": [
diff --git a/erpnext/buying/doctype/purchase_order_item/purchase_order_item.json b/erpnext/buying/doctype/purchase_order_item/purchase_order_item.json
index b4cdb18..7f797cf 100644
--- a/erpnext/buying/doctype/purchase_order_item/purchase_order_item.json
+++ b/erpnext/buying/doctype/purchase_order_item/purchase_order_item.json
@@ -574,6 +574,7 @@
"read_only": 1
},
{
+ "depends_on": "eval:parent.is_subcontracted",
"fieldname": "bom",
"fieldtype": "Link",
"label": "BOM",
@@ -583,6 +584,7 @@
},
{
"default": "0",
+ "depends_on": "eval:parent.is_subcontracted",
"fieldname": "include_exploded_items",
"fieldtype": "Check",
"hidden": 1,
@@ -849,20 +851,20 @@
"print_hide": 1
},
{
- "depends_on": "eval:parent.is_subcontracted == 'Yes'",
+ "depends_on": "eval:parent.is_subcontracted",
"fieldname": "fg_item",
"fieldtype": "Link",
"label": "Finished Good Item",
- "mandatory_depends_on": "eval:parent.is_subcontracted == 'Yes'",
+ "mandatory_depends_on": "eval:parent.is_subcontracted",
"options": "Item"
},
{
"default": "1",
- "depends_on": "eval:parent.is_subcontracted == 'Yes'",
+ "depends_on": "eval:parent.is_subcontracted",
"fieldname": "fg_item_qty",
"fieldtype": "Float",
"label": "Finished Good Item Qty",
- "mandatory_depends_on": "eval:parent.is_subcontracted == 'Yes'"
+ "mandatory_depends_on": "eval:parent.is_subcontracted"
}
],
"idx": 1,
diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json
index 567e41f..8d1939a 100644
--- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json
+++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json
@@ -773,11 +773,10 @@
"fieldtype": "Column Break"
},
{
- "default": "No",
+ "default": "0",
"fieldname": "is_subcontracted",
- "fieldtype": "Select",
+ "fieldtype": "Check",
"label": "Is Subcontracted",
- "options": "\nYes\nNo",
"print_hide": 1
},
{
diff --git a/erpnext/buying/doctype/supplier_quotation/test_records.json b/erpnext/buying/doctype/supplier_quotation/test_records.json
index 0f835d2..8acac32 100644
--- a/erpnext/buying/doctype/supplier_quotation/test_records.json
+++ b/erpnext/buying/doctype/supplier_quotation/test_records.json
@@ -7,7 +7,7 @@
"doctype": "Supplier Quotation",
"base_grand_total": 5000.0,
"grand_total": 5000.0,
- "is_subcontracted": "No",
+ "is_subcontracted": 0,
"naming_series": "_T-Supplier Quotation-",
"base_net_total": 5000.0,
"items": [
diff --git a/erpnext/buying/report/subcontract_order_summary/subcontract_order_summary.js b/erpnext/buying/report/subcontract_order_summary/subcontract_order_summary.js
index 5ba52f1..6889322 100644
--- a/erpnext/buying/report/subcontract_order_summary/subcontract_order_summary.js
+++ b/erpnext/buying/report/subcontract_order_summary/subcontract_order_summary.js
@@ -35,7 +35,7 @@
return {
filters: {
docstatus: 1,
- is_subcontracted: 'Yes',
+ is_subcontracted: 1,
company: frappe.query_report.get_filter_value('company')
}
}
diff --git a/erpnext/buying/report/subcontract_order_summary/subcontract_order_summary.py b/erpnext/buying/report/subcontract_order_summary/subcontract_order_summary.py
index 1b2705a..3d66637 100644
--- a/erpnext/buying/report/subcontract_order_summary/subcontract_order_summary.py
+++ b/erpnext/buying/report/subcontract_order_summary/subcontract_order_summary.py
@@ -45,7 +45,7 @@
def get_filters(report_filters):
filters = [
["Purchase Order", "docstatus", "=", 1],
- ["Purchase Order", "is_subcontracted", "=", "Yes"],
+ ["Purchase Order", "is_subcontracted", "=", 1],
[
"Purchase Order",
"transaction_date",
diff --git a/erpnext/buying/report/subcontracted_item_to_be_received/subcontracted_item_to_be_received.py b/erpnext/buying/report/subcontracted_item_to_be_received/subcontracted_item_to_be_received.py
index 004657b..2e90de6 100644
--- a/erpnext/buying/report/subcontracted_item_to_be_received/subcontracted_item_to_be_received.py
+++ b/erpnext/buying/report/subcontracted_item_to_be_received/subcontracted_item_to_be_received.py
@@ -78,7 +78,7 @@
def get_po(filters):
record_filters = [
- ["is_subcontracted", "=", "Yes"],
+ ["is_subcontracted", "=", 1],
["supplier", "=", filters.supplier],
["transaction_date", "<=", filters.to_date],
["transaction_date", ">=", filters.from_date],
diff --git a/erpnext/buying/report/subcontracted_item_to_be_received/test_subcontracted_item_to_be_received.py b/erpnext/buying/report/subcontracted_item_to_be_received/test_subcontracted_item_to_be_received.py
index 26e4243..57f8741 100644
--- a/erpnext/buying/report/subcontracted_item_to_be_received/test_subcontracted_item_to_be_received.py
+++ b/erpnext/buying/report/subcontracted_item_to_be_received/test_subcontracted_item_to_be_received.py
@@ -17,7 +17,7 @@
class TestSubcontractedItemToBeReceived(FrappeTestCase):
def test_pending_and_received_qty(self):
- po = create_purchase_order(item_code="_Test FG Item", is_subcontracted="Yes")
+ po = create_purchase_order(item_code="_Test FG Item", is_subcontracted=1)
transfer_param = []
make_stock_entry(
item_code="_Test Item", target="_Test Warehouse 1 - _TC", qty=100, basic_rate=100
diff --git a/erpnext/buying/report/subcontracted_raw_materials_to_be_transferred/subcontracted_raw_materials_to_be_transferred.py b/erpnext/buying/report/subcontracted_raw_materials_to_be_transferred/subcontracted_raw_materials_to_be_transferred.py
index 98b18da..6b8a3b1 100644
--- a/erpnext/buying/report/subcontracted_raw_materials_to_be_transferred/subcontracted_raw_materials_to_be_transferred.py
+++ b/erpnext/buying/report/subcontracted_raw_materials_to_be_transferred/subcontracted_raw_materials_to_be_transferred.py
@@ -72,7 +72,7 @@
],
filters=[
["Purchase Order", "per_received", "<", "100"],
- ["Purchase Order", "is_subcontracted", "=", "Yes"],
+ ["Purchase Order", "is_subcontracted", "=", 1],
["Purchase Order", "supplier", "=", filters.supplier],
["Purchase Order", "transaction_date", "<=", filters.to_date],
["Purchase Order", "transaction_date", ">=", filters.from_date],
diff --git a/erpnext/buying/report/subcontracted_raw_materials_to_be_transferred/test_subcontracted_raw_materials_to_be_transferred.py b/erpnext/buying/report/subcontracted_raw_materials_to_be_transferred/test_subcontracted_raw_materials_to_be_transferred.py
index 401176d..2791a26 100644
--- a/erpnext/buying/report/subcontracted_raw_materials_to_be_transferred/test_subcontracted_raw_materials_to_be_transferred.py
+++ b/erpnext/buying/report/subcontracted_raw_materials_to_be_transferred/test_subcontracted_raw_materials_to_be_transferred.py
@@ -19,7 +19,7 @@
class TestSubcontractedItemToBeTransferred(FrappeTestCase):
def test_pending_and_transferred_qty(self):
po = create_purchase_order(
- item_code="_Test FG Item", is_subcontracted="Yes", supplier_warehouse="_Test Warehouse 1 - _TC"
+ item_code="_Test FG Item", is_subcontracted=1, supplier_warehouse="_Test Warehouse 1 - _TC"
)
# Material Receipt of RMs
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index 3a20d3f..8a9318e 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -2586,7 +2586,7 @@
parent.update_ordered_qty()
parent.update_ordered_and_reserved_qty()
parent.update_receiving_percentage()
- if parent.is_subcontracted == "Yes":
+ if parent.is_subcontracted:
parent.update_reserved_qty_for_subcontract()
parent.create_raw_materials_supplied("supplied_items")
parent.save()
diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py
index 4823e8b..6fdb002 100644
--- a/erpnext/controllers/buying_controller.py
+++ b/erpnext/controllers/buying_controller.py
@@ -167,7 +167,7 @@
_("Row #{0}: Accepted Warehouse and Supplier Warehouse cannot be same").format(item.idx)
)
- if item.get("from_warehouse") and self.get("is_subcontracted") == "Yes":
+ if item.get("from_warehouse") and self.get("is_subcontracted"):
frappe.throw(
_(
"Row #{0}: Cannot select Supplier Warehouse while suppling raw materials to subcontractor"
@@ -339,10 +339,7 @@
return supplied_items_cost
def validate_for_subcontracting(self):
- if not self.is_subcontracted and self.sub_contracted_items:
- frappe.throw(_("Please enter 'Is Subcontracted' as Yes or No"))
-
- if self.is_subcontracted == "Yes":
+ if self.is_subcontracted:
if self.doctype in ["Purchase Receipt", "Purchase Invoice"] and not self.supplier_warehouse:
frappe.throw(_("Supplier Warehouse mandatory for sub-contracted {0}").format(self.doctype))
@@ -363,14 +360,14 @@
item.bom = None
def create_raw_materials_supplied(self, raw_material_table):
- if self.is_subcontracted == "Yes":
+ if self.is_subcontracted:
self.set_materials_for_subcontracted_items(raw_material_table)
elif self.doctype in ["Purchase Receipt", "Purchase Invoice"]:
for item in self.get("items"):
item.rm_supp_cost = 0.0
- if self.is_subcontracted == "No" and self.get("supplied_items"):
+ if not self.is_subcontracted and self.get("supplied_items"):
self.set("supplied_items", [])
@property
diff --git a/erpnext/controllers/subcontracting.py b/erpnext/controllers/subcontracting.py
index 7083088..4bce06f 100644
--- a/erpnext/controllers/subcontracting.py
+++ b/erpnext/controllers/subcontracting.py
@@ -407,7 +407,7 @@
def set_consumed_qty_in_po(self):
# Update consumed qty back in the purchase order
- if self.is_subcontracted != "Yes":
+ if not self.is_subcontracted:
return
self.__get_purchase_orders()
diff --git a/erpnext/manufacturing/doctype/bom/test_bom.py b/erpnext/manufacturing/doctype/bom/test_bom.py
index 524f45b..62fc072 100644
--- a/erpnext/manufacturing/doctype/bom/test_bom.py
+++ b/erpnext/manufacturing/doctype/bom/test_bom.py
@@ -251,7 +251,7 @@
self.assertEqual(bom.items[2].rate, 0)
# test in Purchase Order sourced_by_supplier is not added to Supplied Item
po = create_purchase_order(
- item_code=item_code, qty=1, is_subcontracted="Yes", supplier_warehouse="_Test Warehouse 1 - _TC"
+ item_code=item_code, qty=1, is_subcontracted=1, supplier_warehouse="_Test Warehouse 1 - _TC"
)
bom_items = sorted([d.item_code for d in bom.items if d.sourced_by_supplier != 1])
supplied_items = sorted([d.rm_item_code for d in po.supplied_items])
diff --git a/erpnext/manufacturing/doctype/production_plan/production_plan.py b/erpnext/manufacturing/doctype/production_plan/production_plan.py
index 89f9ca6..60b32b8 100644
--- a/erpnext/manufacturing/doctype/production_plan/production_plan.py
+++ b/erpnext/manufacturing/doctype/production_plan/production_plan.py
@@ -501,7 +501,7 @@
po = frappe.new_doc("Purchase Order")
po.supplier = supplier
po.schedule_date = getdate(po_list[0].schedule_date) if po_list[0].schedule_date else nowdate()
- po.is_subcontracted = "Yes"
+ po.is_subcontracted = 1
for row in po_list:
po_data = {
"item_code": row.production_item,
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 028834a..a3bf78b 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -4,6 +4,7 @@
erpnext.patches.v13_0.add_bin_unique_constraint
erpnext.patches.v11_0.refactor_naming_series
erpnext.patches.v11_0.refactor_autoname_naming
+erpnext.patches.v14_0.change_is_subcontracted_fieldtype
execute:frappe.reload_doc("accounts", "doctype", "POS Payment Method") #2020-05-28
execute:frappe.reload_doc("HR", "doctype", "HR Settings") #2020-01-16 #2020-07-24
erpnext.patches.v4_2.update_requested_and_ordered_qty #2021-03-31
diff --git a/erpnext/patches/v14_0/change_is_subcontracted_fieldtype.py b/erpnext/patches/v14_0/change_is_subcontracted_fieldtype.py
new file mode 100644
index 0000000..ba919a7
--- /dev/null
+++ b/erpnext/patches/v14_0/change_is_subcontracted_fieldtype.py
@@ -0,0 +1,26 @@
+# Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+import frappe
+
+
+def execute():
+ for doctype in ["Purchase Order", "Purchase Receipt", "Purchase Invoice", "Supplier Quotation"]:
+ frappe.db.sql(
+ """
+ UPDATE `tab{doctype}`
+ SET is_subcontracted = 0
+ where is_subcontracted in ('', NULL, 'No')""".format(
+ doctype=doctype
+ )
+ )
+ frappe.db.sql(
+ """
+ UPDATE `tab{doctype}`
+ SET is_subcontracted = 1
+ where is_subcontracted = 'Yes'""".format(
+ doctype=doctype
+ )
+ )
+
+ frappe.reload_doc(frappe.get_meta(doctype).module, "doctype", frappe.scrub(doctype))
diff --git a/erpnext/public/js/controllers/buying.js b/erpnext/public/js/controllers/buying.js
index a925470..0920ca0 100644
--- a/erpnext/public/js/controllers/buying.js
+++ b/erpnext/public/js/controllers/buying.js
@@ -81,7 +81,7 @@
}
this.frm.set_query("item_code", "items", function() {
- if (me.frm.doc.is_subcontracted == "Yes") {
+ if (me.frm.doc.is_subcontracted) {
return{
query: "erpnext.controllers.queries.item_query",
filters:{ 'supplier': me.frm.doc.supplier, 'is_stock_item': 0 }
diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index 23c2bd4..57cbe91 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -239,7 +239,7 @@
() => set_value('currency', currency),
() => set_value('price_list_currency', currency),
() => set_value('status', 'Draft'),
- () => set_value('is_subcontracted', 'No'),
+ () => set_value('is_subcontracted', 0),
() => {
if(this.frm.doc.company && !this.frm.doc.amended_from) {
this.frm.trigger("company");
diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js
index 8260426..eded165 100755
--- a/erpnext/public/js/utils.js
+++ b/erpnext/public/js/utils.js
@@ -483,8 +483,8 @@
if (frm.doc.doctype == 'Sales Order') {
filters = {"is_sales_item": 1};
} else if (frm.doc.doctype == 'Purchase Order') {
- if (frm.doc.is_subcontracted == "Yes") {
- filters = {"is_stock_item": 0};
+ if (frm.doc.is_subcontracted) {
+ filters = {"is_sub_contracted_item": 1};
} else {
filters = {"is_purchase_item": 1};
}
diff --git a/erpnext/stock/doctype/item_alternative/test_item_alternative.py b/erpnext/stock/doctype/item_alternative/test_item_alternative.py
index d829b2c..32c58c5 100644
--- a/erpnext/stock/doctype/item_alternative/test_item_alternative.py
+++ b/erpnext/stock/doctype/item_alternative/test_item_alternative.py
@@ -41,7 +41,7 @@
supplier_warehouse = "Test Supplier Warehouse - _TC"
po = create_purchase_order(
item="Test Finished Goods - A",
- is_subcontracted="Yes",
+ is_subcontracted=1,
qty=5,
rate=3000,
supplier_warehouse=supplier_warehouse,
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
index 0182ed5..51ec598 100644
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
@@ -200,7 +200,7 @@
cur_frm.add_custom_button(__('Reopen'), this.reopen_purchase_receipt, __("Status"))
}
- this.frm.toggle_reqd("supplier_warehouse", this.frm.doc.is_subcontracted==="Yes");
+ this.frm.toggle_reqd("supplier_warehouse", this.frm.doc.is_subcontracted);
}
make_purchase_invoice() {
@@ -298,10 +298,10 @@
frappe.provide("erpnext.buying");
frappe.ui.form.on("Purchase Receipt", "is_subcontracted", function(frm) {
- if (frm.doc.is_subcontracted === "Yes") {
+ if (frm.doc.is_subcontracted) {
erpnext.buying.get_default_bom(frm);
}
- frm.toggle_reqd("supplier_warehouse", frm.doc.is_subcontracted==="Yes");
+ frm.toggle_reqd("supplier_warehouse", frm.doc.is_subcontracted);
});
frappe.ui.form.on('Purchase Receipt Item', {
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json
index 6d4b4a1..6e5f6f5 100755
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json
@@ -437,17 +437,16 @@
"fieldtype": "Column Break"
},
{
- "default": "No",
+ "default": "0",
"fieldname": "is_subcontracted",
- "fieldtype": "Select",
- "label": "Raw Materials Consumed",
+ "fieldtype": "Check",
+ "label": "Is Subcontracted",
"oldfieldname": "is_subcontracted",
"oldfieldtype": "Select",
- "options": "No\nYes",
"print_hide": 1
},
{
- "depends_on": "eval:doc.is_subcontracted==\"Yes\"",
+ "depends_on": "eval:doc.is_subcontracted",
"fieldname": "supplier_warehouse",
"fieldtype": "Link",
"label": "Supplier Warehouse",
diff --git a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
index a6f82b0..bfbdd56 100644
--- a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
+++ b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
@@ -327,7 +327,7 @@
target="_Test Warehouse 1 - _TC",
basic_rate=100,
)
- pr = make_purchase_receipt(item_code="_Test FG Item", qty=10, rate=500, is_subcontracted="Yes")
+ pr = make_purchase_receipt(item_code="_Test FG Item", qty=10, rate=500, is_subcontracted=1)
self.assertEqual(len(pr.get("supplied_items")), 2)
rm_supp_cost = sum(d.amount for d in pr.get("supplied_items"))
@@ -362,7 +362,7 @@
item_code="_Test FG Item",
qty=10,
rate=0,
- is_subcontracted="Yes",
+ is_subcontracted=1,
company="_Test Company with perpetual inventory",
warehouse="Stores - TCP1",
supplier_warehouse="Work In Progress - TCP1",
@@ -401,7 +401,7 @@
item_code=item_code,
qty=1,
include_exploded_items=0,
- is_subcontracted="Yes",
+ is_subcontracted=1,
supplier_warehouse="_Test Warehouse 1 - _TC",
)
@@ -1122,7 +1122,7 @@
po = create_purchase_order(
item_code=item_code,
qty=order_qty,
- is_subcontracted="Yes",
+ is_subcontracted=1,
supplier_warehouse="_Test Warehouse 1 - _TC",
)
@@ -1465,7 +1465,7 @@
pr.set_posting_time = 1
pr.company = args.company or "_Test Company"
pr.supplier = args.supplier or "_Test Supplier"
- pr.is_subcontracted = args.is_subcontracted or "No"
+ pr.is_subcontracted = args.is_subcontracted or 0
pr.supplier_warehouse = args.supplier_warehouse or "_Test Warehouse 1 - _TC"
pr.currency = args.currency or "INR"
pr.is_return = args.is_return
diff --git a/erpnext/stock/doctype/purchase_receipt/test_records.json b/erpnext/stock/doctype/purchase_receipt/test_records.json
index 724e3d7..990ad12 100644
--- a/erpnext/stock/doctype/purchase_receipt/test_records.json
+++ b/erpnext/stock/doctype/purchase_receipt/test_records.json
@@ -92,7 +92,7 @@
"currency": "INR",
"doctype": "Purchase Receipt",
"base_grand_total": 5000.0,
- "is_subcontracted": "Yes",
+ "is_subcontracted": 1,
"base_net_total": 5000.0,
"items": [
{
diff --git a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json
index e5994b2..03a4201 100644
--- a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json
+++ b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json
@@ -648,7 +648,7 @@
},
{
"default": "0",
- "depends_on": "eval:parent.is_subcontracted == 'Yes'",
+ "depends_on": "eval:parent.is_subcontracted",
"fieldname": "include_exploded_items",
"fieldtype": "Check",
"label": "Include Exploded Items",
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js
index 1aafcee..a940878 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.js
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.js
@@ -793,7 +793,7 @@
return {
"filters": {
"docstatus": 1,
- "is_subcontracted": "Yes",
+ "is_subcontracted": 1,
"company": me.frm.doc.company
}
};
diff --git a/erpnext/stock/doctype/stock_ledger_entry/test_stock_ledger_entry.py b/erpnext/stock/doctype/stock_ledger_entry/test_stock_ledger_entry.py
index 42956a1..6561362 100644
--- a/erpnext/stock/doctype/stock_ledger_entry/test_stock_ledger_entry.py
+++ b/erpnext/stock/doctype/stock_ledger_entry/test_stock_ledger_entry.py
@@ -436,7 +436,7 @@
item_code=subcontracted_item,
qty=10,
rate=20,
- is_subcontracted="Yes",
+ is_subcontracted=1,
)
self.assertEqual(pr1.items[0].valuation_rate, 120)
diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py
index 0d7d472..dfd9f8a 100644
--- a/erpnext/stock/get_item_details.py
+++ b/erpnext/stock/get_item_details.py
@@ -50,7 +50,7 @@
"transaction_date": None,
"conversion_rate": 1.0,
"buying_price_list": None,
- "is_subcontracted": "Yes" / "No",
+ "is_subcontracted": 0/1,
"ignore_pricing_rule": 0/1
"project": ""
"set_warehouse": ""
@@ -124,7 +124,7 @@
if args.transaction_date and item.lead_time_days:
out.schedule_date = out.lead_time_date = add_days(args.transaction_date, item.lead_time_days)
- if args.get("is_subcontracted") == "Yes":
+ if args.get("is_subcontracted"):
out.bom = args.get("bom") or get_default_bom(args.item_code)
get_gross_profit(out)
@@ -237,7 +237,7 @@
throw(_("Item {0} is a template, please select one of its variants").format(item.name))
elif args.transaction_type == "buying" and args.doctype != "Material Request":
- if args.get("is_subcontracted") == "Yes" and item.is_stock_item:
+ if args.get("is_subcontracted") and item.is_stock_item:
throw(_("Item {0} must be a Non-Stock Item").format(item.name))
@@ -258,7 +258,7 @@
"transaction_date": None,
"conversion_rate": 1.0,
"buying_price_list": None,
- "is_subcontracted": "Yes" / "No",
+ "is_subcontracted": 0/1,
"ignore_pricing_rule": 0/1
"project": "",
barcode: "",
diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py
index 967b2b2..3e0ddab 100644
--- a/erpnext/stock/stock_ledger.py
+++ b/erpnext/stock/stock_ledger.py
@@ -715,7 +715,7 @@
)
# Recalculate subcontracted item's rate in case of subcontracted purchase receipt/invoice
- if frappe.get_cached_value(sle.voucher_type, sle.voucher_no, "is_subcontracted") == "Yes":
+ if frappe.get_cached_value(sle.voucher_type, sle.voucher_no, "is_subcontracted"):
doc = frappe.get_doc(sle.voucher_type, sle.voucher_no)
doc.update_valuation_rate(reset_outgoing_rate=False)
for d in doc.items + doc.supplied_items:
diff --git a/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.js b/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.js
index 80fe944..c9e4577 100644
--- a/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.js
+++ b/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.js
@@ -24,7 +24,7 @@
return {
filters: {
docstatus: 1,
- is_subcontracted: "Yes"
+ is_subcontracted: 1
}
};
});
diff --git a/erpnext/tests/test_subcontracting.py b/erpnext/tests/test_subcontracting.py
index 07291e8..bf12181 100644
--- a/erpnext/tests/test_subcontracting.py
+++ b/erpnext/tests/test_subcontracting.py
@@ -50,7 +50,7 @@
itemwise_details = make_stock_in_entry(rm_items=rm_items)
po = create_purchase_order(
- rm_items=items, is_subcontracted="Yes", supplier_warehouse="_Test Warehouse 1 - _TC"
+ rm_items=items, is_subcontracted=1, supplier_warehouse="_Test Warehouse 1 - _TC"
)
for d in rm_items:
@@ -112,7 +112,7 @@
itemwise_details = make_stock_in_entry(rm_items=rm_items)
po = create_purchase_order(
- rm_items=items, is_subcontracted="Yes", supplier_warehouse="_Test Warehouse 1 - _TC"
+ rm_items=items, is_subcontracted=1, supplier_warehouse="_Test Warehouse 1 - _TC"
)
for d in rm_items:
@@ -175,7 +175,7 @@
itemwise_details = make_stock_in_entry(rm_items=rm_items)
po = create_purchase_order(
- rm_items=items, is_subcontracted="Yes", supplier_warehouse="_Test Warehouse 1 - _TC"
+ rm_items=items, is_subcontracted=1, supplier_warehouse="_Test Warehouse 1 - _TC"
)
for d in rm_items:
@@ -239,7 +239,7 @@
itemwise_details = make_stock_in_entry(rm_items=rm_items)
po = create_purchase_order(
- rm_items=items, is_subcontracted="Yes", supplier_warehouse="_Test Warehouse 1 - _TC"
+ rm_items=items, is_subcontracted=1, supplier_warehouse="_Test Warehouse 1 - _TC"
)
for d in rm_items:
@@ -298,7 +298,7 @@
itemwise_details = make_stock_in_entry(rm_items=rm_items)
po = create_purchase_order(
- rm_items=items, is_subcontracted="Yes", supplier_warehouse="_Test Warehouse 1 - _TC"
+ rm_items=items, is_subcontracted=1, supplier_warehouse="_Test Warehouse 1 - _TC"
)
for d in rm_items:
@@ -363,7 +363,7 @@
itemwise_details = make_stock_in_entry(rm_items=rm_items)
po = create_purchase_order(
- rm_items=items, is_subcontracted="Yes", supplier_warehouse="_Test Warehouse 1 - _TC"
+ rm_items=items, is_subcontracted=1, supplier_warehouse="_Test Warehouse 1 - _TC"
)
for d in rm_items:
@@ -421,7 +421,7 @@
itemwise_details = make_stock_in_entry(rm_items=rm_items)
po = create_purchase_order(
- rm_items=items, is_subcontracted="Yes", supplier_warehouse="_Test Warehouse 1 - _TC"
+ rm_items=items, is_subcontracted=1, supplier_warehouse="_Test Warehouse 1 - _TC"
)
for d in rm_items:
@@ -492,7 +492,7 @@
itemwise_details = make_stock_in_entry(rm_items=rm_items)
po = create_purchase_order(
- rm_items=items, is_subcontracted="Yes", supplier_warehouse="_Test Warehouse 1 - _TC"
+ rm_items=items, is_subcontracted=1, supplier_warehouse="_Test Warehouse 1 - _TC"
)
for d in rm_items:
@@ -529,7 +529,7 @@
itemwise_details = make_stock_in_entry(rm_items=rm_items)
po = create_purchase_order(
- rm_items=items, is_subcontracted="Yes", supplier_warehouse="_Test Warehouse 1 - _TC"
+ rm_items=items, is_subcontracted=1, supplier_warehouse="_Test Warehouse 1 - _TC"
)
for d in rm_items:
@@ -609,7 +609,7 @@
itemwise_details = make_stock_in_entry(rm_items=rm_items)
po = create_purchase_order(
- rm_items=items, is_subcontracted="Yes", supplier_warehouse="_Test Warehouse 1 - _TC"
+ rm_items=items, is_subcontracted=1, supplier_warehouse="_Test Warehouse 1 - _TC"
)
for d in rm_items:
@@ -675,7 +675,7 @@
itemwise_details = make_stock_in_entry(rm_items=rm_items)
po = create_purchase_order(
- rm_items=items, is_subcontracted="Yes", supplier_warehouse="_Test Warehouse 1 - _TC"
+ rm_items=items, is_subcontracted=1, supplier_warehouse="_Test Warehouse 1 - _TC"
)
for d in rm_items:
@@ -751,7 +751,7 @@
itemwise_details = make_stock_in_entry(rm_items=rm_items)
po = create_purchase_order(
- rm_items=items, is_subcontracted="Yes", supplier_warehouse="_Test Warehouse 1 - _TC"
+ rm_items=items, is_subcontracted=1, supplier_warehouse="_Test Warehouse 1 - _TC"
)
for d in rm_items:
@@ -834,7 +834,7 @@
itemwise_details = make_stock_in_entry(rm_items=rm_items)
po = create_purchase_order(
- rm_items=items, is_subcontracted="Yes", supplier_warehouse="_Test Warehouse 1 - _TC"
+ rm_items=items, is_subcontracted=1, supplier_warehouse="_Test Warehouse 1 - _TC"
)
for d in rm_items: