Files
odoo_source/addons/mrp
Touati Djamel (otd) fe1443885a [FIX] mrp: print structure & cost BOM's of archived products
Steps to reproduce the bug:
- Create a storable Product “p1” with BoM:
    - Add a component and a byproduct:
- Archive “P1”
- Go to BOM Overview
- Filter -> see archived BoM
- Print BOM Structure

Problem:
A traceback is triggered,`ValueError:
Expected singleton:product.product()`

The `_match_all_variant_values` function is called but without the
product, while it takes at least one:
https://github.com/odoo/odoo/blob/15.0/addons/mrp/models/mrp_bom.py#L456
https://github.com/odoo/odoo/blob/15.0/addons/mrp/models/product.py#L286

The product must be set in the `_get_pdf_line` function, in our case,
the function does not receive it as an argument, so we have to get it
from the BOM, but as the `product variant` field has not been set in
the BOM, we should get it from the product_template:

https://github.com/odoo/odoo/blob/02cd750da6a79e6aa7104473fff2ab986b6e607c/addons/mrp/report/mrp_report_bom_structure.py#L378

The `product_variant_id` field is a non-stored compute field:
https://github.com/odoo/odoo/blob/34a2948d3d6e0f597c1b5d65f9f118e891c07cc4/addons/product/models/product_template.py#L133

And in the compute function, we use the first element of the
`product_variant_ids`: https://github.com/odoo/odoo/blob/34a2948d3d6e0f597c1b5d65f9f118e891c07cc4/addons/product/models/product_template.py#L177-L179

But it is a `Many2one` field, and for this type of field we have to add
`with_context(active_test=False)` to the ORM returns all records,
active or archived.

opw-3236421

closes odoo/odoo#116207

X-original-commit: fa10dd50397f83ad88380995a65c7d722825aee1
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2023-03-22 15:59:15 +01:00
..
2023-03-20 16:51:30 +01:00
…

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.