PerformanceHighlight of Weekly #002

POS ticket screen stops refetching variants

Loading paid orders no longer refetches every sibling variant with inline images on each filter change. With large configurable products this was a multi-megabyte response.

Versions18.0
ModulesPoint of Sale point_of_sale
AppPoint of Sale

Pull requests and commits

BranchPull requestCommit
18.0odoo/odoo#289970 ↗a33c1807d4 ↗

Commit message

[PERF] point_of_sale: stop refetching sibling variants

When the ticket screen loads paid orders whose products are not in
memory, `processProductAttributesByProducts` fetches every other variant
of the templates involved so it can keep a single main variant per
template. That `search_read` requests the full product field list
without `bin_size`, so `image_128` comes back inline, and it excludes
only the products of the orders, so variants already loaded at boot or
by a previous visit are fetched again. It runs on every filter change.

With a few configurable products of several hundred variants each, 30
orders resolve to a multi-megabyte response that the browser has to
parse and turn into records before recomputing the attribute exclusions,
which freezes the PoS for tens of seconds each time the ticket screen is
opened or filtered.

Steps to reproduce:
- Create a product with attributes generating a few hundred variants,
  each variant with an image.
- Open a PoS session, sell some of these variants in several orders.
- Open the ticket screen and switch between the filters.

The tab freezes on every filter change while a huge product
`search_read` is processed.

Fix:
- Reuse the sibling variants already in memory instead of refetching
  them.
- Fetch the remaining siblings with `bin_size`, since the PoS only uses
  `image_128` as a flag to build the image URL.
- Remember the templates whose siblings were fetched so later ticket
  screen visits and filter changes do not query the server again.

opw-6592443

My stack

Pick the versions and apps you run. Weekly digests, this week's table and All changes then show only what concerns you. Saved in this browser.

Versions
Apps
Modules