Skip to content

[ADD] sale_kit_management: sale kit product management and order configurator#1319

Open
times-odoo wants to merge 5 commits into
odoo:19.0from
odoo-dev:19.0-add-sale_kit_management-times
Open

[ADD] sale_kit_management: sale kit product management and order configurator#1319
times-odoo wants to merge 5 commits into
odoo:19.0from
odoo-dev:19.0-add-sale_kit_management-times

Conversation

@times-odoo
Copy link
Copy Markdown

@times-odoo times-odoo commented Jun 3, 2026

Introduce a complete Sale Kit Management system that enables grouping sub-products into single items, calculates bundle prices dynamically, and configures kit structures on sales order lines with full reconfiguration support.

The implementation covers:

  • Dynamic Bundle Pricing & Validation: Integrates a custom sub-product line architecture inside product templates. It tracks product bundle details natively and handles dynamic cost roll-ups seamlessly via backend calculation utilities.
  • Reconfigurable Exploded Kit Wizard: Adds an interactive configuration wizard to the quotation workflow. It allows users to continuously reconfigure previously exploded kits by purging stale child structures and cleanly overriding item matrices without duplicating records.
  • Strict Structural Deletion Controls: Employs backend @api.ondelete validation hooks to prevent disjointed mutations. Users cannot strip individual child subproduct items directly from an active list layout unless the parent bundle target or the surrounding structural layout section is unlinked collectively.
  • Isolated Sequencing Boundaries: Enforces strict layout integrity by routing exploded bundle sections into specific, high-index sequence intervals. This approach effectively prevents layout overlaps when users manually drag and reorder regular catalog items later.
  • Derived Visual Mapping: Ensures clear client communications by formatting nested line items with zero-value unit pricing and locking down template visibility properties dynamically with protective, read-only constraints.

Task Reference: 6268133

…ent and order configurator

Implemented a product kit architecture allowing users to bundle sub-products,
dynamically compute bundle pricing, and explode kit selections into sale orders.

Rationale:
Sales teams need a flexible mechanism to sell multi-component product bundles
(kits) without manually tracking constituent items or distorting unit pricing
structures. This module addresses that by introducing a kit layout toggle on
products, establishing automatic cost roll-ups based on child line assignments,
and integrating an interactive configuration wizard inside the sales quotation
interface to generate dependent order lines dynamically.

Technical choices:
- Created 'product.subproduct.line' and 'sale.order.kit.config.line' models
  to store static templates and active configuration states respectively.
- Overrode CRUD operations on subproduct lines to automatically recompute bundle
  prices using aggregate methods ('_compute_kit_list_price').
- Inherited 'sale.order.line' to establish tree cascading links ('kit_parent_line_id')
  and overrode 'write' and 'unlink' to mirror quantity scale changes or handle
  recursive removal adjustments automatically.
- Designed a 'sale.order.kit' configuration wizard using 'default_get' to preload
  kit architectures and inject exploded subproduct items as discrete, protected,
  muted rows contextually attached beneath a section header block.
- Applied multi-level list restrictions inside view templates using column-invisible
  and read-only flags to block explicit manual overrides of derived child row values.

Task Reference: 6268133
@robodoo
Copy link
Copy Markdown

robodoo commented Jun 3, 2026

Pull request status dashboard

@times-odoo times-odoo changed the title [ADD] sale_kit_management: introduce dynamic sale kit product managem… [ADD] sale_kit_management: sale kit product management and order configurator Jun 3, 2026
@times-odoo times-odoo requested a review from mash-odoo June 3, 2026 09:27
…subproduct line unlinking edge cases

Optimized the kit pricing lifecycle and added recursive recalculation logic
when individual kit subproduct lines are unlinked from a sales order.

Rationale:
The pricing engine needed to be more robust against manual user interventions.
If a user unlinks a child subproduct line directly from the sales order view,
the parent kit line must dynamically lower its 'price_unit' to match the
remaining components. Additionally, if all exploded components are removed,
the system now purges the orphaned section header and resets the parent's unit
price back to its standard standalone catalog fallback value ('lst_price').

Technical choices:
- Converted 'price_unit' in 'product.subproduct.line' to a computed, stored field
  to allow optional manual overrides during initial bundle definitions.
- Renamed and streamlined '_compute_kit_list_price' into a dedicated context
  recalculation method '_recompute_kit_list_price' to decouple it from strict
  api.depends evaluation traps.
- Rewrote 'unlink' in 'sale.order.line' to cleanly capture unlinked child rows,
  re-sum remaining sibling records using aggregate methods, and clear detached
  'line_section' rows when the kit's subproduct array goes blank.
- Streamlined 'default_get' inside 'sale.order.kit' by consolidating the logic
  to rely exclusively on 'default_sale_order_line_id' from the context.
- Cleaned up trailing spaces and redundant configuration line re-creations inside
  the wizard's 'action_add_to_sol' invocation thread.
@times-odoo times-odoo force-pushed the 19.0-add-sale_kit_management-times branch from 1554442 to 3e7f312 Compare June 4, 2026 05:09
…ated sequence bases for kit explosion

Refactored the kit breakdown lifecycle using modern Odoo deletion hooks and
introduced a isolated sequencing threshold to safeguard line visual hierarchy.

Rationale:
Relying entirely on overriding the standard 'unlink' model method is fragile
because backend system cleanups or automated actions can pass pre-filtered or
mutated recordsets, leading to execution gaps. Migrating this cleanup logic to
'@api.ondelete' methods ensures consistent performance. Additionally, exploding
subproducts immediately using arbitrary incremental logic ('sequence + 1')
frequently breaks if a user later rearranges regular line items. Isolating all
exploded components above a high-value sequence base index prevents collision errors.

Technical choices:
- Replaced standard 'unlink' method overrides in 'ProductSubproductLine' and
  'SaleOrderLine' with optimized '@api.ondelete(at_uninstall=False)' hook decorators.
- Introduced a computed, stored 'amount' field to tracking line totals in the backend.
- Declared '_KIT_SUBPRODUCT_SEQ_BASE' to safely gate explode rows away from core lines.
- Updated the wizard creation payload to insulate sequence positioning dynamically using
  the current count of existing exploded kit section layouts.
- Overrode 'create' in 'SaleOrderLine' to dynamically scale down any regular, non-kit
  item values targeting indices past the dedicated subproduct barrier.
@times-odoo times-odoo force-pushed the 19.0-add-sale_kit_management-times branch from 3e7f312 to c86a3ed Compare June 4, 2026 05:51
…subproduct lines and fix child row pricing

Restructured the kit line deletion safeguards by forcing contextual removal
dependencies and initializing zero-value unit pricing for exploded items.

Rationale:
Allowing users to selectively delete individual child subproduct lines
directly from the sale order lines list view compromises data integrity and
desynchronizes the parent kit's computed pricing. To guarantee business flow
consistency, the system now validates that subproduct lines can only be
removed if their corresponding parent kit product or their entire structural
enclosing section layout is targeted in the same batch deletion. Additionally,
ensuring that exploded child rows have their 'price_unit' forced to zero blocks
duplicate pricing visibility issues inside client quotes.

Technical choices:
- Integrated a strict batch lookup inside the '@api.ondelete' method of
  'SaleOrderLine' to catch standalone subproduct row removals.
- Added a validation trigger that throws a 'UserError' message when independent
  child subproduct unlinking patterns are detected.
- Modified 'write' operations to force child component unit values to zero
  upon initial quantity matrix redistribution calculations.
- Enforced a safety boundary condition ('id not in self.ids') during batch
  child lookup workflows to prevent recursive search traps.
- Injected conditional 'readonly' visibility control over the
  'product_template_id' list field attribute inside inherited layout records.
@times-odoo times-odoo force-pushed the 19.0-add-sale_kit_management-times branch 4 times, most recently from 63c1115 to 8a38e1c Compare June 4, 2026 09:31
… lines clean rewrite

Updated the kit configurator layout and wizard actions to support multiple
reconfigurations of an already exploded sales order kit.

Rationale:
Previously, the kit configuration button vanished once sub-products were
exploded onto the sales order lines. This prevented users from correcting
or modifying a kit component bundle after adding it. By keeping the button
visible for all kit templates and adding an explicit cleanup search block
prior to line generation, the wizard now smoothly purges stale child records
and cleanly rewrites both the runtime configuration values and exploded lines.

Technical choices:
- Adjusted the XML list view button xpath, dropping 'has_kit_subproducts'
  from the 'invisible' restriction attribute.
- Re-introduced the baseline population mapping routine for the
  'sale.order.kit.config.line' context table during final submission.
- Added a pre-generation sweep query against 'sale.order.line' to isolate
  and drop any stale exploded subproduct elements previously linked to the parent.
@times-odoo times-odoo force-pushed the 19.0-add-sale_kit_management-times branch from 8a38e1c to e6b6243 Compare June 4, 2026 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants