T-MINUS scan report
Target upgrade: v15 → v16
Application: precision_mass
Files scanned: 948

Result: ACTION REQUIRED
Findings: 27 error, 1 warning, 16 info

What to do next:
  1. Resolve Errors before an upgrade rehearsal.
  2. Review Warnings before migrating.
  3. Review Information findings for behavior changes.

This is a static scan. Confirm changes on a restored copy before upgrading
production.

Errors (27)
  These findings are likely to break on v16.
  1. frappe.db.commit() inside a doc_events hook (11 location(s))
     Status: ACTION REQUIRED • Rule: v16-db-commit-in-doc-events • [silent, T-30]
     Why it matters: A function registered in doc_events calls frappe.db.commit(). v16 turns transaction control off while document hooks run, so the commit only prints a warning and is ignored. Anything the code relied on being saved at that point stays in the open transaction and is rolled back if the request fails later.
     Suggested action: Remove the commit and let the request commit at the end. If the data must survive a failure, write it in a separate background job (frappe.enqueue).
     Affected locations:
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/apis/job_card.py:302
         Code: frappe.db.commit()
         Technical context: doc_events["Job Card"]["before_submit"] -> precision_mass.apis.job_card.on_submit (hooks.py:276)
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/apis/lead.py:48
         Code: frappe.db.commit()
         Technical context: doc_events["Sales Order"]["after_insert"] -> precision_mass.apis.lead.update_lead_status_on_order_creation (hooks.py:245)
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/apis/purchase_order.py:250
         Code: frappe.db.commit()
         Technical context: doc_events["Purchase Order"]["after_insert"] -> precision_mass.apis.purchase_order.after_insert (hooks.py:288)
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/apis/purchase_order.py:256
         Code: frappe.db.commit()
         Technical context: doc_events["Purchase Order"]["on_submit"] -> precision_mass.apis.purchase_order.on_submit (hooks.py:289)
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/apis/sales_order.py:1393
         Code: frappe.db.commit()
         Technical context: doc_events["Sales Order"]["on_submit"] -> precision_mass.apis.sales_order.create_project (hooks.py:238)
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/apis/sales_order.py:2457
         Code: frappe.db.commit()
         Technical context: doc_events["Sales Order"]["on_update_after_submit"] -> precision_mass.apis.sales_order.cancellation_of_unwanted_custom_dial_design (hooks.py:248)
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/apis/sales_order.py:2464
         Code: frappe.db.commit()
         Technical context: doc_events["Sales Order"]["on_update_after_submit"] -> precision_mass.apis.sales_order.cancellation_of_unwanted_custom_dial_design (hooks.py:248)
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/apis/sales_order.py:2478
         Code: frappe.db.commit()
         Technical context: doc_events["Sales Order"]["on_update_after_submit"] -> precision_mass.apis.sales_order.cancellation_of_unwanted_custom_dial_design (hooks.py:248)
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/apis/sales_order.py:2484
         Code: frappe.db.commit()
         Technical context: doc_events["Sales Order"]["on_update_after_submit"] -> precision_mass.apis.sales_order.cancellation_of_unwanted_custom_dial_design (hooks.py:248)
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/apis/stock_entry.py:3383
         Code: frappe.db.commit()
         Technical context: doc_events["Stock Entry"]["on_submit"] -> precision_mass.apis.stock_entry.on_submit (hooks.py:277)
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/precision_mass/doctype/sales_coordinator/sales_coordinator.py:19
         Code: frappe.db.commit()
         Technical context: doc_events["Sales Person"]["after_insert"] -> precision_mass.precision_mass.doctype.sales_coordinator.sales_coordinator.create_user_permission (hooks.py:309)
  2. get_item_tax_map is keyword-only and takes the document (2 location(s))
     Status: ACTION REQUIRED • Rule: v16-erpnext-get-item-tax-map-keyword-only • [quiet, T-30]
     Why it matters: v15 called get_item_tax_map(company, item_tax_template). In v16 the signature is get_item_tax_map(*, doc, tax_template=None, as_json=True), so any positional argument raises TypeError.
     Suggested action: Call get_item_tax_map(doc=<the document>, tax_template=<template>). The first argument is now the whole document (its company is read from it), not the company name.
     Affected locations:
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/apis/sales_order.py:1794
         Code: child_item.item_tax_rate = get_item_tax_map(
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/overrides/price_list_rate.py:79
         Code: out["item_tax_rate"] = get_item_tax_map(
  3. ERPNext fields removed, renamed or moved in v16 (3 location(s))
     Status: ACTION REQUIRED • Rule: v16-erpnext-removed-or-renamed-fields • [quiet, T-30]
     Why it matters: A field that no longer exists on this DocType in v16 is read, filtered on or written. Reading it can fail with an unknown-field error or quietly return nothing. The detail line says what replaced it.
     Suggested action: Use the replacement named in the detail line. Where it only says removed, read the v16 DocType and port the logic; do not redesign it.
     Affected locations:
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/apis/stock_entry.py:2609
         Code: frappe.db.get_single_value("Manufacturing Settings", "set_op_cost_and_scrap_from_sub_assemblies")
         Technical context: Manufacturing Settings.set_op_cost_and_scrap_from_sub_assemblies: renamed to set_op_cost_and_secondary_items_from_sub_assemblies
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/precision_mass/report/opportunity_analysis/opportunity_analysis.py:79
         Code: O.source,
         Technical context: Opportunity.source: replaced by utm_source; no migration patch copies the old value, so copy existing data yourself  [found in SQL text: check that the column belongs to this table]
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/precision_mass/report/opportunity_analysis/opportunity_analysis.py:92
         Code: O.campaign,
         Technical context: Opportunity.campaign: replaced by utm_campaign; no migration patch copies the old value, so copy existing data yourself  [found in SQL text: check that the column belongs to this table]
  4. Frappe framework fields removed in v16 (6 location(s))
     Status: ACTION REQUIRED • Rule: v16-frappe-removed-fields • [quiet, T-30]
     Why it matters: A field that no longer exists on this DocType in v16 is read, filtered on or written. Reading it can fail with an unknown-field error or quietly return nothing. The detail line says what replaced it.
     Suggested action: Use the replacement named in the detail line. Where it only says removed, read the v16 DocType and port the logic; do not redesign it.
     Affected locations:
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/migrate/after_migrate.py:96
         Code: current_total = str(doc.total_fields or "")
         Technical context: List View Settings.total_fields: removed in v16 (no replacement found in the migration patches)
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/migrate/after_migrate.py:98
         Code: doc.total_fields = str(len(fields))
         Technical context: List View Settings.total_fields: removed in v16 (no replacement found in the migration patches)
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/migrate/after_migrate.py:147
         Code: current_total = str(doc.total_fields or "")
         Technical context: List View Settings.total_fields: removed in v16 (no replacement found in the migration patches)
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/migrate/after_migrate.py:149
         Code: doc.total_fields = str(len(fields))
         Technical context: List View Settings.total_fields: removed in v16 (no replacement found in the migration patches)
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/migrate/after_migrate.py:218
         Code: current_total = str(doc.total_fields or "")
         Technical context: List View Settings.total_fields: removed in v16 (no replacement found in the migration patches)
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/migrate/after_migrate.py:220
         Code: doc.total_fields = str(len(fields))
         Technical context: List View Settings.total_fields: removed in v16 (no replacement found in the migration patches)
  5. SQL written as a string in get_all / get_list fields or filters (4 location(s))
     Status: ACTION REQUIRED • Rule: v16-get-all-sql-strings • [quiet, T-30]
     Why it matters: frappe.get_all / get_list in v16 accept only plain field names in `fields` and plain field names as filter keys. SQL written as a string (sum(x) as y, distinct x, ifnull(...), a quoted literal) raises a ValidationError when the query runs.
     Suggested action: Use the dict syntax for SQL functions, for example {"COUNT": "*"}, or frappe.qb for a complex query. In filters, filter on a plain field name.
     Affected locations:
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/apis/stock_entry.py:2265
         Code: "sum(`tabStock Entry Detail`.qty) as qty",
         Technical context: fields "sum(`tabStock Entry Detail`.qty) as qty": SQL functions are not allowed as strings in SELECT; use dict syntax such as {'COUNT': '*'}
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/apis/stock_entry.py:2266
         Code: "sum(`tabStock Entry Detail`.transfer_qty) as transfer_qty",
         Technical context: fields "sum(`tabStock Entry Detail`.transfer_qty) as transfer_qty": SQL functions are not allowed as strings in SELECT; use dict syntax such as {'COUNT': '*'}
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/apis/stock_entry.py:2429
         Code: fields=["max(process_loss_qty) as process_loss_qty"],
         Technical context: fields "max(process_loss_qty) as process_loss_qty": SQL functions are not allowed as strings in SELECT; use dict syntax such as {'COUNT': '*'}
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/apis/stock_entry.py:3209
         Code: fields=["sum(transfer_qty) as qty"],
         Technical context: fields "sum(transfer_qty) as qty": SQL functions are not allowed as strings in SELECT; use dict syntax such as {'COUNT': '*'}
  6. DocTypes removed in v16 (1 location(s))
     Status: ACTION REQUIRED • Rule: v16-removed-doctypes • [quiet, T-30]
     Why it matters: A DocType that no longer exists in v16 is passed to a Frappe API (get_doc, get_all, db.get_value, qb.DocType, ...) or used in a dict with a "doctype" key. The code keeps working until someone opens that form or runs that code path. If the DocType moved to a separate app, this is fine as long as that app is installed on the v16 bench.
     Suggested action: Use the replacement named in the detail line, or install the separate app and suppress the finding with a tminus ignore comment.
     Affected locations:
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/apis/stock_entry.py:2660
         Code: job_card_scrap_item = frappe.qb.DocType("Job Card Scrap Item")
         Technical context: Job Card Scrap Item: replaced by Job Card Secondary Item (secondary_item_type 'Scrap')

Warnings (1)
  These findings need a developer's review.
  1. App does not declare which frappe versions it supports (1 location(s))
     Status: REVIEW REQUIRED • Rule: v16-app-frappe-bound-missing • [quiet, T-30]
     Why it matters: The app has no [tool.bench.frappe-dependencies] frappe entry in pyproject.toml. bench prints 'Required frappe version not set in pyproject.toml' and cannot stop the app from being installed on a frappe version it does not support.
     Suggested action: Add to pyproject.toml on the version-16 branch: [tool.bench.frappe-dependencies] with frappe = ">=16.0.0,<17.0.0".
     Affected locations:
       - /home/dev01/frappe-bench/apps/precision_mass/pyproject.toml:1
         Code: [project]
         Technical context: precision_mass: no [tool.bench.frappe-dependencies] frappe bound

Information (16)
  These findings may change behavior without an error.
  1. First or last row taken from a query without order_by (16 location(s))
     Status: BEHAVIOR REVIEW • Rule: v16-first-row-without-order-by • [silent, T-30]
     Why it matters: The first or last row of a get_all/get_list result is used ([0], [-1] or limit 1) and the query has no order_by. v15 sorted by modified when no order was given and v16 sorts by creation, so "the latest record" logic can return a different row. Nothing raises an error. Review each finding: it only matters when more than one row can match.
     Suggested action: Add an explicit order_by (for example order_by="creation desc") so the result does not depend on the default order.
     Affected locations:
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/apis/batch.py:108
         Code: min_max_values = frappe.db.get_all("Mechnical Property Hardness", {"parenttype": "Material Grade", "parent": grade, "unit": unit}, ["min", "max"], limit=1) or []
         Technical context: Mechnical Property Hardness: only one row is requested (limit 1) without order_by
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/apis/stock_entry.py:2168
         Code: ret["subcontracted_item"] = subcontract_items[0].main_item_code
         Technical context: ?: the first/last row is used without order_by
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/apis/stock_entry.py:2432
         Code: if data and data[0].process_loss_qty is not None:
         Technical context: Work Order Operation: the first/last row is used without order_by
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/apis/stock_entry.py:2433
         Code: process_loss_qty = data[0].process_loss_qty
         Technical context: Work Order Operation: the first/last row is used without order_by
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/apis/stock_entry.py:3220
         Code: if transferred_qty and transferred_qty[0]:
         Technical context: Stock Entry Detail: the first/last row is used without order_by
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/apis/stock_entry.py:3221
         Code: if transferred_qty[0].qty > transfer_qty:
         Technical context: Stock Entry Detail: the first/last row is used without order_by
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/apis/stock_entry.py:3229
         Code: transferred_qty[0].qty if transferred_qty and transferred_qty[0] else 0.0
         Technical context: Stock Entry Detail: the first/last row is used without order_by
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/precision_mass/doctype/assisted_material_planning/assisted_material_planning.py:161
         Code: bin_item["warehouse_reorder_level"] = data[0]["warehouse_reorder_level"] if data else 0
         Technical context: Item Reorder: the first/last row is used without order_by
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/precision_mass/doctype/assisted_material_planning/assisted_material_planning.py:162
         Code: bin_item["warehouse_reorder_qty"] = data[0]["warehouse_reorder_qty"] if data else 0
         Technical context: Item Reorder: the first/last row is used without order_by
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/precision_mass/report/gl_report/gl_report.py:367
         Code: return data[0].reference_name if data else ""
         Technical context: Journal Entry Account: the first/last row is used without order_by
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/whatsapp_apis/create_whatsapp_message_log.py:58
         Code: whatsapp_log = frappe.get_doc("WhatsApp Message Log", duplicate_doc[0].name)
         Technical context: WhatsApp Message Log: the first/last row is used without order_by
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/whatsapp_apis/get_message_history.py:19
         Code: "WhatsApp Message Log", message_log_list[0].name
         Technical context: WhatsApp Message Log: the first/last row is used without order_by
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/whatsapp_interakt/doctype/whatsapp_notification/whatsapp_notification.py:794
         Code: company = frappe.defaults.get_user_default("Company") or frappe.get_all("Company", limit=1)[0].name
         Technical context: Company: only one row is requested (limit 1) without order_by
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/www/balance_confirmation_letter.py:78
         Code: address_link = frappe.get_all(
         Technical context: Dynamic Link: only one row is requested (limit 1) without order_by
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/www/balance_confirmation_letter_pdf.py:78
         Code: address_link = frappe.get_all(
         Technical context: Dynamic Link: only one row is requested (limit 1) without order_by
       - /home/dev01/frappe-bench/apps/precision_mass/precision_mass/www/cash_flow_statement.py:65
         Code: links = frappe.get_all(
         Technical context: Dynamic Link: only one row is requested (limit 1) without order_by

Summary: 27 error, 1 warning, 16 info
  by stage:    T-30: 27 error, 1 warning, 16 info
  by category: 17 quiet, 27 silent

Not checked:
  - Static checks only: Python, JavaScript, Print Format templates, hooks, SQL text, packaging.
  - Not implemented yet: site data, site-saved code, migrate rehearsal, v15 vs v16 comparison.
