diff --git a/bom_forecast/__init__.py b/bom_forecast/__init__.py new file mode 100644 index 00000000000..9186ee3ad24 --- /dev/null +++ b/bom_forecast/__init__.py @@ -0,0 +1 @@ +from . import model diff --git a/bom_forecast/__manifest__.py b/bom_forecast/__manifest__.py new file mode 100644 index 00000000000..b6a514074df --- /dev/null +++ b/bom_forecast/__manifest__.py @@ -0,0 +1,15 @@ +{ + "name": "bom_forecast", + "version": "1.0", + "depends": ["mrp", "purchase"], + "author": "soham", + "category": "Tutorials", + "license": "LGPL-3", + 'installable': True, + 'auto_install': True, + "assets": { + "web.assets_backend": [ + "bom_forecast/static/src/**/*", + ], + }, +} diff --git a/bom_forecast/model/__init__.py b/bom_forecast/model/__init__.py new file mode 100644 index 00000000000..98974148e0e --- /dev/null +++ b/bom_forecast/model/__init__.py @@ -0,0 +1 @@ +from . import report_mrp_bom_structure diff --git a/bom_forecast/model/report_mrp_bom_structure.py b/bom_forecast/model/report_mrp_bom_structure.py new file mode 100644 index 00000000000..7fc532931a9 --- /dev/null +++ b/bom_forecast/model/report_mrp_bom_structure.py @@ -0,0 +1,40 @@ +from odoo import _, models + + +class ReportMrpReportBomStructure(models.AbstractModel): + _inherit = "report.mrp.report_bom_structure" + + def _get_bom_data(self, *args, **kwargs): + result = super()._get_bom_data(*args, **kwargs) + + self._set_ready_to_produce_status(result) + self._set_forecast_status_display(result) + + return result + + def _set_ready_to_produce_status(self, line): + if line.get("level") != 0: + return + + qty = int(line.get("producible_qty") or 0) + line["status"] = _("%(qty)s Ready To Produce", qty=qty) if qty > 0 else False + + def _set_forecast_status_display(self, line): + availability_display = line.get("availability_display") or "" + availability_state = line.get("availability_state") + + line["forecast_status_display"] = availability_display + + if availability_state in ("expected", "estimated") and availability_display: + display_parts = availability_display.split(" ", 1) + date_part = display_parts[1] if len(display_parts) > 1 else "" + + label = _("Estimated") if line.get("level") == 0 else _("Expected") + line["forecast_status_display"] = _( + "%(label)s %(date)s", + label=label, + date=date_part, + ) + + for child_line in line.get("components", []) + line.get("operations", []): + self._set_forecast_status_display(child_line) diff --git a/bom_forecast/static/src/bom_overview_line.xml b/bom_forecast/static/src/bom_overview_line.xml new file mode 100644 index 00000000000..3eba8174ac9 --- /dev/null +++ b/bom_forecast/static/src/bom_overview_line.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bom_forecast/static/src/mrp_bom_overview_table.xml b/bom_forecast/static/src/mrp_bom_overview_table.xml new file mode 100644 index 00000000000..9f863981c5c --- /dev/null +++ b/bom_forecast/static/src/mrp_bom_overview_table.xml @@ -0,0 +1,14 @@ + + + + + + + + + +