Skip to content

Commit

Permalink
[MIG] mrp_repair_order: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
HeliconiaSolutions committed Jan 10, 2025
1 parent e99fa6c commit 5dc6169
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 25 deletions.
16 changes: 9 additions & 7 deletions mrp_repair_order/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ MRP Repair Order
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github
:target: https://github.com/OCA/manufacture/tree/17.0/mrp_repair_order
:target: https://github.com/OCA/manufacture/tree/18.0/mrp_repair_order
:alt: OCA/manufacture
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/manufacture-17-0/manufacture-17-0-mrp_repair_order
:target: https://translation.odoo-community.org/projects/manufacture-18-0/manufacture-18-0-mrp_repair_order
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/manufacture&target_branch=17.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/manufacture&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -58,7 +58,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/manufacture/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/manufacture/issues/new?body=module:%20mrp_repair_order%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/manufacture/issues/new?body=module:%20mrp_repair_order%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Expand All @@ -73,9 +73,11 @@ Authors
Contributors
------------

- [APSL-Nagarro](https://apsl.tech):
- [APSL-Nagarro](https://apsl.tech):

- Antoni Marroig <amarroig@apsl.net>
- Antoni Marroig <amarroig@apsl.net>

- Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>

Maintainers
-----------
Expand All @@ -98,6 +100,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-peluko00|

This module is part of the `OCA/manufacture <https://github.com/OCA/manufacture/tree/17.0/mrp_repair_order>`_ project on GitHub.
This module is part of the `OCA/manufacture <https://github.com/OCA/manufacture/tree/18.0/mrp_repair_order>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion mrp_repair_order/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "MRP Repair Order",
"summary": "Create repair order from manufacturing order",
"version": "17.0.1.0.0",
"version": "18.0.1.0.0",
"category": "Manufacturing",
"website": "https://github.com/OCA/manufacture",
"author": "Antoni Marroig, Odoo Community Association (OCA)",
Expand Down
1 change: 1 addition & 0 deletions mrp_repair_order/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
- \[APSL-Nagarro\](<https://apsl.tech>):
- Antoni Marroig \<<amarroig@apsl.net>\>
- Heliconia Solutions Pvt. Ltd. \<<https://www.heliconia.io>\>
128 changes: 111 additions & 17 deletions mrp_repair_order/tests/test_mrp_repair_order.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,124 @@
# Copyright 2024 Antoni Marroig(APSL-Nagarro)<amarroig@apsl.net>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo.tests.common import Form, TransactionCase
from odoo.tests import Form, TransactionCase


class MRPRepairOrderTest(TransactionCase):
class TestMrpRepairIntegration(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.mrp_order = cls.env["mrp.production"].create(
# Create product
cls.product = cls.env["product.product"].create(
{
"product_id": cls.env.ref("product.product_delivery_01").id,
"product_qty": 2,
"name": "Test Product",
"tracking": "none",
}
)
# Create component
cls.component = cls.env["product.product"].create(
{
"name": "Test Component",
}
)
# Create BOM
cls.bom = cls.env["mrp.bom"].create(
{
"product_tmpl_id": cls.product.product_tmpl_id.id,
"product_qty": 1.0,
"type": "normal",
"bom_line_ids": [
(0, 0, {"product_id": cls.component.id, "product_qty": 1.0})
],
}
)

def test_01_create_repair_from_mrp(self):
"""Test creation of repair order from manufacturing order"""
# Create MO
mo_form = Form(self.env["mrp.production"])
mo_form.product_id = self.product
mo_form.bom_id = self.bom
mo_form.product_qty = 1.0
mo = mo_form.save()

# Create repair order from MO
action = mo.action_create_repair_order()
self.assertEqual(action["type"], "ir.actions.act_window")
self.assertEqual(action["res_model"], "repair.order")
self.assertEqual(action["view_mode"], "form")
self.assertEqual(action["target"], "new")

def test_create_repair_order_from_mrp(self):
repair_form = Form(
self.env["repair.order"].with_context(
default_mrp_id=self.mrp_order.id,
default_product_qty=self.mrp_order.product_qty,
default_product_id=self.mrp_order.product_id.id,
default_mrp_ids=[self.mrp_order.id],
)
# Check context values
context = action["context"]
self.assertEqual(context["default_product_id"], self.product.id)
self.assertEqual(context["default_product_qty"], 1.0)
self.assertEqual(context["default_mrp_ids"], [mo.id])

def test_02_repair_mrp_navigation(self):
"""Test navigation between repair order and manufacturing order"""
# Create MO
mo = self.env["mrp.production"].create(
{
"product_id": self.product.id,
"bom_id": self.bom.id,
"product_qty": 1.0,
}
)

# Create Repair Order
repair = self.env["repair.order"].create(
{
"product_id": self.product.id,
"product_qty": 1.0,
"mrp_ids": [(4, mo.id)],
}
)
repair_order = repair_form.save()
self.assertEqual(self.mrp_order.repair_id, repair_order)
self.assertEqual(self.mrp_order.repair_id.product_id, repair_order.product_id)
self.assertEqual(self.mrp_order.repair_id.product_qty, repair_order.product_qty)

# Link MO to repair
mo.repair_id = repair.id

# Test navigation from repair to MO
action = repair.action_view_repair_manufacturing_order()
self.assertEqual(action["type"], "ir.actions.act_window")
self.assertEqual(action["res_model"], "mrp.production")
self.assertEqual(action["res_id"], mo.id)

# Test navigation from MO to repair
action = mo.action_view_mrp_production_repair_orders()
self.assertEqual(action["type"], "ir.actions.act_window")
self.assertEqual(action["res_model"], "repair.order")
self.assertEqual(action["res_id"], repair.id)

def test_03_multiple_mrp_orders(self):
"""Test handling of multiple manufacturing orders linked to repair"""
repair = self.env["repair.order"].create(
{
"product_id": self.product.id,
"product_qty": 1.0,
}
)

# Create multiple MOs
mo1 = self.env["mrp.production"].create(
{
"product_id": self.product.id,
"bom_id": self.bom.id,
"product_qty": 1.0,
"repair_id": repair.id,
}
)

mo2 = self.env["mrp.production"].create(
{
"product_id": self.product.id,
"bom_id": self.bom.id,
"product_qty": 1.0,
"repair_id": repair.id,
}
)

# Verify mrp_ids in repair order
self.assertEqual(len(repair.mrp_ids), 2)
self.assertIn(mo1.id, repair.mrp_ids.ids)
self.assertIn(mo2.id, repair.mrp_ids.ids)

0 comments on commit 5dc6169

Please sign in to comment.