summaryrefslogtreecommitdiff
path: root/odoo
diff options
context:
space:
mode:
authorAdrien Horgnies <aho@odoo.com>2021-01-22 10:39:58 +0000
committerAdrien Horgnies <aho@odoo.com>2021-02-16 14:29:46 +0000
commit0820b9ca6b992675d62aaf21e3b14a6fe628652e (patch)
treebbd8744c627b5c992eb51affb8fc6405a6f909df /odoo
parentaaa26710ba8e29d088b9df5987bb7c2453fb3c7b (diff)
[FIX] product: generate variant combinations faster
The function `_get_possible_combinations` generates possibles combinations for the product template attribute values (ptav) of each product template attribute line (ptal) of a given product template. It used to iterate over them using a cartesian product. A combination can be invalid if it contains two incompatibles ptav. The problem is that it used to filter out invalid combinations after generating them. It's a problem because there can be a lot of invalid combinations to filter out before finding a valid combination. Even before the first valid combination if the first ptav of the two first ptal are incompatible. The solution brought by this commit is to reject the invalid combinations while building them rather than after. It does so by using a cartesian product implementation with early rejection. The algorithm tests each ptav when incorporating it in a partial combination and if it's incompatible, it goes to the next partial combination and thus skips all combinations starting with the invalid partial combination. The client that reported the issue has a product template with about 25 ptal with an average of 9 ptav. The ptav of the first ptal was incompatible with the first ptav of second ptal. It had to build and filter out 5.76*10^15 ptav before finding the first valid ptav. If we generate 10^6 ptav by second (it's much less) user would get first ptav after 182 years. Now it's instantaneous. opw-2335936 closes odoo/odoo#65794 X-original-commit: 98616c4676aa6ef5507110c0e407a640082abbaf Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Diffstat (limited to 'odoo')
0 files changed, 0 insertions, 0 deletions