From da474a13804f3a9042e7b4c5cbdcca3cc1e36ffe Mon Sep 17 00:00:00 2001 From: unaiberis <146723346+unaiberis@users.noreply.github.com> Date: Tue, 2 Jul 2024 11:34:45 +0200 Subject: [PATCH] [14.0][ADD] Add module project_mrp (#287) * [ADD] Add module project_Mrp * [ADD] Add module project_Mrp --- project_mrp/README.rst | 34 ++++++++++++++++++++++ project_mrp/__init__.py | 1 + project_mrp/__manifest__.py | 15 ++++++++++ project_mrp/models/__init__.py | 1 + project_mrp/models/mrp_production.py | 20 +++++++++++++ project_mrp/models/project_task.py | 13 +++++++++ project_mrp/views/mrp_production_views.xml | 27 +++++++++++++++++ project_mrp/views/project_task_views.xml | 18 ++++++++++++ setup/project_mrp/odoo/addons/project_mrp | 1 + setup/project_mrp/setup.py | 6 ++++ 10 files changed, 136 insertions(+) create mode 100644 project_mrp/README.rst create mode 100644 project_mrp/__init__.py create mode 100644 project_mrp/__manifest__.py create mode 100644 project_mrp/models/__init__.py create mode 100644 project_mrp/models/mrp_production.py create mode 100644 project_mrp/models/project_task.py create mode 100644 project_mrp/views/mrp_production_views.xml create mode 100644 project_mrp/views/project_task_views.xml create mode 120000 setup/project_mrp/odoo/addons/project_mrp create mode 100644 setup/project_mrp/setup.py diff --git a/project_mrp/README.rst b/project_mrp/README.rst new file mode 100644 index 00000000..0b1c4ea7 --- /dev/null +++ b/project_mrp/README.rst @@ -0,0 +1,34 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: https://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +=========== +Project MRP +=========== + +* Add new field task_ids in mrp production. +* Add new field mrp_production_id in project task. +* Add new field product_id in project task. +* Create a button in mrp production form to call action_view_related_tasks to show related tasks. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smash it by providing detailed and welcomed feedback. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Images +------ + +Contributors +------------ + +* Ana Juaristi +* Unai Beristain diff --git a/project_mrp/__init__.py b/project_mrp/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/project_mrp/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/project_mrp/__manifest__.py b/project_mrp/__manifest__.py new file mode 100644 index 00000000..55d54856 --- /dev/null +++ b/project_mrp/__manifest__.py @@ -0,0 +1,15 @@ +{ + "name": "Project MRP Integration", + "version": "14.0.1.1.0", + "category": "Project", + "website": "https://github.com/avanzosc/project-addons", + "license": "AGPL-3", + "author": "AvanzOSC", + "depends": ["base", "project", "mrp", "sale", "mrp_sale_info"], + "data": [ + "views/project_task_views.xml", + "views/mrp_production_views.xml", + ], + "installable": True, + "auto_install": False, +} diff --git a/project_mrp/models/__init__.py b/project_mrp/models/__init__.py new file mode 100644 index 00000000..972223f3 --- /dev/null +++ b/project_mrp/models/__init__.py @@ -0,0 +1 @@ +from . import project_task, mrp_production diff --git a/project_mrp/models/mrp_production.py b/project_mrp/models/mrp_production.py new file mode 100644 index 00000000..5294381e --- /dev/null +++ b/project_mrp/models/mrp_production.py @@ -0,0 +1,20 @@ +from odoo import fields, models + + +class MrpProduction(models.Model): + _inherit = "mrp.production" + + task_ids = fields.One2many( + "project.task", "mrp_production_id", string="Related Tasks" + ) + + def action_view_related_tasks(self): + action = self.env.ref("project.action_view_task").read()[0] + action["domain"] = [("id", "in", self.task_ids.ids)] + action["context"] = { + "default_project_id": self.project_id.id + if hasattr(self, "project_id") and self.project_id + else False, + "default_mrp_production_id": self.id, + } + return action diff --git a/project_mrp/models/project_task.py b/project_mrp/models/project_task.py new file mode 100644 index 00000000..3b1e6c7f --- /dev/null +++ b/project_mrp/models/project_task.py @@ -0,0 +1,13 @@ +from odoo import fields, models + + +class ProjectTask(models.Model): + _inherit = "project.task" + + mrp_production_id = fields.Many2one( + comodel_name="mrp.production", + string="Manufacturing Order", + ) + product_id = fields.Many2one( + related="mrp_production_id.product_id", string="Product", store=True + ) diff --git a/project_mrp/views/mrp_production_views.xml b/project_mrp/views/mrp_production_views.xml new file mode 100644 index 00000000..cf46c3cf --- /dev/null +++ b/project_mrp/views/mrp_production_views.xml @@ -0,0 +1,27 @@ + + + + mrp.production.form.inherit + mrp.production + + + + + + + + + + + + +