Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mrp_bom_overview_forecast/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
14 changes: 14 additions & 0 deletions mrp_bom_overview_forecast/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "bom_overview",
"version": "1.0",
"depends": ["mrp", "purchase"],
"author": "times",
"category": "Tutorials",
"license": "LGPL-3",
'installable': True,
"assets": {
"web.assets_backend": [
"mrp_bom_overview_forecast/static/src/**/*",
],
},
}
1 change: 1 addition & 0 deletions mrp_bom_overview_forecast/models/__init__.py
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 mrp_bom_overview_forecast/models/mrp_report_bom_structure.py
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
41 changes: 41 additions & 0 deletions mrp_bom_overview_forecast/static/src/bom_overview.xml
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[@class='text-center' and .//div[hasclass('o_field_badge')]]" 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[@class='text-center' and .//t[@t-if=&quot;data.hasOwnProperty('availability_state')&quot;]]" position="replace"/>
</t>

<t t-name="mrp.BomOverviewTable.headers" t-inherit="mrp.BomOverviewTable" t-inherit-mode="extension">
<xpath expr="//th[@title='Reception time estimation.']" position="replace"/>
<xpath expr="//tfoot//tr[1]/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="//tfoot//t//tr/td[@t-if='forecastMode'][3]" position="replace"/>
</t>

<t t-name="mrp.BomOverviewSpecialLine" t-inherit="mrp.BomOverviewSpecialLine" t-inherit-mode="extension">
<xpath expr="//td[@t-if='forecastMode'][3]" 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>
35 changes: 35 additions & 0 deletions mrp_bom_overview_forecast/static/src/bom_overview_line.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { patch } from "@web/core/utils/patch";
import { BomOverviewLine } from "@mrp/components/bom_overview_line/mrp_bom_overview_line";

patch(BomOverviewLine.prototype, {

get statusData() {
if (this.data.hasOwnProperty('components_available') && this.data.status && this.data.status !== "No Ready To Produce") {
return this.data.status;
}
if (this.data.status === "No Ready To Produce" && 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.statusData) {
return "text-bg-danger";
}
if (this.statusData === "Available" || this.statusData.includes("Ready To Produce")) {
return "text-bg-success";
}
if (this.statusData.includes("Expected")) {
return "text-bg-warning";
}
if (this.statusData.includes("Estimated")) {
return "text-bg-dark";
}
return "text-bg-danger";
},
});