[FW][FIX] point_of_sale, pos_sale: fix product loading in POS
Commit 1
[FIX] point_of_sale, pos_sale: fix product loading in POS
Before this commit, when loading additional products after the initial load, the PoS were not receiving all necessary data related to the products, for example product's precomputed taxes objects.
This commit add a method which will load all necessary data for the products when loading them in the PoS.
What's more, when a product was loaded via barcode, it didn't yet have its associated pricelists, as these were loaded in another RPC. This commit unifies data reception via a single RPC.
Loyalty cards are not longer loaded at the beginning of the PoS since they are loaded each time a partner is selected. Loyalty cards doesn't works with offline mode anyway since some backend check must be done before validating them.
Some debug information about loading times and records is now printed in the console when the PoS is started in debug mode.
IndexedDB method is now debounced to avoid calling it too often when the PoS is started. The create method is also batched to avoid putting large amount of data in IndexedDB at once.
Loaded data includes:
-
product.product -
product.template -
product.combo -
product.combo.item -
product.uom -
product.pricelist -
product.pricelist.item -
product.template.attribute.value -
product.template.attribute.line -
account.tax
Commit 2
[PERF] point_of_sale: pricelist computations Before this commit, when we were trying to compute pricelist item for a product, we were iterating over all pricelist items of the pricelist and checking if the product was in the item or if the item didn't have any product set. This was very inefficient, especially when there were many pricelist items and products.
This commit add a pre-computation of pricelist items for general rules which eliminates the need to calculate rules on the fly.
Forward-Port-Of: odoo/odoo#214371
@davidmonnom cherrypicking of pull request odoo/odoo#214371 failed.
- 3ab05d2f048557459c5482214b322135726ab8dc <- on this commit
- 227fd7d7b7b6ba6c0da7a995f8a5d715ad2cbed6
- e8a8ae09a975c8e84663bb17b4e3385f2bc32a7c
stdout:
Auto-merging addons/point_of_sale/models/pos_session.py
Auto-merging addons/point_of_sale/models/product_template.py
Auto-merging addons/point_of_sale/static/src/app/screens/product_screen/product_screen.js
Auto-merging addons/point_of_sale/static/src/app/services/data_service.js
Auto-merging addons/point_of_sale/static/src/app/services/pos_store.js
Auto-merging addons/pos_sale/models/sale_order.py
Auto-merging addons/pos_sale/static/src/app/services/pos_store.js
Auto-merging addons/pos_self_order/static/src/app/services/self_order_service.js
CONFLICT (content): Merge conflict in addons/pos_self_order/static/src/app/services/self_order_service.js
Either perform the forward-port manually (and push to this branch, proceeding as usual) or close this PR (maybe?).
In the former case, you may want to edit this PR message as well.
:warning: after resolving this conflict, you will need to merge it via @robodoo.
More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port
@robodoo r+
