[ADD] sale_kit_management: sale kit product management and order configurator#1319
Open
times-odoo wants to merge 5 commits into
Open
[ADD] sale_kit_management: sale kit product management and order configurator#1319times-odoo wants to merge 5 commits into
times-odoo wants to merge 5 commits into
Conversation
…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
…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.
1554442 to
3e7f312
Compare
…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.
3e7f312 to
c86a3ed
Compare
…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.
63c1115 to
8a38e1c
Compare
… 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.
8a38e1c to
e6b6243
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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:
Task Reference: 6268133