diff --git a/mrp_bom_custom/__init__.py b/mrp_bom_custom/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/mrp_bom_custom/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/mrp_bom_custom/__manifest__.py b/mrp_bom_custom/__manifest__.py new file mode 100644 index 00000000000..5c7b3b02eb6 --- /dev/null +++ b/mrp_bom_custom/__manifest__.py @@ -0,0 +1,15 @@ +{ + "name": "MRP BOM Customization", + "author": "Dharmil Goyani", + "license": "LGPL-3", + "version": "1.0", + "summary": "Customize BOM report logic", + "depends": ["mrp"], + "assets": { + "web.assets_backend": [ + "mrp_bom_custom/static/src/**/*", + ], + }, + "installable": True, + "application": False, +} diff --git a/mrp_bom_custom/models/__init__.py b/mrp_bom_custom/models/__init__.py new file mode 100644 index 00000000000..6b05b39b209 --- /dev/null +++ b/mrp_bom_custom/models/__init__.py @@ -0,0 +1 @@ +from . import report_bom_structure diff --git a/mrp_bom_custom/models/report_bom_structure.py b/mrp_bom_custom/models/report_bom_structure.py new file mode 100644 index 00000000000..27512124e9a --- /dev/null +++ b/mrp_bom_custom/models/report_bom_structure.py @@ -0,0 +1,17 @@ +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) + + 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 diff --git a/mrp_bom_custom/static/src/bom_overview_line.js b/mrp_bom_custom/static/src/bom_overview_line.js new file mode 100644 index 00000000000..6fdb05d5bcb --- /dev/null +++ b/mrp_bom_custom/static/src/bom_overview_line.js @@ -0,0 +1,17 @@ +import { patch } from "@web/core/utils/patch"; +import { BomOverviewLine } from "@mrp/components/bom_overview_line/mrp_bom_overview_line"; + +patch(BomOverviewLine.prototype, { + get statusBackgroundColor() { + console.log(this.data) + if (this.data.level !== 0 && this.data.availability_state == 'estimated') { + return "text-bg-warning"; + } + switch (this.data.availability_state) { + case "available": return "text-bg-success"; + case "expected": return "text-bg-warning"; + case "unavailable": return "text-bg-danger"; + default: return "text-bg-dark"; + } + } +}); diff --git a/mrp_bom_custom/static/src/bom_overview_line.xml b/mrp_bom_custom/static/src/bom_overview_line.xml new file mode 100644 index 00000000000..144bc7feaab --- /dev/null +++ b/mrp_bom_custom/static/src/bom_overview_line.xml @@ -0,0 +1,29 @@ + + + + + +
+ + + + + + + + + + + + + + +
+
+
+
diff --git a/mrp_bom_custom/static/src/mrp_bom_overview_table.xml b/mrp_bom_custom/static/src/mrp_bom_overview_table.xml new file mode 100644 index 00000000000..151a81b4662 --- /dev/null +++ b/mrp_bom_custom/static/src/mrp_bom_overview_table.xml @@ -0,0 +1,7 @@ + + + + + + +