Skip to content

Commit

Permalink
[14.0][ADD] Add module project_mrp (#287)
Browse files Browse the repository at this point in the history
* [ADD] Add module project_Mrp

* [ADD] Add module project_Mrp
  • Loading branch information
unaiberis authored Jul 2, 2024
1 parent bdd0592 commit da474a1
Show file tree
Hide file tree
Showing 10 changed files with 136 additions and 0 deletions.
34 changes: 34 additions & 0 deletions project_mrp/README.rst
Original file line number Diff line number Diff line change
@@ -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
<https://github.com/avanzosc/sale-addons/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 <[email protected]>
* Unai Beristain <[email protected]>
1 change: 1 addition & 0 deletions project_mrp/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
15 changes: 15 additions & 0 deletions project_mrp/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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,
}
1 change: 1 addition & 0 deletions project_mrp/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import project_task, mrp_production
20 changes: 20 additions & 0 deletions project_mrp/models/mrp_production.py
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions project_mrp/models/project_task.py
Original file line number Diff line number Diff line change
@@ -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
)
27 changes: 27 additions & 0 deletions project_mrp/views/mrp_production_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" ?>
<odoo>
<record id="view_mrp_production_form_inherit" model="ir.ui.view">
<field name="name">mrp.production.form.inherit</field>
<field name="model">mrp.production</field>
<field name="inherit_id" ref="mrp.mrp_production_form_view" />
<field name="arch" type="xml">
<xpath expr="//notebook" position="inside">
<page string="Tasks">
<field name="task_ids">
<tree editable="bottom">
<field name="name" />
</tree>
</field>
</page>
</xpath>
<xpath expr="//div[@name='button_box']" position="inside">
<button
name="action_view_related_tasks"
type="object"
string="Related Tasks"
class="oe_highlight"
/>
</xpath>
</field>
</record>
</odoo>
18 changes: 18 additions & 0 deletions project_mrp/views/project_task_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" ?>
<odoo>
<record id="view_task_form_inherit" model="ir.ui.view">
<field name="name">project.task.form.inherit</field>
<field name="model">project.task</field>
<field name="inherit_id" ref="project.view_task_form2" />
<field name="arch" type="xml">
<xpath expr="//field[@name='partner_id']" position="after">
<field name="sale_order_id" invisible="1" />
<field
name="mrp_production_id"
domain="['|',('sale_id', '=', sale_order_id), ('sale_id', '=', False)]"
/>
<field name="product_id" />
</xpath>
</field>
</record>
</odoo>
1 change: 1 addition & 0 deletions setup/project_mrp/odoo/addons/project_mrp
6 changes: 6 additions & 0 deletions setup/project_mrp/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit da474a1

Please sign in to comment.