The main motivation for this change is to improve performance of BoM `explode`, which heavily rely on checking the lines to skip. `explode` is also called from product `compute_quantities_dict` which is called multiple times during upgrades. With this fix we improved the running time of an upgrade _test_ from 3h:30m to 2h:55m which gives a 16% performance improvement. The goal of `_skip_bom_line` is to check that for each attribute present on the line, at least one value associated to that attribute must be in the attribute values of the product(*). If none is found then we consider that we can skip the line. The previous implementation was inefficient. It grouped all values by attribute, then checked one by one if at least one value is on the product. In case one attribute does not have any value on the product it skipped the line. The implementation we propose here is to take the intersection of the product and line values, then check that their attributes are the same. The later can be done with a simple length check. In case they are different the line must be skipped. Note that this works because only one value is possible per attribute in a product. Both implementations are equivalent. The second is more efficient because does not branch and relies on (record)set operations. For example, let's consider a product with two attribute values `a` and `b`, and a line with multiple values `a`,`y` for attribute 1, and `z` for attribute 2. ``` Product Line +---+ +-----+ | a | <- same attribute -> | a,y | +---+ +-----+ | b | <- same attribute -> | z | +---+ + ----+ ``` This line must be skipped. The reason is that the value `b` is not among the list `[z]` of values for attribute 2 on the line. The new implementation would get the intersection of attribute values as `[a]` from there the comparison of the attributes will fail because `[a]` has only one attribute while the line has two. Let's consider a second case, where there is no value on the line for attribute 2. ``` Product Line +---+ +-----+ | a | <- same attribute -> | a,y | +---+ +-----+ | b | <- same attribute -> | | +---+ + ----+ ``` This line is not skipped because there is no value for attribute 2 on the line. Therefore the condition(*) per attribute is not violated for this product. The new implementation gets `[a]` as intersection of values, but now the attributes coincide: they are both attribute 1 for the intersection and the line. Finally, ``` Product Line +---+ +-----+ | a | <- same attribute -> | a,y | +---+ +-----+ | | <- same attribute -> | z,w | +---+ + ----+ ``` This line is skipped because none of `[z,w]` are in the product. The new implementation would get again `[a]` as intersection which does not match the attributes on the line. closes odoo/odoo#105019 X-original-commit: 47f4c3cc72ecb612ef4edd8c603e27b698187d8a Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Odoo Manufacturing Resource Planning
Manage Bill of Materials, plan manufacturing orders, track work orders with the Odoo Open Source MRP app.
Get all your assembly or manufacturing operations managed by Odoo. Schedule manufacturing orders and work orders automatically. Review the proposed planning with the smart kanban and gantt views. Use the advanced analytics features to detect bottleneck in resources capacities and inventory locations.
Schedule Manufacturing Orders Efficiently
Get manufacturing orders and work orders scheduled automatically based on your procurement rules, quantities forecasted and dependent demand (demand for this part based on another part consuming it).
Define Flexible Master Data
Get the flexibility to create multi-level bill of materials, optional routing, version changes and phantom bill of materials. You can use BoM for kits or for manufacturing orders.
Get Flexibility In All Operations
Edit manually all proposed operations at any level of the progress. With Odoo, you will not be frustrated by a rigid system.
Schedule Work Orders
Check resources capacities and fix bottlenecks. Define routings and plan the working time and capacity of your resources. Quickly identify resource requirements and bottlenecks to ensure your production meets your delivery schedule dates.
A Productive User Interface
Organize manufacturing orders and work orders the way you like it. Process next orders from the list view, control in the calendar view and edit the proposed schedule in the Gantt view.
Inventory & Manufacturing Analytics
Track the evolution of the stock value, according to the level of manufacturing activities as they progress in the transformation process.
Fully Integrated with Operations
Get your manufacturing resource planning accurate with it's full integration with sales and purchases apps. The accounting integration allows real time accounting valuation and deeper reporting on costs and revenues on your manufacturing operations.