Skip to content

[Bug Fix] #638531: Disable Open TO from PO actions on non-subcontracting lines#8752

Draft
ventselartur wants to merge 1 commit into
mainfrom
bugs/638531-SubcontractingOpenPOFromTO
Draft

[Bug Fix] #638531: Disable Open TO from PO actions on non-subcontracting lines#8752
ventselartur wants to merge 1 commit into
mainfrom
bugs/638531-SubcontractingOpenPOFromTO

Conversation

@ventselartur

@ventselartur ventselartur commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Bug Reference

ADO Work item #638531 - [Subcontracting] Open TO from PO action only works from main item line

Summary

The "Open TO from PO" actions on the subcontracting Purchase Order lines (Transfer Order / Return Transfer Order) are now disabled when the current line is not a subcontracting line, instead of appearing enabled but silently doing nothing.

Root Cause

The Transfer Order and Return Transfer Order actions in pageextension 99001524 "Subc. PO Subform" call SubcPurchFactboxMgmt.ShowTransferOrdersAndReturnOrder(Rec, ...), which requires the current purchase line's Prod. Order No. and exit(0)s when it is empty. The enclosing group(Production) was gated only at the document level (Visible = HasSubcontractingContext), never per line. So on a component/non-subcontracting line the actions stayed enabled but did nothing - a usability/discoverability defect.

Changes Made

  • src/Apps/W1/Subcontracting/App/src/Purchase/SubcPOSubform.PageExt.al: Added an OnAfterGetCurrRecord trigger that computes CurrentLineIsSubcontractingLine from Subcontracting Management.IsSubcontractingPurchaseLine(Rec), and set Enabled = CurrentLineIsSubcontractingLine on action("Transfer Order") and action("Return Transfer Order").
  • src/Apps/W1/Subcontracting/Test/Tests/SubcSubcontractingTest.Codeunit.al: Added regression test TransferOrderActionDisabledOnNonSubcontractingPurchaseLine.

Implementation Process

  • Fix iterations: 1
  • Compilation: All projects compile successfully (full al_build, scope=all)
  • Tests: All tests passing

Test Evidence

Pre-Fix Test Results (Baseline)

Run without the fix (deterministic across 3 runs):

FAIL TransferOrderActionDisabledOnNonSubcontractingPurchaseLine
     Assert.IsFalse failed. Transfer Order action must be disabled for a
     non-subcontracting purchase line (no Prod. Order No.).

Post-Fix Test Results (Final)

PASS TransferOrderActionDisabledOnNonSubcontractingPurchaseLine
Test run completed: 3 passed, 0 failed, 0 skipped.

Test Coverage

  • New regression test for work item #638531
  • Action enabled on a subcontracting line (Prod. Order No. set)
  • Action disabled on a non-subcontracting line (no Prod. Order No.) on the same order

Review Notes

The fix relies on the existing internal Subcontracting Management.IsSubcontractingPurchaseLine, which returns true only when Prod. Order No. and Prod. Order Line No. are set.

Generated by the bc-fix-bug skill

Bug #638531: [Subcontracting] Open TO from PO action only works from main item line

Root Cause:
- The "Transfer Order" and "Return Transfer Order" actions in pageextension
  99001524 "Subc. PO Subform" call ShowTransferOrdersAndReturnOrder(Rec, ...),
  which requires the current line's Prod. Order No. and silently exits when it is
  empty. The actions were gated only at document level (Visible =
  HasSubcontractingContext), so on a component/non-subcontracting line they stayed
  enabled but did nothing.

Changes:
- Add OnAfterGetCurrRecord computing CurrentLineIsSubcontractingLine via
  Subcontracting Management.IsSubcontractingPurchaseLine(Rec).
- Set Enabled = CurrentLineIsSubcontractingLine on action("Transfer Order") and
  action("Return Transfer Order") so they are disabled on non-subcontracting lines.

Test Coverage:
- New test TransferOrderActionDisabledOnNonSubcontractingPurchaseLine in codeunit
  139989 asserts the action is enabled on a subcontracting line and disabled on a
  non-subcontracting line on the same order. Verified red without the fix
  (deterministic across 3 runs) and green with the fix.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added the AL: Apps (W1) Add-on apps for W1 label Jun 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Could not find a linked ADO work item. Please link one by using the pattern 'AB#' followed by the relevant work item number. You may use the 'Fixes' keyword to automatically resolve the work item when the pull request is merged. E.g. 'Fixes AB#1234'

@ventselartur ventselartur added the Subcontracting Subcontracting related activities label Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AL: Apps (W1) Add-on apps for W1 Subcontracting Subcontracting related activities

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant