Skip to content

Syncing from upstream OCA/server-tools (18.0) - #2111

Merged
bt-admin merged 3 commits into
brain-tec:18.0from
OCA:18.0
Sep 16, 2026
Merged

bt-admin merged 3 commits into
brain-tec:18.0from
OCA:18.0

Conversation

@bt-admin

Copy link
Copy Markdown

bt_gitbot

sergio-teruel and others added 3 commits September 14, 2026 14:02
…transaction

detect_exceptions() opens a second, genuinely independent DB connection
(self.env.registry.cursor()) to write exception flags so they survive a
rollback of the ongoing transaction. It then re-derived main_records
through that same second connection (self.with_env(new_env)), which
crashes with MissingError whenever _get_main_records() has to read a
field on records created earlier in the SAME ongoing transaction and not
yet committed (e.g. sale.order.line._get_main_records() reading order_id
right after the line was created by write()).

Typical trigger: adding a product to an already confirmed sale order.
sale_exception.write() re-runs detect_exceptions() on order_line whenever
order_line changes on a confirmed order; the new line only exists in the
ongoing transaction, so the second connection can't see it yet.

Resolve main_records once through the original (main) cursor, which does
see the just-created records, and only rebind that already-resolved
recordset to the new environment for the exception_ids check.
Signed-off-by hparfr
@bt-admin bt-admin added the 18.0 label Sep 16, 2026
@bt-admin
bt-admin merged commit d5aa079 into brain-tec:18.0 Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants