Adrien Widart (awt) 09f71c0809 [FIX] stock,mrp: redirect byproducts with capacity constraints
When redirecting the SML of byproducts, the capacity constraints of
the locations are not considered.

To reproduce the issue:
1. In Settings, enable:
   - By-Products
   - Storage Locations
   - Storage Categories
2. Create three storable products P01, P02, P_comp
3. Create a storage category SG:
   - Max Weight: 1000
   - Capacity by Products:
     - 2 x P02
4. Create two locations L01, L02:
   - Parent Location: WH/Stock
   - Storage Category: SG
5. Create a putaway rule:
   - From: WH/Stock
   - Product: P02
   - To: WH/Stock
   - Having Category: SG
6. Create a BoM:
   - Product: P01
   - Components: 1 x P_compo
   - By-products: 1 x P02
7. Update on hand qty of P02:
   - 1 x P02 at L01
8. Create and confirm a MO with 2 x P01
9. Set the producing qty to 2
10. Open the detailed operations of P02

Error: The destination location is L01, this would break the
capacity constraint. The location should be L02

When setting the producing qty, we also set the done quantities of
the finished moves and we redirect them thanks to the putaway rules:
https://github.com/odoo/odoo/blob/cc6e31efe6fdd9dee16de1565afe9e1b502de45d/addons/stock/models/stock_move.py#L1885-L1888
However, the SML created only has the `qty_done` defined and, when
applying the putaway rules, we consider the `product_uom_qty` which
is equal to 0 in such a case.

So, when trying to redirect the SML of P02, we check if the capacity
constraint of L01 would be exceeded with the quantity of the SML.
But, as explained above, that quantity will be 0, so we conclude
that the capacity constraint is ok and we return L01 as best solution.

This is the reason why this commit suggests the use of the maximum
between done quantity and reserved quantity. This logic is already
used in the putaway application process, when we check the forecasted
quantity by location:
https://github.com/odoo/odoo/blob/a217ba27600c64c9104f8c1f003afd74ad06bd05/addons/stock/models/stock_location.py#L297-L301

OPW-3100322

closes odoo/odoo#109669

X-original-commit: 4ee8f974f993d2bbea7d9fc00779ebb1c1fa047d
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Adrien Widart <awt@odoo.com>
2023-01-12 08:02:48 +01:00
2022-12-13 17:03:17 +01:00
2023-01-03 13:16:02 +01:00
2023-01-06 14:31:50 +01:00
2023-01-03 13:16:02 +01:00
…
…
…
2023-01-03 13:16:02 +01:00
2023-01-03 13:16:02 +01:00

Build Status Tech Doc Help Nightly Builds

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

S
Description
No description provided
Readme LGPL-3.0
3.4 GiB
Languages
Python 49.6%
JavaScript 47.8%
SCSS 2%
CSS 0.3%
HTML 0.2%