Skip to content
Snippets Groups Projects
Commit 817de24a authored by Nicolas Martinelli's avatar Nicolas Martinelli
Browse files

[FIX] purchase_stock: fallback on seller


- Create a product with routes MTO + Buy.
- Create a vendor pricelist with a minimum quantity:
  Min. Qty 1000 for 10 USD
- Create a SO, sell 1000 quantity
  => A PO is created automatically in draft.
- Go back to SO and update quantity to 1200.

The following message pops up: "There is no matching vendor price to
generate the purchase order for product..."

We select the supplier based on the procurement quantity, which is lower
than the minimum quantity of the supplier.

To avoid this situation, we fall back on any supplier like it was the
case in v12.

opw-2297001

closes odoo/odoo#54526

X-original-commit: 4d4913fc
Signed-off-by: default avatarNicolas Martinelli (nim) <nim@odoo.com>
parent 6df72a53
Branches
Tags
No related merge requests found
......@@ -60,6 +60,12 @@ class StockRule(models.Model):
date=schedule_date.date(),
uom_id=procurement.product_uom)
# Fall back on a supplier for which no price may be defined. Not ideal, but better than
# blocking the user.
supplier = supplier or procurement.product_id._prepare_sellers(False).filtered(
lambda s: not s.company_id or s.company_id == procurement.company_id
)[:1]
if not supplier:
msg = _('There is no matching vendor price to generate the purchase order for product %s (no vendor defined, minimum quantity not reached, dates not valid, ...). Go on the product form and complete the list of vendors.') % (procurement.product_id.display_name)
errors.append((procurement, msg))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment