-
-
Notifications
You must be signed in to change notification settings - Fork 484
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e8ebb9c
commit e0c43f6
Showing
6 changed files
with
58 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,27 @@ | |
# @author Iván Todorovich <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import Command, models | ||
from odoo import Command, api, models | ||
|
||
|
||
class ReportBomStructure(models.AbstractModel): | ||
_inherit = "report.mrp.report_bom_structure" | ||
|
||
def _get_bom_lines(self, bom, bom_quantity, product, line_id, level): | ||
@api.model | ||
def _get_bom_data( | ||
self, | ||
bom, | ||
warehouse, | ||
product=False, | ||
line_qty=False, | ||
bom_line=False, | ||
level=0, | ||
parent_bom=False, | ||
parent_product=False, | ||
index=0, | ||
product_info=False, | ||
ignore_stock=False, | ||
): | ||
# OVERRIDE to fill in the `line.product_id` if a component template is used. | ||
# To avoid a complete override, we HACK the bom by replacing it with a virtual | ||
# record, and modifying it's lines on-the-fly. | ||
|
@@ -31,14 +45,24 @@ def _get_bom_lines(self, bom, bom_quantity, product, line_id, level): | |
line.product_id = line_product | ||
if to_ignore_line_ids: | ||
bom.bom_line_ids = [Command.unlink(id) for id in to_ignore_line_ids] | ||
components, total = super()._get_bom_lines( | ||
bom, bom_quantity, product, line_id, level | ||
data = super()._get_bom_data( | ||
bom, | ||
warehouse, | ||
product=product, | ||
line_qty=line_qty, | ||
bom_line=bom_line, | ||
level=level, | ||
parent_bom=parent_bom, | ||
parent_product=parent_product, | ||
index=index, | ||
product_info=product_info, | ||
ignore_stock=ignore_stock, | ||
) | ||
# Replace any NewId value by the real record id | ||
# Otherwise it's evaluated as False in some situations, and it may cause issues | ||
if has_template_lines: | ||
for component in components: | ||
for component in data.get("components", []): | ||
for key, value in component.items(): | ||
if isinstance(value, models.NewId): | ||
component[key] = value.origin | ||
return components, total | ||
return data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters