Skip to content

[18.0][ADD] pos_order_line_change_variant: change the variant of an existin… - #1598

Open
cvinh wants to merge 1 commit into
OCA:18.0from
invitu:18.0-add_pos_order_line_change_variant
Open

cvinh wants to merge 1 commit into
OCA:18.0from
invitu:18.0-add_pos_order_line_change_variant

Conversation

@cvinh

@cvinh cvinh commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

…g order line

In standard Point of Sale, once a product with variants has been added to the cart, there is no way to switch it to a different variant: the line has to be removed and the new variant re-added as a separate line. Clicking a cart line only lets you edit quantity, discount or price through the numpad; double-clicking a line currently does nothing beyond cancelling the line's pending auto-deselection timeout (OrderSummary.clickLine, ev.detail === 2 branch), so this event was free to repurpose.

This module lets the user double-click a cart line whose product is configurable (product.isConfigurable()) to reopen the variant configurator, pre-filled with the line's current attribute values, and apply the newly picked variant on that same line instead of creating a new one.

PosStore.changeOrderlineVariant(line) reuses the same variant resolution logic addLineToOrder already uses when adding a configurable product (matching product_template_variant_value_ids against the confirmed attribute_value_ids), then updates the line's product_id, attribute_value_ids, custom_attribute_value_ids, price_extra, unit price and full product name in place.

The change is refused, with an explanatory dialog, when:

  • the line already has lot/serial numbers assigned, since changing the product could invalidate them;
  • another line in the order already uses the target variant, to avoid having to silently merge two lines.

A Python HttpCase + tour test covers the full flow: add a variant, add it to the cart, double-click the line, switch to another variant, check the line was updated in place rather than duplicated.

Assisted-by: Claude (Anthropic)

@OCA-git-bot OCA-git-bot added series:18.0 mod:pos_order_line_change_variant Module pos_order_line_change_variant labels Aug 18, 2026
@cvinh
cvinh force-pushed the 18.0-add_pos_order_line_change_variant branch from 8600b11 to 099e785 Compare August 18, 2026 20:05
@cvinh
cvinh marked this pull request as draft August 18, 2026 20:14
@cvinh
cvinh force-pushed the 18.0-add_pos_order_line_change_variant branch 4 times, most recently from b4664b0 to 8b6a52d Compare August 20, 2026 20:26
@cvinh

cvinh commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

tests fail because of pos_user_restriction

…g order line

Lets the user click an already-selected cart line whose product is
configurable a second time to reopen the variant configurator,
pre-filled with the line's current attribute selection.

PosStore.changeOrderlineVariant(line) reuses the same variant
resolution logic addLineToOrder already uses when adding a
configurable product, then:
- splits off the confirmed unit onto its own line first when the
  line's quantity is more than 1, so only that unit is affected;
- updates the line in place if it was never sent to the kitchen
  printer, or removes it and adds a fresh line with the new variant
  otherwise, so the change is correctly reported to the kitchen as a
  cancellation and a new addition. Note, customer note and discount
  are carried over when a line is split or replaced.

Pre-filling covers every attribute type: values that define a real
variant, no_variant/custom values on the line, and multi-select
values, via a defaultValues.multi sub-key and a MultiProductAttribute
patch (core never passes defaultValues to that component at all).

The change is refused, with an explanatory dialog, when the line
already has lot/serial numbers assigned.

A Python HttpCase + tour test covers the full flow: add a variant to
the cart, select the line, click it again, switch to another variant,
check the line was updated in place rather than duplicated.

Assisted-by: Claude (Anthropic)
@cvinh
cvinh force-pushed the 18.0-add_pos_order_line_change_variant branch from 8b6a52d to 2518060 Compare August 24, 2026 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:pos_order_line_change_variant Module pos_order_line_change_variant series:18.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants