Skip to content

[FIX] pos_order_to_sale_order: hook _pre_confirm_from_pos previo a ac…#1580

Draft
Pablocce wants to merge 1 commit into
OCA:16.0from
factorlibre:16.0-imp-pos_order_to_sale_order-pre_confirm_hook
Draft

[FIX] pos_order_to_sale_order: hook _pre_confirm_from_pos previo a ac…#1580
Pablocce wants to merge 1 commit into
OCA:16.0from
factorlibre:16.0-imp-pos_order_to_sale_order-pre_confirm_hook

Conversation

@Pablocce

@Pablocce Pablocce commented Jul 10, 2026

Copy link
Copy Markdown

Summary

Adds a no-op extension hook, _pre_confirm_from_pos(order_data), called
from create_order_from_pos right before action_confirm() is invoked
(only when the order is actually going to be confirmed).

Motivation

create_order_from_pos creates, confirms, delivers and invoices the sale
order in a single call, with no seam between "create" and "confirm". Any
downstream module that needs to prepare the order (e.g. auto-assign a
delivery carrier or warehouse) before it is confirmed currently has no
way to do so other than embedding that logic inside its own
action_confirm() override.

That is fragile: if any other module patches action_confirm via
_patch_method (a common pattern for global exception/validation checks),
the patch wraps the already-merged MRO chain and runs before any
_inherit-based override gets a chance to run — including the one doing
the carrier/warehouse assignment. The order can then get stuck without a
carrier and, in a programmatic context like POS order creation, fail to
confirm silently.

This hook gives downstream modules a proper place to run that kind of
preparation logic strictly before action_confirm() is ever invoked from
this flow, without having to touch — or race against — whatever patches
action_confirm itself.

Changes

  • pos_order_to_sale_order/models/sale_order.py: new no-op
    _pre_confirm_from_pos method, called from create_order_from_pos.

No existing behavior changes — the hook is a no-op unless a downstream
module overrides it.

Testing

  • Existing test suite (test_module.py tour, test_sale_order.py) run
    unmodified against a fresh test database; no regressions introduced by
    this change.
  • A downstream module (internal, not part of this PR) exercises the hook
    by overriding it to assign a delivery carrier before confirmation, with
    its own dedicated unit tests.

…tion_confirm

Añade un punto de enganche no-op en create_order_from_pos, justo antes
de confirmar el pedido, para que módulos de extensión (p. ej. los
omnicanal de TPV) puedan asignar transportista/almacén con el pedido
todavía en borrador.

Sin este hook, esa asignación solo podía vivir dentro de action_confirm(),
donde queda a merced de cualquier _patch_method que intercepte el método
antes de la cadena de herencia normal (p. ej. sale_exceptions_priority,
que evalúa excepciones con el pedido todavía sin carrier y bloquea la
confirmación en silencio en contexto programático).

Ref odoo-16/fl-v16#9646
Ref odoo-16/mas-musculo#834
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hi @legalsylvain,
some modules you are maintaining are being modified, check this out!

@OCA-git-bot OCA-git-bot added series:16.0 mod:pos_order_to_sale_order Module pos_order_to_sale_order labels Jul 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:pos_order_to_sale_order Module pos_order_to_sale_order series:16.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants