Skip to content
Snippets Groups Projects
Commit 0802d4c6 authored by Adrien Widart's avatar Adrien Widart
Browse files

[FIX] purchase_stock: create new POL if different RR

If the user triggers several orderpoints one by one, some purchase order
lines may be merged while they shouldn't.

To reproduce the issue:
1. In Settings, enable "Storage Locations"
2. Create a product P:
    - Type: Storable
    - With a vendor V
    - Route: Buy
3. Add two reordering rules to P:
    - Min=Max=1 at WH/Stock
    - Min=Max=2 at WH/Stock/Shelf 1
4. Inventory > Operations > Replenishment, trigger the orderpoints of P
(one by one)
5. Open the generated PO

Error: There is only one line with 3 x P, there should be two lines (1 x
P + 2 x P, one for each orderpoint). If the user confirms the PO and
receives the products, the destination location will be Stock or Shelf 1
(depending on the last orderpoint triggered)

Running the orderpoint leads to `_run_buy`, where we try to find an
existing PO line so we can update it (else we will create a new one):
https://github.com/odoo/odoo/blob/5b34adb51eda978aa9ef1a434ab77257d73b9594/addons/purchase_stock/models/stock_rule.py#L122-L129



Here is the issue: the filter in `_find_candidate` contains an `or True`
that makes a whole condition useless.

Considering [1], the condition on `move_dest_ids` is only relevant when
an orderpoint is defined. Therefore, we can remove the `or True` and
improve the condition

[1] 63fffa0b

OPW-2720868

closes odoo/odoo#88870

Signed-off-by: default avatarArnold Moyaux <arm@odoo.com>
parent 41d1adb4
Branches
Tags
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment