From f8d2e276a5b235bb288551b7181c6bc90450688d Mon Sep 17 00:00:00 2001 From: Sagar Sharma Date: Mon, 7 Nov 2022 17:19:03 +0530 Subject: [PATCH 1/7] fix: make `consumed_qty` read-only in SCR Supplied Items --- .../subcontracting_receipt_supplied_item.json | 411 +++++++++--------- 1 file changed, 206 insertions(+), 205 deletions(-) diff --git a/erpnext/subcontracting/doctype/subcontracting_receipt_supplied_item/subcontracting_receipt_supplied_item.json b/erpnext/subcontracting/doctype/subcontracting_receipt_supplied_item/subcontracting_receipt_supplied_item.json index ddbb80661a..d21bc22ad7 100644 --- a/erpnext/subcontracting/doctype/subcontracting_receipt_supplied_item/subcontracting_receipt_supplied_item.json +++ b/erpnext/subcontracting/doctype/subcontracting_receipt_supplied_item/subcontracting_receipt_supplied_item.json @@ -1,207 +1,208 @@ { - "actions": [], - "creation": "2022-04-18 10:45:16.538479", - "doctype": "DocType", - "editable_grid": 1, - "engine": "InnoDB", - "field_order": [ - "main_item_code", - "rm_item_code", - "item_name", - "bom_detail_no", - "col_break1", - "description", - "stock_uom", - "conversion_factor", - "reference_name", - "secbreak_1", - "rate", - "col_break2", - "amount", - "secbreak_2", - "available_qty_for_consumption", - "required_qty", - "col_break3", - "consumed_qty", - "current_stock", - "secbreak_3", - "batch_no", - "col_break4", - "serial_no", - "subcontracting_order" - ], - "fields": [ - { - "fieldname": "main_item_code", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Item Code", - "options": "Item", - "read_only": 1 - }, - { - "fieldname": "rm_item_code", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Raw Material Item Code", - "options": "Item", - "read_only": 1 - }, - { - "fieldname": "description", - "fieldtype": "Text Editor", - "in_global_search": 1, - "label": "Description", - "print_width": "300px", - "read_only": 1, - "width": "300px" - }, - { - "fieldname": "batch_no", - "fieldtype": "Link", - "label": "Batch No", - "no_copy": 1, - "options": "Batch" - }, - { - "fieldname": "serial_no", - "fieldtype": "Text", - "label": "Serial No", - "no_copy": 1 - }, - { - "fieldname": "col_break1", - "fieldtype": "Column Break" - }, - { - "fieldname": "required_qty", - "fieldtype": "Float", - "label": "Required Qty", - "print_hide": 1, - "read_only": 1 - }, - { - "columns": 2, - "fieldname": "consumed_qty", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Consumed Qty", - "reqd": 1 - }, - { - "fieldname": "stock_uom", - "fieldtype": "Link", - "label": "Stock Uom", - "options": "UOM", - "read_only": 1 - }, - { - "fieldname": "rate", - "fieldtype": "Currency", - "label": "Rate", - "options": "Company:company:default_currency", - "read_only": 1 - }, - { - "fieldname": "amount", - "fieldtype": "Currency", - "label": "Amount", - "options": "Company:company:default_currency", - "read_only": 1 - }, - { - "default": "1", - "fieldname": "conversion_factor", - "fieldtype": "Float", - "hidden": 1, - "label": "Conversion Factor", - "read_only": 1 - }, - { - "fieldname": "current_stock", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Current Stock", - "read_only": 1 - }, - { - "fieldname": "reference_name", - "fieldtype": "Data", - "hidden": 1, - "in_list_view": 1, - "label": "Reference Name", - "read_only": 1 - }, - { - "fieldname": "bom_detail_no", - "fieldtype": "Data", - "hidden": 1, - "in_list_view": 1, - "label": "BOM Detail No", - "read_only": 1 - }, - { - "fieldname": "secbreak_1", - "fieldtype": "Section Break" - }, - { - "fieldname": "col_break2", - "fieldtype": "Column Break" - }, - { - "fieldname": "secbreak_2", - "fieldtype": "Section Break" - }, - { - "fieldname": "col_break3", - "fieldtype": "Column Break" - }, - { - "fieldname": "secbreak_3", - "fieldtype": "Section Break" - }, - { - "fieldname": "col_break4", - "fieldtype": "Column Break" - }, - { - "fieldname": "item_name", - "fieldtype": "Data", - "label": "Item Name", - "read_only": 1 - }, - { - "fieldname": "subcontracting_order", - "fieldtype": "Link", - "hidden": 1, - "label": "Subcontracting Order", - "no_copy": 1, - "options": "Subcontracting Order", - "print_hide": 1, - "read_only": 1 - }, - { - "default": "0", - "fieldname": "available_qty_for_consumption", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Available Qty For Consumption", - "print_hide": 1, - "read_only": 1 - } - ], - "idx": 1, - "istable": 1, - "links": [], - "modified": "2022-09-02 22:28:53.392381", - "modified_by": "Administrator", - "module": "Subcontracting", - "name": "Subcontracting Receipt Supplied Item", - "naming_rule": "Autoincrement", - "owner": "Administrator", - "permissions": [], - "sort_field": "modified", - "sort_order": "DESC", - "states": [], - "track_changes": 1 + "actions": [], + "creation": "2022-04-18 10:45:16.538479", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "main_item_code", + "rm_item_code", + "item_name", + "bom_detail_no", + "col_break1", + "description", + "stock_uom", + "conversion_factor", + "reference_name", + "secbreak_1", + "rate", + "col_break2", + "amount", + "secbreak_2", + "available_qty_for_consumption", + "required_qty", + "col_break3", + "consumed_qty", + "current_stock", + "secbreak_3", + "batch_no", + "col_break4", + "serial_no", + "subcontracting_order" + ], + "fields": [ + { + "fieldname": "main_item_code", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Item Code", + "options": "Item", + "read_only": 1 + }, + { + "fieldname": "rm_item_code", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Raw Material Item Code", + "options": "Item", + "read_only": 1 + }, + { + "fieldname": "description", + "fieldtype": "Text Editor", + "in_global_search": 1, + "label": "Description", + "print_width": "300px", + "read_only": 1, + "width": "300px" + }, + { + "fieldname": "batch_no", + "fieldtype": "Link", + "label": "Batch No", + "no_copy": 1, + "options": "Batch" + }, + { + "fieldname": "serial_no", + "fieldtype": "Text", + "label": "Serial No", + "no_copy": 1 + }, + { + "fieldname": "col_break1", + "fieldtype": "Column Break" + }, + { + "fieldname": "required_qty", + "fieldtype": "Float", + "label": "Required Qty", + "print_hide": 1, + "read_only": 1 + }, + { + "columns": 2, + "fieldname": "consumed_qty", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Consumed Qty", + "read_only": 1, + "reqd": 1 + }, + { + "fieldname": "stock_uom", + "fieldtype": "Link", + "label": "Stock Uom", + "options": "UOM", + "read_only": 1 + }, + { + "fieldname": "rate", + "fieldtype": "Currency", + "label": "Rate", + "options": "Company:company:default_currency", + "read_only": 1 + }, + { + "fieldname": "amount", + "fieldtype": "Currency", + "label": "Amount", + "options": "Company:company:default_currency", + "read_only": 1 + }, + { + "default": "1", + "fieldname": "conversion_factor", + "fieldtype": "Float", + "hidden": 1, + "label": "Conversion Factor", + "read_only": 1 + }, + { + "fieldname": "current_stock", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Current Stock", + "read_only": 1 + }, + { + "fieldname": "reference_name", + "fieldtype": "Data", + "hidden": 1, + "in_list_view": 1, + "label": "Reference Name", + "read_only": 1 + }, + { + "fieldname": "bom_detail_no", + "fieldtype": "Data", + "hidden": 1, + "in_list_view": 1, + "label": "BOM Detail No", + "read_only": 1 + }, + { + "fieldname": "secbreak_1", + "fieldtype": "Section Break" + }, + { + "fieldname": "col_break2", + "fieldtype": "Column Break" + }, + { + "fieldname": "secbreak_2", + "fieldtype": "Section Break" + }, + { + "fieldname": "col_break3", + "fieldtype": "Column Break" + }, + { + "fieldname": "secbreak_3", + "fieldtype": "Section Break" + }, + { + "fieldname": "col_break4", + "fieldtype": "Column Break" + }, + { + "fieldname": "item_name", + "fieldtype": "Data", + "label": "Item Name", + "read_only": 1 + }, + { + "fieldname": "subcontracting_order", + "fieldtype": "Link", + "hidden": 1, + "label": "Subcontracting Order", + "no_copy": 1, + "options": "Subcontracting Order", + "print_hide": 1, + "read_only": 1 + }, + { + "default": "0", + "fieldname": "available_qty_for_consumption", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Available Qty For Consumption", + "print_hide": 1, + "read_only": 1 + } + ], + "idx": 1, + "istable": 1, + "links": [], + "modified": "2022-11-07 17:17:21.670761", + "modified_by": "Administrator", + "module": "Subcontracting", + "name": "Subcontracting Receipt Supplied Item", + "naming_rule": "Autoincrement", + "owner": "Administrator", + "permissions": [], + "sort_field": "modified", + "sort_order": "DESC", + "states": [], + "track_changes": 1 } \ No newline at end of file From bf4b012cec46cc7df261303d0f5d3106bc61d97c Mon Sep 17 00:00:00 2001 From: Sagar Sharma Date: Mon, 7 Nov 2022 17:20:52 +0530 Subject: [PATCH 2/7] fix: make `consumed_qty` editable when backflush based on Material Transfer --- .../subcontracting_receipt/subcontracting_receipt.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.js b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.js index aff76eb50f..eb4d0ca24d 100644 --- a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.js +++ b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.js @@ -57,6 +57,18 @@ frappe.ui.form.on('Subcontracting Receipt', { filters: { 'company': frm.doc.company } }; }); + + frappe.db.get_single_value('Buying Settings', 'backflush_raw_materials_of_subcontract_based_on').then(val => { + if (val == "Material Transferred for Subcontract") { + cur_frm.fields_dict['supplied_items'].grid.grid_rows.forEach((grid_row) => { + grid_row.docfields.forEach((df) => { + if (df.fieldname == "consumed_qty") { + df.read_only = 0; + } + }); + }); + } + }); }, refresh: (frm) => { From 5e8a22be24ebd70b494a2dd7ec5af542798f1201 Mon Sep 17 00:00:00 2001 From: Sagar Sharma Date: Mon, 7 Nov 2022 17:37:22 +0530 Subject: [PATCH 3/7] fix: linter --- .../doctype/workstation/workstation.py | 4 +--- .../subcontracting_receipt.js | 14 +++++++------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/erpnext/manufacturing/doctype/workstation/workstation.py b/erpnext/manufacturing/doctype/workstation/workstation.py index 76795e3c56..3c256221be 100644 --- a/erpnext/manufacturing/doctype/workstation/workstation.py +++ b/erpnext/manufacturing/doctype/workstation/workstation.py @@ -100,9 +100,7 @@ def get_default_holiday_list(): def check_if_within_operating_hours(workstation, operation, from_datetime, to_datetime): if from_datetime and to_datetime: - if not cint( - frappe.db.get_value("Manufacturing Settings", None, "allow_production_on_holidays") - ): + if not frappe.db.get_single_value("Manufacturing Settings", "allow_production_on_holidays"): check_workstation_for_holiday(workstation, from_datetime, to_datetime) if not cint(frappe.db.get_value("Manufacturing Settings", None, "allow_overtime")): diff --git a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.js b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.js index eb4d0ca24d..b6bef8c4a0 100644 --- a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.js +++ b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.js @@ -59,13 +59,13 @@ frappe.ui.form.on('Subcontracting Receipt', { }); frappe.db.get_single_value('Buying Settings', 'backflush_raw_materials_of_subcontract_based_on').then(val => { - if (val == "Material Transferred for Subcontract") { - cur_frm.fields_dict['supplied_items'].grid.grid_rows.forEach((grid_row) => { - grid_row.docfields.forEach((df) => { - if (df.fieldname == "consumed_qty") { - df.read_only = 0; - } - }); + if (val == 'Material Transferred for Subcontract') { + frm.fields_dict['supplied_items'].grid.grid_rows.forEach((grid_row) => { + grid_row.docfields.forEach((df) => { + if (df.fieldname == 'consumed_qty') { + df.read_only = 0; + } + }); }); } }); From 2b65b22aa2d9fd6d7ff4b407ecd1bd01f4bc43fa Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Mon, 7 Nov 2022 22:48:52 +0530 Subject: [PATCH 4/7] fix: Project filter in timesheet --- .../projects/doctype/timesheet/timesheet.js | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/erpnext/projects/doctype/timesheet/timesheet.js b/erpnext/projects/doctype/timesheet/timesheet.js index e1486de18c..a376bf46a5 100644 --- a/erpnext/projects/doctype/timesheet/timesheet.js +++ b/erpnext/projects/doctype/timesheet/timesheet.js @@ -92,18 +92,26 @@ frappe.ui.form.on("Timesheet", { frm.fields_dict["time_logs"].grid.toggle_enable("billing_hours", false); frm.fields_dict["time_logs"].grid.toggle_enable("is_billable", false); } + + let filters = { + "status": "Open" + }; + + if (frm.doc.customer) { + filters["customer"] = frm.doc.customer; + } + + frm.set_query('parent_project', function(doc) { + return { + filters: filters + }; + }); + frm.trigger('setup_filters'); frm.trigger('set_dynamic_field_label'); }, customer: function(frm) { - frm.set_query('parent_project', function(doc) { - return { - filters: { - "customer": doc.customer - } - }; - }); frm.set_query('project', 'time_logs', function(doc) { return { filters: { From 7b5cf6978ed11fa251dce7bbb961088ac20ab1d6 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Tue, 8 Nov 2022 11:00:48 +0530 Subject: [PATCH 5/7] chore: Linting Issues --- erpnext/manufacturing/doctype/workstation/workstation.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/erpnext/manufacturing/doctype/workstation/workstation.py b/erpnext/manufacturing/doctype/workstation/workstation.py index 76795e3c56..471ea47710 100644 --- a/erpnext/manufacturing/doctype/workstation/workstation.py +++ b/erpnext/manufacturing/doctype/workstation/workstation.py @@ -100,9 +100,7 @@ def get_default_holiday_list(): def check_if_within_operating_hours(workstation, operation, from_datetime, to_datetime): if from_datetime and to_datetime: - if not cint( - frappe.db.get_value("Manufacturing Settings", None, "allow_production_on_holidays") - ): + if not cint(frappe.db.get_value("Manufacturing Settings", None, "allow_production_on_holidays")): check_workstation_for_holiday(workstation, from_datetime, to_datetime) if not cint(frappe.db.get_value("Manufacturing Settings", None, "allow_overtime")): From 84ab100d86a6003a1b58e4dac1ee1e5698093f39 Mon Sep 17 00:00:00 2001 From: Sagar Sharma Date: Tue, 8 Nov 2022 12:05:15 +0530 Subject: [PATCH 6/7] chore: remove `debugger` from `stock_entry_list.js` --- erpnext/stock/doctype/stock_entry/stock_entry_list.js | 1 - 1 file changed, 1 deletion(-) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry_list.js b/erpnext/stock/doctype/stock_entry/stock_entry_list.js index 4eb0da11d2..af29d495ff 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry_list.js +++ b/erpnext/stock/doctype/stock_entry/stock_entry_list.js @@ -3,7 +3,6 @@ frappe.listview_settings['Stock Entry'] = { "`tabStock Entry`.`purpose`", "`tabStock Entry`.`work_order`", "`tabStock Entry`.`bom_no`", "`tabStock Entry`.`is_return`"], get_indicator: function (doc) { - debugger if(doc.is_return===1 && doc.purpose === "Material Transfer for Manufacture") { return [__("Material Returned from WIP"), "orange", "is_return,=,1|purpose,=,Material Transfer for Manufacture|docstatus,<,2"]; From 47248251e22315f6e4542c342619c2a22f1e98b5 Mon Sep 17 00:00:00 2001 From: Sagar Sharma Date: Tue, 8 Nov 2022 12:29:41 +0530 Subject: [PATCH 7/7] chore: link SCR Return in SCR Dashboard --- .../subcontracting_receipt_dashboard.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt_dashboard.py b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt_dashboard.py index a9e51937d7..deb8342b83 100644 --- a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt_dashboard.py +++ b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt_dashboard.py @@ -4,6 +4,9 @@ from frappe import _ def get_data(): return { "fieldname": "subcontracting_receipt_no", + "non_standard_fieldnames": { + "Subcontracting Receipt": "return_against", + }, "internal_links": { "Subcontracting Order": ["items", "subcontracting_order"], "Project": ["items", "project"], @@ -11,5 +14,6 @@ def get_data(): }, "transactions": [ {"label": _("Reference"), "items": ["Subcontracting Order", "Quality Inspection", "Project"]}, + {"label": _("Returns"), "items": ["Subcontracting Receipt"]}, ], }