504589efb27259eb9667d35557e401e45252874a
__reversed__ in BaseModel for efficiency
Before when we do `reserved(records)`, it iterates in a reverse order of `records`. Unfortunately, the `__reserved__` method don't exist explicitly in BaseModel then Python fallback on its own implementation using `__getitem__` and `__len__` (coming from Sequence): https://github.com/python/cpython/blob/3.10/Lib/_collections_abc.py#L1047-L1049 Because it uses __getitem__, it breaks the prefetch of the recordset. Example: ------------- ``` partners = self.env['res.partner'].browse(1, 2, 3, 4, 5) for partner in reversed(partners): partner.name ``` will generate 5 SQL requests to fetch data (one by record) Then create our own `__reversed__` and handle the prefetch correctly (like `__iter__`). Now in the example it will correctly generate only 1 SQL request because of the prefetch. task-2687953 closes odoo/odoo#79622 Signed-off-by: Raphael Collet <rco@odoo.com> Co-authored-by: rco-odoo <rco@odoo.com>
Odoo
Odoo is a suite of web based open source business apps.
The main Odoo Apps include an Open Source CRM, Website Builder, eCommerce, Warehouse Management, Project Management, Billing & Accounting, Point of Sale, Human Resources, Marketing, Manufacturing, ...
Odoo Apps can be used as stand-alone applications, but they also integrate seamlessly so you get a full-featured Open Source ERP when you install several Apps.
Getting started with Odoo
For a standard installation please follow the Setup instructions from the documentation.
To learn the software, we recommend the Odoo eLearning, or Scale-up, the business game. Developers can start with the developer tutorials
Languages
Python
49.6%
JavaScript
47.8%
SCSS
2%
CSS
0.3%
HTML
0.2%