Skip to content

[FIX] multi_store: allow reading records of other stores by id - #115

Closed
rov-adhoc wants to merge 2 commits into
ingadhoc:18.0from
adhoc-dev:18.0-h-132306-rov
Closed

rov-adhoc wants to merge 2 commits into
ingadhoc:18.0from
adhoc-dev:18.0-h-132306-rov

Conversation

@rov-adhoc

@rov-adhoc rov-adhoc commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Ticket: https://www.adhoc.inc/odoo/helpdesk.ticket/132306

Since 17.0, fetch() resolves the ids through _search() as the current user. The store filter that account.journal, sale.order and stock.picking.type add in _search() was meant only to restrict choosing records, but now it also forbids reading them by id: a user of one store can no longer open an entry, transfer or order of another store (read access error). Up to 16.0 this was allowed.

fetch() now reads with the skip_store_filter context, which _search() honors. Choosing records stays filtered by store, and writing on records of other stores stays forbidden by the record rules.

The new env keeps env.company and env.companies: it passes them as allowed_company_ids, with env.company first. env.company is part of the cache key of company-dependent fields: without it, the values fetched were cached under the user's default company, and reading them in an env whose company was set directly (as demo_full tests do with self.env.company = ...) raised MissingError. with_company() alone is not enough: without allowed_company_ids in the context it leaves only that company allowed, and the multi-company rules then forbid reading records of the user's other companies.

Tests added in the three modules: they fail without the fix and pass with it.

@roboadhoc

Copy link
Copy Markdown

Pull request status dashboard

@cav-adhoc

Copy link
Copy Markdown
Contributor

LGTM! 👍

Cosas que están ok:

  • Diagnóstico correcto: en 18 fetch() pasa por _search() y el filtro por tienda cortaba la lectura por id.
  • La búsqueda y la selección siguen filtradas (search_fetch no pasa por fetch()).
  • Multicompañía se sigue respetando y escribir en otras tiendas sigue prohibido.
  • El contexto no sale de fetch ni entra en la caché.
  • Los tests fallan sin el fix.

Cosas que vi y descarté:

  • stock.warehouse y stock.rule no tienen el bug: su filtro pide limit o un contexto que fetch no trae.
  • skip_store_filter se puede mandar por RPC, pero no expone más que la lectura por id que este fix ya abre.
  • Ningún x2many de estos modelos apunta a otro modelo filtrado, así que el contexto no se propaga a otros modelos.
  • Odoo pide no hacer override de fetch, pero no hay otro punto de extensión.
  • El comentario del override se podría acortar a una línea, pero es menor.

Since 17.0, fetch() resolves the ids through _search() as the current
user. The store filter that account.journal, sale.order and
stock.picking.type add in _search() was meant only to restrict choosing
records, but now it also forbids reading them by id, so a user of one
store can no longer open an entry, transfer or order of another store
(read access error on the journal, operation type or order). Up to 16.0
this was allowed.

fetch() now reads with the skip_store_filter context, which _search()
honors. Choosing records stays filtered by store and writing on records
of other stores stays forbidden by the record rules.

The new env keeps env.company (with_company), which is part of the cache
key of company-dependent fields: otherwise the values fetched would be
cached under another company and reading them would raise MissingError.
@maq-adhoc

Copy link
Copy Markdown

@roboadhoc r+ nobump

This branch was successfully deployed

1 active deployment
merge — 14babe21 Deployed Nov 19, 2026 by roboadhoc
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.

4 participants