Skip to content

Conversation

@peregrine-2024
Copy link

: Resolves issue where product state incorrectly resets from 'Active' to 'End of Lifecycle' during quote confirmation for SKU NWK200-03. This fix modifies the product template model's lifecycle state enforcement logic to distinguish between user-initiated changes and process-driven modifications, preserving intentional state updates. Addresses ticket #67634 with underlying cause in automated workflow triggering during quote processing. Technical implementation involves adjusting the lifecycle management hooks to maintain state consistency while preserving user intent.

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

🛠️ Automated Fix: Prevent Unwanted Product State Reset During Quoting Process

This pull request addresses Ticket #67634 — a bug where the product state of an SKU (e.g., NWK200-03) was incorrectly reset to "End of Lifecycle" during the quotation process, even after being manually set to "Active".

✅ What Was Actually Implemented

The core issue stemmed from automatic state propagation logic that did not account for manual overrides. To resolve this, we introduced a new module ol_product_state, which provides enhanced control over product lifecycle states and prevents unintended resets during related business operations like quoting.

🔧 Key Changes Overview:
  • New Module Added: ol_product_state

    • Adds support for managing product states via categories and predefined states.
    • Introduces a new field product_state_manually_set to track when a user has intentionally overridden the default behavior.
    • Implements logic in product_template.py to detect and respect manual state changes when updating kits or triggering exceptions.
  • Core Logic Updates in ol_exception/models/product_template.py

    • Enhanced the _fields_trigger_check_exception() method to include dynamic field detection.
    • Modified the write() method to:
      • Detect transitions in product_state_id that may trigger exception checks.
      • Identify toggles in tech_exception.
      • Apply updated logic to propagate kit states while respecting manual overrides.
      • Trigger downstream exception checks on Sale Orders, Delivery Orders, and Manufacturing Orders.
  • Data Definitions

    • New XML data files (data/product_category_data.xml, data/product_state_data.xml) define standard product categories and states including "Active", "End of Lifecycle", etc.
    • These definitions ensure consistent behavior across environments.
  • Security & Views

    • Security group configuration added for fine-grained access control.
    • UI views updated to reflect new fields and allow visibility into product state management.
  • Testing

    • Added unit tests (tests/test_product_state_ol.py) to validate:
      • Manual override detection.
      • Kit state propagation logic.
      • Exception triggering workflows.

📌 How This Fixes the Issue

Previously, when a user changed a product’s state to “Active” for quoting purposes, the system would still reset it back to “End of Lifecycle” due to internal logic that didn’t distinguish between auto-generated and user-initiated updates.

With this change:

  • A new boolean field product_state_manually_set tracks whether a product’s current state was set by a user.
  • When propagating kit states or checking exceptions, the system now skips updates if the current state was manually set.
  • This ensures that intentional state changes persist through the quoting and manufacturing processes.

🧪 Testing & Review Notes

  • All new functionality has been covered by unit tests.
  • Please verify that:
    • Manual state changes are preserved during quoting.
    • Kit state propagation works correctly without unintended resets.
    • Exception workflows continue to function as expected.

⚠️ Ensure that existing data is reviewed for compatibility with the new product_state_manually_set flag and updated accordingly.


Let me know if further clarification or adjustments are needed!

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