diff --git a/inventory_tools/inventory_tools/custom/bom.json b/inventory_tools/inventory_tools/custom/bom.json index 89f5b24..95f85f0 100644 --- a/inventory_tools/inventory_tools/custom/bom.json +++ b/inventory_tools/inventory_tools/custom/bom.json @@ -1,69 +1,131 @@ { - "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": [], + "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):