Skip to content

Conversation

@peregrine-2024
Copy link

: This PR addresses ticket #64717 by fixing the phantom kit availability calculation in the BoM Overview screen. The issue was that phantom kits were not properly aggregating the worst-case availability date from their components. The fix overrides the availability computation in the BoM model to ensure phantom kits calculate their availability based on the maximum expected date of their components, providing accurate availability dates when components are fully reserved. This ensures that kit lines display the latest expected date among their components rather than incorrectly using other date calculations. Technical implementation involves overriding the compute method in the BoM model to properly handle phantom kit scenarios while maintaining existing functionality for regular BOMs.

Implemented solution using Cursor CLI automation
@peregrine-2024
Copy link
Author

🛠️ Automated Fix: Phantom Kit Availability Aggregation

This pull request addresses ticket #64717 — a bug where phantom kit availability in the BoM structure report was not correctly aggregating the worst-case (latest) expected delivery date from its components.

✅ Changes Overview

  • New File Added:
    ol_mrp/models/mrp_report_bom_structure.py

    • Introduces a new model ReportBomStructure that inherits from report.mrp.report_bom_structure.
    • Overrides _get_report_data() to intercept and correct phantom kit availability logic.
    • Adds helper methods to recursively process nested phantom kits and compute the latest expected date across components.
  • File Modified:
    ol_mrp/models/__init__.py

    • Imports the newly added mrp_report_bom_structure module to make it available in the module.

🔧 Technical Details

Key Methods Implemented:
  • _get_report_data(): Overrides the base method to inject custom logic for handling phantom kits.
  • _process_phantom_kits_in_components(): Recursively processes phantom kits within components to ensure nested kits are also handled.
  • _update_phantom_kit_availability(): Computes the worst-case expected date from child components and updates the phantom kit’s availability fields (expected_date, availability_date, availability_state).
  • _parse_date(): Utility function to safely parse date strings into datetime objects for comparison.
Logic Fixes:
  • When a phantom kit contains fully reserved or expected-date components, the kit itself now reflects the latest expected delivery date among those components.
  • Prevents infinite recursion by using a context flag (skip_phantom_kit_processing) during nested BOM lookups.
  • Ensures that even deeply nested phantom kits are processed correctly.

🧪 Testing & Review Notes

  • Ensure that BoM reports with phantom kits behave correctly under various scenarios:
    • Fully reserved components
    • Mixed availability states
    • Nested phantom kits
  • Verify that non-phantom kits remain unaffected.
  • Test edge cases such as missing dates or invalid date formats.

This change ensures accurate representation of kit availability in the BoM overview, aligning behavior with user expectations described in the original ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants