01e09bb2c27299ba6563f71f48704ca7a8e988ba
_compute_currency_rate of pos.order
Description:
Saving a new `res.config.settings` (for ex: checking "Use QR code on
ticket") can be extremely slow on database with a large number
of `pos.order`.
Analysis:
Saving a new `res.config.settings` creates a new instance of the config.
This will invoke a check on the python constraints calling
eventually `_check_currencies` of `pos.config`, which will invoke the
compute of `currency_id` setting the field as dirty.
The `_compute_currency_rate` of `pos.order` depends on the `currency_id`
of the current `pos.config` (via a related).
This means the compute will be called with *all* `pos.order` ever made.
As the compute itself makes a few calls to `_get_conversion_rate`, which
makes a query, it can become slow when the method is called frequently.
Solution:
Memoize the call to `_get_conversion_rate`, as similarly done
in `account.move.line` from d8d47f9ff8
to reduce the number queries necessary.
Benchmark:
The `create` request to `res.config.settings` on a database with over
240k `pos.order` took
| | Before | After |
|-------------|-----------|----------|
| Timing | 36.9 secs | 4.3 secs |
| Query count | 47k | 627 |
Reference:
opw-3632273
closes odoo/odoo#148136
X-original-commit: 1c6f7f23b2c0dbd009d8d56689c7a98792990f7f
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
Signed-off-by: Piryns Victor (pivi) <pivi@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%