-
Notifications
You must be signed in to change notification settings - Fork 3.1k
[IMP] mrp_bom_overview: clean forecast view with consolidated status #1263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
times-odoo
wants to merge
2
commits into
odoo:19.0
Choose a base branch
from
odoo-dev:19.0-imp-mrp-bom-forecast-times
base: 19.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -127,3 +127,8 @@ dmypy.json | |
|
|
||
| # Pyre type checker | ||
| .pyre/ | ||
|
|
||
| /vanilla_js | ||
| /health | ||
| /library | ||
| /hr_loan | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from . import models |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "name": "mrp_bom_overview_forecast", | ||
| "version": "1.0", | ||
| "depends": ["mrp", "purchase"], | ||
| "author": "times", | ||
| "category": "Tutorials", | ||
| "license": "LGPL-3", | ||
| 'installable': True, | ||
| 'auto_install': True, | ||
| "assets": { | ||
| "web.assets_backend": [ | ||
| "mrp_bom_overview_forecast/static/src/**/*", | ||
| ], | ||
| }, | ||
| } | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from . import mrp_report_bom_structure |
15 changes: 15 additions & 0 deletions
15
mrp_bom_overview_forecast/models/mrp_report_bom_structure.py
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| from odoo import _, models | ||
|
|
||
|
|
||
| class ReportMrpReport_Bom_Structure(models.AbstractModel): | ||
| _inherit = 'report.mrp.report_bom_structure' | ||
|
|
||
| def _get_bom_data(self, *args, **kwargs): | ||
| result = super()._get_bom_data(*args, **kwargs) | ||
| if result.get('level') == 0: | ||
| qty = int(result.get('producible_qty') or 0) | ||
| if qty > 0: | ||
| result["status"] = _("%(qty)s Ready To Produce", qty=qty) | ||
| else: | ||
| result["status"] = _("No Ready To Produce") | ||
| return result |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <templates xml:space="preserve"> | ||
|
|
||
| <t t-name="mrp.BomOverviewTable" t-inherit="mrp.BomOverviewTable" t-inherit-mode="extension"> | ||
| <xpath expr="//div[hasclass('d-flex','mb-5')]" position="replace"/> | ||
| <xpath expr="//div[hasclass('o_mrp_bom_report_page')]" position="attributes"> | ||
| <attribute name="class">o_mrp_bom_report_page py-3 py-lg-2 px-0 overflow-auto border-bottom bg-view</attribute> | ||
| </xpath> | ||
| </t> | ||
|
|
||
| <t t-name="mrp.BomOverviewLine" t-inherit="mrp.BomOverviewLine" t-inherit-mode="extension"> | ||
| <xpath expr="//td[.//div[@t-if="data.hasOwnProperty('status')"]]" position="replace"> | ||
| <td t-if="forecastMode" class="text-center"> | ||
| <div t-if="data.is_storable" class="o_field_badge" role="button" t-on-click.prevent="goToForecast"> | ||
| <span t-attf-class="badge rounded-pill o_mrp_overview_badge {{statusBackgroundClass}}" t-out="statusData"/> | ||
| </div> | ||
| </td> | ||
| </xpath> | ||
| <xpath expr="//td[.//t[@t-if="data.hasOwnProperty('availability_state')"]]" position="replace"/> | ||
| </t> | ||
|
|
||
| <t t-name="mrp.BomOverviewTable.headers" t-inherit="mrp.BomOverviewTable" t-inherit-mode="extension"> | ||
| <xpath expr="//th[@name='th_mrp_bom_h']/following-sibling::th[@t-if='forecastMode'][3]" position="replace"/> | ||
| <xpath expr="//td[@name='td_mrp_bom_f']/following-sibling::td[@t-if='forecastMode'][3]" position="replace"/> | ||
| </t> | ||
|
|
||
| <t t-name="mrp.BomOverviewTable.byproducts_footer" t-inherit="mrp.BomOverviewTable" t-inherit-mode="extension"> | ||
| <xpath expr="//td[@name='td_mrp_bom_b']/following-sibling::td[@t-if='forecastMode'][3]" position="replace"/> | ||
| </t> | ||
|
|
||
| <t t-name="mrp.BomOverviewSpecialLine" t-inherit="mrp.BomOverviewSpecialLine" t-inherit-mode="extension"> | ||
| <xpath expr="//td[@name='bom_cost']/preceding-sibling::td[@t-if='forecastMode'][last()]" position="replace"/> | ||
| </t> | ||
|
|
||
| <t t-name="mrp.BomOverviewComponentsBlock" t-inherit="mrp.BomOverviewComponentsBlock" t-inherit-mode="extension"> | ||
| <xpath expr="//BomOverviewLine" position="attributes"> | ||
| <attribute name="currentWarehouseId">props.currentWarehouseId</attribute> | ||
| </xpath> | ||
| </t> | ||
|
|
||
| </templates> |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import { patch } from "@web/core/utils/patch"; | ||
| import { BomOverviewLine } from "@mrp/components/bom_overview_line/mrp_bom_overview_line"; | ||
|
|
||
| patch(BomOverviewLine.prototype, { | ||
|
times-odoo marked this conversation as resolved.
|
||
|
|
||
| get statusData() { | ||
| if (this.data.hasOwnProperty('components_available')) { | ||
| const qty = parseInt(this.data.producible_qty) || 0; | ||
| if (qty > 0) { | ||
| return this.data.status; | ||
| } | ||
| if (qty == 0 && this.data.availability_display) { | ||
| return this.data.availability_display; | ||
| } | ||
| } | ||
| if (this.data.availability_display) { | ||
| return this.data.availability_display; | ||
| } | ||
|
|
||
| return "Not Available"; | ||
| }, | ||
|
|
||
| get statusBackgroundClass() { | ||
| if (this.data.hasOwnProperty('components_available')) { | ||
| const qty = parseInt(this.data.producible_qty) || 0; | ||
| if (qty > 0) { | ||
| return "text-bg-success"; | ||
| } | ||
| } | ||
|
|
||
| const state = this.data.availability_state; | ||
| switch (state) { | ||
| case "available": | ||
| return "text-bg-success"; | ||
| case "expected": | ||
| return "text-bg-warning"; | ||
| case "estimated": | ||
| return "text-bg-dark"; | ||
| default: | ||
| return "text-bg-danger"; | ||
| } | ||
| }, | ||
| }); | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.