From 27d95b7ca5d5ee18e6c7a52ddbf243e2e149e370 Mon Sep 17 00:00:00 2001 From: fproldan Date: Tue, 9 Jan 2024 20:07:37 -0300 Subject: [PATCH 1/2] feat: configurable creation of job card --- .../inventory_tools/custom/bom.json | 220 ++++++++++++------ .../inventory_tools_settings.json | 17 +- .../inventory_tools/overrides/work_order.py | 13 ++ 3 files changed, 181 insertions(+), 69 deletions(-) diff --git a/inventory_tools/inventory_tools/custom/bom.json b/inventory_tools/inventory_tools/custom/bom.json index 89f5b24..cfb6f0a 100644 --- a/inventory_tools/inventory_tools/custom/bom.json +++ b/inventory_tools/inventory_tools/custom/bom.json @@ -1,69 +1,155 @@ { - "custom_fields": [ - { - "_assign": null, - "_comments": null, - "_liked_by": null, - "_user_tags": null, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "collapsible_depends_on": null, - "columns": 0, - "creation": "2023-07-20 11:26:07.355568", - "default": 0, - "depends_on": null, - "description": null, - "docstatus": 0, - "dt": "BOM", - "fetch_from": null, - "fetch_if_empty": 0, - "fieldname": "is_subcontracted", - "fieldtype": "Check", - "hidden": 0, - "hide_border": 0, - "hide_days": 0, - "hide_seconds": 0, - "idx": 9, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_preview": 0, - "in_standard_filter": 0, - "insert_after": "allow_alternative_item", - "is_system_generated": 0, - "is_virtual": 0, - "label": "Is Subcontracted", - "length": 0, - "mandatory_depends_on": null, - "modified": "2023-07-20 11:26:07.355568", - "modified_by": "Administrator", - "module": "Inventory Tools", - "name": "BOM-is_subcontracted", - "no_copy": 0, - "non_negative": 0, - "options": null, - "owner": "Administrator", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "print_width": null, - "read_only": 0, - "read_only_depends_on": null, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "translatable": 0, - "unique": 0, - "width": null - } - ], - "custom_perms": [], - "doctype": "BOM", - "links": [], - "property_setters": [], - "sync_on_migrate": 1 + "custom_fields": [ + { + "_assign": null, + "_comments": null, + "_liked_by": null, + "_user_tags": null, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "collapsible_depends_on": null, + "columns": 0, + "creation": "2023-07-20 11:26:07.355568", + "default": "0", + "depends_on": null, + "description": null, + "docstatus": 0, + "dt": "BOM", + "fetch_from": null, + "fetch_if_empty": 0, + "fieldname": "is_subcontracted", + "fieldtype": "Check", + "hidden": 0, + "hide_border": 0, + "hide_days": 0, + "hide_seconds": 0, + "idx": 10, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_preview": 0, + "in_standard_filter": 0, + "insert_after": "allow_alternative_item", + "is_system_generated": 0, + "is_virtual": 0, + "label": "Is Subcontracted", + "length": 0, + "mandatory_depends_on": null, + "modified": "2023-07-20 11:26:07.355568", + "modified_by": "Administrator", + "module": "Inventory Tools", + "name": "BOM-is_subcontracted", + "no_copy": 0, + "non_negative": 0, + "options": null, + "owner": "Administrator", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "print_width": null, + "read_only": 0, + "read_only_depends_on": null, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "sort_options": 0, + "translatable": 0, + "unique": 0, + "width": null + }, + { + "_assign": null, + "_comments": null, + "_liked_by": null, + "_user_tags": null, + "allow_in_quick_entry": 0, + "allow_on_submit": 1, + "bold": 0, + "collapsible": 0, + "collapsible_depends_on": null, + "columns": 0, + "creation": "2024-01-09 18:02:12.685077", + "default": null, + "depends_on": null, + "description": null, + "docstatus": 0, + "dt": "BOM", + "fetch_from": null, + "fetch_if_empty": 0, + "fieldname": "create_job_cards_automatically", + "fieldtype": "Select", + "hidden": 0, + "hide_border": 0, + "hide_days": 0, + "hide_seconds": 0, + "idx": 11, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_preview": 0, + "in_standard_filter": 0, + "insert_after": "set_rate_of_sub_assembly_item_based_on_bom", + "is_system_generated": 0, + "is_virtual": 0, + "label": "Create Job Card(s) Automatically", + "length": 0, + "mandatory_depends_on": null, + "modified": "2024-01-09 18:02:12.685077", + "modified_by": "Administrator", + "module": "Inventory Tools", + "name": "BOM-create_job_cards_automatically", + "no_copy": 0, + "non_negative": 0, + "options": "\nYes\nNo", + "owner": "Administrator", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "print_width": null, + "read_only": 0, + "read_only_depends_on": null, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "sort_options": 0, + "translatable": 0, + "unique": 0, + "width": null + } + ], + "custom_perms": [], + "doctype": "BOM", + "links": [], + "property_setters": [ + { + "_assign": null, + "_comments": null, + "_liked_by": null, + "_user_tags": null, + "creation": "2024-01-09 12:01:11.525984", + "default_value": null, + "doc_type": "BOM", + "docstatus": 0, + "doctype_or_field": "DocType", + "field_name": null, + "idx": 0, + "is_system_generated": 0, + "modified": "2024-01-09 12:01:11.525984", + "modified_by": "Administrator", + "module": "Inventory Tools", + "name": "BOM-main-field_order", + "owner": "Administrator", + "property": "field_order", + "property_type": "Data", + "row_name": null, + "value": "[\"production_item_tab\", \"item\", \"company\", \"uom\", \"quantity\", \"cb0\", \"is_active\", \"is_default\", \"allow_alternative_item\", \"is_subcontracted\", \"set_rate_of_sub_assembly_item_based_on_bom\", null, \"project\", \"image\", \"currency_detail\", \"rm_cost_as_per\", \"buying_price_list\", \"price_list_currency\", \"plc_conversion_rate\", \"column_break_ivyw\", \"currency\", \"conversion_rate\", \"materials_section\", \"items\", \"section_break_21\", \"operations_section_section\", \"with_operations\", \"column_break_23\", \"transfer_material_against\", \"routing\", \"fg_based_operating_cost\", \"fg_based_section_section\", \"operating_cost_per_bom_quantity\", \"operations_section\", \"operations\", \"scrap_section\", \"scrap_items_section\", \"scrap_items\", \"process_loss_section\", \"process_loss_percentage\", \"column_break_ssj2\", \"process_loss_qty\", \"costing\", \"operating_cost\", \"raw_material_cost\", \"scrap_material_cost\", \"cb1\", \"base_operating_cost\", \"base_raw_material_cost\", \"base_scrap_material_cost\", \"column_break_26\", \"total_cost\", \"base_total_cost\", \"more_info_tab\", \"item_name\", \"description\", \"column_break_27\", \"has_variants\", \"quality_inspection_section_break\", \"inspection_required\", \"column_break_dxp7\", \"quality_inspection_template\", \"section_break0\", \"exploded_items\", \"website_section\", \"show_in_website\", \"route\", \"column_break_52\", \"website_image\", \"thumbnail\", \"sb_web_spec\", \"show_items\", \"show_operations\", \"web_long_description\", \"amended_from\", \"connections_tab\"]" + } + ], + "sync_on_migrate": 1 } \ No newline at end of file diff --git a/inventory_tools/inventory_tools/doctype/inventory_tools_settings/inventory_tools_settings.json b/inventory_tools/inventory_tools/doctype/inventory_tools_settings/inventory_tools_settings.json index db3a6f4..5c84509 100644 --- a/inventory_tools/inventory_tools/doctype/inventory_tools_settings/inventory_tools_settings.json +++ b/inventory_tools/inventory_tools/doctype/inventory_tools_settings/inventory_tools_settings.json @@ -15,6 +15,8 @@ "work_order_subcontracting_section", "enable_work_order_subcontracting", "create_purchase_orders", + "bom_column", + "create_job_cards_automatically", "section_break_0", "update_warehouse_path", "section_break_gzcbr", @@ -94,12 +96,23 @@ "fieldname": "enforce_uoms", "fieldtype": "Check", "label": "Enforce UOMs" + }, + { + "fieldname": "bom_column", + "fieldtype": "Section Break", + "label": "Work Order" + }, + { + "default": "Yes", + "fieldname": "create_job_cards_automatically", + "fieldtype": "Select", + "label": "Create Job Card(s) Automatically", + "options": "Yes\nNo" } ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-08-09 20:12:09.274841", - + "modified": "2024-01-09 18:12:20.714002", "modified_by": "Administrator", "module": "Inventory Tools", "name": "Inventory Tools Settings", diff --git a/inventory_tools/inventory_tools/overrides/work_order.py b/inventory_tools/inventory_tools/overrides/work_order.py index 4b4bbc9..92f7a52 100644 --- a/inventory_tools/inventory_tools/overrides/work_order.py +++ b/inventory_tools/inventory_tools/overrides/work_order.py @@ -78,6 +78,19 @@ def on_cancel_remove_wo_from_po(self): indicator="green", ) + def create_job_card(self): + create_job_cards_automatically = ( + frappe.db.get_value("BOM", self.bom_no, "create_job_cards_automatically") + or frappe.db.get_value( + "Inventory Tools Settings", {"company": self.company}, "create_job_cards_automatically" + ) + or "Yes" + ) + + if create_job_cards_automatically == "No": + return + return super().create_job_card() + @frappe.whitelist() def make_subcontracted_purchase_order(wo_name, supplier=None): From 5244ba17dc7a500057c53502ea2e185550de7a3f Mon Sep 17 00:00:00 2001 From: fproldan Date: Tue, 9 Jan 2024 20:08:51 -0300 Subject: [PATCH 2/2] feat: configurable creation of job card --- .../inventory_tools/custom/bom.json | 26 +------------------ 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/inventory_tools/inventory_tools/custom/bom.json b/inventory_tools/inventory_tools/custom/bom.json index cfb6f0a..95f85f0 100644 --- a/inventory_tools/inventory_tools/custom/bom.json +++ b/inventory_tools/inventory_tools/custom/bom.json @@ -126,30 +126,6 @@ "custom_perms": [], "doctype": "BOM", "links": [], - "property_setters": [ - { - "_assign": null, - "_comments": null, - "_liked_by": null, - "_user_tags": null, - "creation": "2024-01-09 12:01:11.525984", - "default_value": null, - "doc_type": "BOM", - "docstatus": 0, - "doctype_or_field": "DocType", - "field_name": null, - "idx": 0, - "is_system_generated": 0, - "modified": "2024-01-09 12:01:11.525984", - "modified_by": "Administrator", - "module": "Inventory Tools", - "name": "BOM-main-field_order", - "owner": "Administrator", - "property": "field_order", - "property_type": "Data", - "row_name": null, - "value": "[\"production_item_tab\", \"item\", \"company\", \"uom\", \"quantity\", \"cb0\", \"is_active\", \"is_default\", \"allow_alternative_item\", \"is_subcontracted\", \"set_rate_of_sub_assembly_item_based_on_bom\", null, \"project\", \"image\", \"currency_detail\", \"rm_cost_as_per\", \"buying_price_list\", \"price_list_currency\", \"plc_conversion_rate\", \"column_break_ivyw\", \"currency\", \"conversion_rate\", \"materials_section\", \"items\", \"section_break_21\", \"operations_section_section\", \"with_operations\", \"column_break_23\", \"transfer_material_against\", \"routing\", \"fg_based_operating_cost\", \"fg_based_section_section\", \"operating_cost_per_bom_quantity\", \"operations_section\", \"operations\", \"scrap_section\", \"scrap_items_section\", \"scrap_items\", \"process_loss_section\", \"process_loss_percentage\", \"column_break_ssj2\", \"process_loss_qty\", \"costing\", \"operating_cost\", \"raw_material_cost\", \"scrap_material_cost\", \"cb1\", \"base_operating_cost\", \"base_raw_material_cost\", \"base_scrap_material_cost\", \"column_break_26\", \"total_cost\", \"base_total_cost\", \"more_info_tab\", \"item_name\", \"description\", \"column_break_27\", \"has_variants\", \"quality_inspection_section_break\", \"inspection_required\", \"column_break_dxp7\", \"quality_inspection_template\", \"section_break0\", \"exploded_items\", \"website_section\", \"show_in_website\", \"route\", \"column_break_52\", \"website_image\", \"thumbnail\", \"sb_web_spec\", \"show_items\", \"show_operations\", \"web_long_description\", \"amended_from\", \"connections_tab\"]" - } - ], + "property_setters": [], "sync_on_migrate": 1 } \ No newline at end of file