diff --git a/mrp_workcenter_hierarchical/README.rst b/mrp_workcenter_hierarchical/README.rst index 030a42816..fb994b535 100644 --- a/mrp_workcenter_hierarchical/README.rst +++ b/mrp_workcenter_hierarchical/README.rst @@ -14,19 +14,18 @@ MRP Workcenter Hierarchical :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/9.0/mrp_workcenter_hierarchical + :target: https://github.com/OCA/manufacture/tree/14.0/mrp_workcenter_hierarchical :alt: OCA/manufacture .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/manufacture-9-0/manufacture-9-0-mrp_workcenter_hierarchical + :target: https://translation.odoo-community.org/projects/manufacture-14-0/manufacture-14-0-mrp_workcenter_hierarchical :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/129/9.0 + :target: https://runbot.odoo-community.org/runbot/129/14.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| - -* Add the possibility to define a parent workcenter to a workcenter +Allow to define a parent workcenter to a workcenter **Table of contents** @@ -36,18 +35,17 @@ MRP Workcenter Hierarchical Configuration ============= -To visualize features offered by this module, you need to: - - * go to Settings > Configuration > Manufacturing - * in the section Manufacturing Order / Planning, - check "Manage routings and work orders" and Validate +Activate workcenters: + * Manufacturing > Configuration > Settings > Configuration + * Check Work Orders and save Usage ===== -To use this module, you need to go to: + * Go to Manufacturing > Configuration > Work Centers + * Set parent field on workcenters - * Manufacturing > Configuration > Workcenter Hierarchical + ../static/src/img/img1.png Bug Tracker =========== @@ -55,7 +53,7 @@ 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 smashing it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -89,6 +87,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/manufacture `_ project on GitHub. +This module is part of the `OCA/manufacture `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/mrp_workcenter_hierarchical/__init__.py b/mrp_workcenter_hierarchical/__init__.py index f68a77f44..0650744f6 100644 --- a/mrp_workcenter_hierarchical/__init__.py +++ b/mrp_workcenter_hierarchical/__init__.py @@ -1,5 +1 @@ -# © 2016 Akretion (http://www.akretion.com) -# David BEAL -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -from . import model +from . import models diff --git a/mrp_workcenter_hierarchical/__manifest__.py b/mrp_workcenter_hierarchical/__manifest__.py index f8903196d..2bccd24e4 100644 --- a/mrp_workcenter_hierarchical/__manifest__.py +++ b/mrp_workcenter_hierarchical/__manifest__.py @@ -1,10 +1,10 @@ -# © 2016 Akretion (http://www.akretion.com) +# 2016 Akretion (http://www.akretion.com) # David BEAL # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { "name": "MRP Workcenter Hierarchical", - "version": "14.0.0.0.0", + "version": "14.0.1.0.0", "author": "Akretion,Odoo Community Association (OCA)", "summary": "Organise Workcenters by section", "category": "Manufacturing", diff --git a/mrp_workcenter_hierarchical/data/mrp_demo.xml b/mrp_workcenter_hierarchical/data/mrp_demo.xml index f39fc8fd8..beb6f1cca 100644 --- a/mrp_workcenter_hierarchical/data/mrp_demo.xml +++ b/mrp_workcenter_hierarchical/data/mrp_demo.xml @@ -1,96 +1,39 @@ - - - - Assembly 1 - - 5 - 1 - 0.1 - 0.1 - 0.87 - - 0.1 - - 0.05 - - - - Assembly workshop 2 - - 5 - 1 - 0.1 - 0.1 - 0.87 - - 0.1 - - 0.05 - - - - - Assembly A - - 5 - 1 - 0.1 - 0.1 - 0.87 - - 0.1 - - 0.05 - - - - - Assembly B - - 5 - 1 - 0.1 - 0.1 - 0.87 - - 0.1 - - 0.05 - - - - - Assembly C - - 5 - 1 - 0.1 - 0.1 - 0.87 - - 0.1 - - 0.05 - - - - - Assembly E - - 5 - 1 - 0.1 - 0.1 - 0.87 - - 0.1 - - 0.05 - - - - - - - + + + + 12345 + + + 1234 + + + + 123 + + + + 12 + + + + 1 + + + + + + + mrp.workcenter + + + + + + + + + + + + diff --git a/mrp_workcenter_hierarchical/model/__init__.py b/mrp_workcenter_hierarchical/model/__init__.py deleted file mode 100644 index ec36a0176..000000000 --- a/mrp_workcenter_hierarchical/model/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -# © 2016 Akretion (http://www.akretion.com) -# David BEAL -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -from . import workcenter diff --git a/mrp_workcenter_hierarchical/models/__init__.py b/mrp_workcenter_hierarchical/models/__init__.py new file mode 100644 index 000000000..567663b3b --- /dev/null +++ b/mrp_workcenter_hierarchical/models/__init__.py @@ -0,0 +1 @@ +from . import mrp_workcenter diff --git a/mrp_workcenter_hierarchical/model/workcenter.py b/mrp_workcenter_hierarchical/models/mrp_workcenter.py similarity index 75% rename from mrp_workcenter_hierarchical/model/workcenter.py rename to mrp_workcenter_hierarchical/models/mrp_workcenter.py index 35dc12000..33e4f2a1b 100644 --- a/mrp_workcenter_hierarchical/model/workcenter.py +++ b/mrp_workcenter_hierarchical/models/mrp_workcenter.py @@ -1,39 +1,41 @@ -# © 2016 Akretion (http://www.akretion.com) +# 2016 Akretion (http://www.akretion.com) # David BEAL # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from openerp import api, fields, models +from odoo import api, fields, models class MrpWorkcenter(models.Model): _inherit = "mrp.workcenter" - _order = "parent_left" + _parent_name = "parent_id" _parent_store = True - parent_id = fields.Many2one("mrp.workcenter", string="Parent") - child_ids = fields.One2many("mrp.workcenter", "parent_id", string="Children") + parent_id = fields.Many2one( + comodel_name="mrp.workcenter", string="Parent", index=True + ) + parent_path = fields.Char(index=True) + child_ids = fields.One2many( + comodel_name="mrp.workcenter", inverse_name="parent_id", string="Children" + ) parent_level_1_id = fields.Many2one( - "mrp.workcenter", + comodel_name="mrp.workcenter", compute="_compute_parent_level", string="Parent Level 1", store=True, ) parent_level_2_id = fields.Many2one( - "mrp.workcenter", + comodel_name="mrp.workcenter", compute="_compute_parent_level", string="Parent Level 2", store=True, ) parent_level_3_id = fields.Many2one( - "mrp.workcenter", + comodel_name="mrp.workcenter", compute="_compute_parent_level", string="Parent Level 3", store=True, ) - parent_left = fields.Integer(select=True) - parent_right = fields.Integer(select=True) - @api.multi def _get_parent_ids(self): self.ensure_one() if self.parent_id: @@ -43,7 +45,6 @@ class MrpWorkcenter(models.Model): ids = [] return ids - @api.multi @api.depends("parent_id.parent_id.parent_id", "child_ids") def _compute_parent_level(self): def get_next_level(parent_ids, workcenter): diff --git a/mrp_workcenter_hierarchical/readme/CONFIGURE.rst b/mrp_workcenter_hierarchical/readme/CONFIGURE.rst index e476e55a7..eef187384 100644 --- a/mrp_workcenter_hierarchical/readme/CONFIGURE.rst +++ b/mrp_workcenter_hierarchical/readme/CONFIGURE.rst @@ -1,5 +1,3 @@ -To visualize features offered by this module, you need to: - - * go to Settings > Configuration > Manufacturing - * in the section Manufacturing Order / Planning, - check "Manage routings and work orders" and Validate +Activate workcenters: + * Manufacturing > Configuration > Settings > Configuration + * Check Work Orders and save diff --git a/mrp_workcenter_hierarchical/readme/DESCRIPTION.rst b/mrp_workcenter_hierarchical/readme/DESCRIPTION.rst index 2d03560dd..8dc1024b2 100644 --- a/mrp_workcenter_hierarchical/readme/DESCRIPTION.rst +++ b/mrp_workcenter_hierarchical/readme/DESCRIPTION.rst @@ -1,2 +1 @@ - -* Add the possibility to define a parent workcenter to a workcenter +Allow to define a parent workcenter to a workcenter diff --git a/mrp_workcenter_hierarchical/readme/USAGE.rst b/mrp_workcenter_hierarchical/readme/USAGE.rst index 6b7ee7572..e475d34a2 100644 --- a/mrp_workcenter_hierarchical/readme/USAGE.rst +++ b/mrp_workcenter_hierarchical/readme/USAGE.rst @@ -1,3 +1,4 @@ -To use this module, you need to go to: + * Go to Manufacturing > Configuration > Work Centers + * Set parent field on workcenters - * Manufacturing > Configuration > Workcenter Hierarchical + ../static/src/img/img1.png diff --git a/mrp_workcenter_hierarchical/static/description/index.html b/mrp_workcenter_hierarchical/static/description/index.html index 81edc9e02..369c713a1 100644 --- a/mrp_workcenter_hierarchical/static/description/index.html +++ b/mrp_workcenter_hierarchical/static/description/index.html @@ -367,10 +367,8 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/manufacture Translate me on Weblate Try me on Runbot

-
    -
  • Add the possibility to define a parent workcenter to a workcenter
  • -
+

Beta License: AGPL-3 OCA/manufacture Translate me on Weblate Try me on Runbot

+

Allow to define a parent workcenter to a workcenter

Table of contents

    @@ -387,22 +385,24 @@ ul.auto-toc {

Configuration

-

To visualize features offered by this module, you need to:

-
-
    -
  • go to Settings > Configuration > Manufacturing
  • -
  • in the section Manufacturing Order / Planning, -check “Manage routings and work orders” and Validate
  • +
    +
    Activate workcenters:
    +
      +
    • Manufacturing > Configuration > Settings > Configuration
    • +
    • Check Work Orders and save
    -
+ +

Usage

-

To use this module, you need to go to:

    -
  • Manufacturing > Configuration > Workcenter Hierarchical
  • +
  • Go to Manufacturing > Configuration > Work Centers
  • +
  • Set parent field on workcenters
+
+../static/src/img/img1.png
@@ -410,7 +410,7 @@ check “Manage routings and work orders” and Validate

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 smashing it by providing a detailed and welcomed -feedback.

+feedback.

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

@@ -437,7 +437,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

-

This module is part of the OCA/manufacture project on GitHub.

+

This module is part of the OCA/manufacture project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/mrp_workcenter_hierarchical/static/src/img/img1.png b/mrp_workcenter_hierarchical/static/src/img/img1.png new file mode 100644 index 000000000..16a3cccfc Binary files /dev/null and b/mrp_workcenter_hierarchical/static/src/img/img1.png differ diff --git a/mrp_workcenter_hierarchical/tests/test_compute_level.py b/mrp_workcenter_hierarchical/tests/test_compute_level.py index c711fdf2b..2f5bcaca8 100644 --- a/mrp_workcenter_hierarchical/tests/test_compute_level.py +++ b/mrp_workcenter_hierarchical/tests/test_compute_level.py @@ -2,73 +2,17 @@ # David BEAL # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from openerp.tests.common import TransactionCase +from odoo.tests.common import TransactionCase class ComputeParentLevel(TransactionCase): - def test_compute_parent_level0(self): - workcenter = self.env["mrp.workcenter"].create( - { - "name": "New Assembly", - "calendar_id": self.env.ref("resource.timesheet_group1").id, - "capacity_per_cycle": 5, - "time_cycle": 1, - "time_start": 0.1, - "time_stop": 0.1, - "time_efficiency": 0.87, - "product_id": self.env.ref("product.product_assembly").id, - "costs_hour": 0, - "costs_hour_account_id": self.env.ref("mrp.account_assembly_hours").id, - "costs_cycle": 0.05, - "costs_cycle_account_id": self.env.ref("mrp.account_assembly_cycle").id, - } - ) - workcenter_child = self.env.ref("mrp_workcenter_hierarchical.mrp_workcenter_A") - workcenter_child.write({"parent_id": workcenter.id}) - self.assertEqual(workcenter.parent_level_1_id, workcenter) + def test_compute_low_level_workcenter(self): + workcenter = self.env["mrp.workcenter"].create({"name": "any"}) - def test_compute_parent_level1(self): - workcenter_child = self.env.ref("mrp_workcenter_hierarchical.mrp_workcenter_E") - workcenter_parent = self.env.ref( - "mrp_workcenter_hierarchical.mrp_workcenter_top" - ) - workcenter_child.write({"parent_id": workcenter_parent.id}) - self.assertEqual(workcenter_child.parent_level_1_id, workcenter_parent) + def get_record(string): + return self.env.ref("mrp_workcenter_hierarchical.%s" % string) - def test_compute_parent_level2(self): - workcenter_child = self.env.ref("mrp_workcenter_hierarchical.mrp_workcenter_A") - workcenter_parent1 = self.env.ref( - "mrp_workcenter_hierarchical.mrp_workcenter_top" - ) - workcenter_parent2 = self.env.ref("mrp.mrp_workcenter_0") - workcenter_child.write({"parent_id": workcenter_parent2.id}) - self.assertEqual(workcenter_child.parent_level_2_id, workcenter_parent2) - self.assertEqual(workcenter_child.parent_level_1_id, workcenter_parent1) - - def test_compute_parent_level3(self): - workcenter_child = self.env.ref("mrp_workcenter_hierarchical.mrp_workcenter_B") - workcenter_parent1 = self.env.ref( - "mrp_workcenter_hierarchical.mrp_workcenter_top" - ) - workcenter_parent2 = self.env.ref( - "mrp_workcenter_hierarchical.mrp_workcenter_2" - ) - workcenter_parent3 = self.env.ref( - "mrp_workcenter_hierarchical.mrp_workcenter_A" - ) - workcenter_child.write({"parent_id": workcenter_parent3.id}) - self.assertEqual(workcenter_child.parent_level_3_id, workcenter_parent3) - self.assertEqual(workcenter_child.parent_level_2_id, workcenter_parent2) - self.assertEqual(workcenter_child.parent_level_1_id, workcenter_parent1) - - def test_compute_parent_level3_bis(self): - workcenter_child = self.env.ref("mrp_workcenter_hierarchical.mrp_workcenter_C") - workcenter_parent3 = self.env.ref( - "mrp_workcenter_hierarchical.mrp_workcenter_A" - ) - workcenter_parent4 = self.env.ref( - "mrp_workcenter_hierarchical.mrp_workcenter_B" - ) - workcenter_parent4.write({"parent_id": workcenter_parent3.id}) - workcenter_child.write({"parent_id": workcenter_parent4.id}) - self.assertEqual(workcenter_child.parent_id, workcenter_parent4) + workcenter.write({"parent_id": get_record("workc_12").id}) + assert workcenter.parent_level_3_id == get_record("workc_123") + assert workcenter.parent_level_2_id == get_record("workc_1234") + assert workcenter.parent_level_1_id == get_record("workc_12345") diff --git a/mrp_workcenter_hierarchical/views/workcenter_view.xml b/mrp_workcenter_hierarchical/views/workcenter_view.xml index 15314e909..0be32e6aa 100644 --- a/mrp_workcenter_hierarchical/views/workcenter_view.xml +++ b/mrp_workcenter_hierarchical/views/workcenter_view.xml @@ -1,44 +1,54 @@ - - - - - mrp.workcenter - - - - - - - + + + mrp.workcenter + + + + + + + + + + + + mrp.workcenter + + + + - - - mrp.workcenter - - - - - + + + + + mrp.workcenter + + + + - - - {'search_default_group_by_level_1': 1} - - - + + + + + {'search_default_group_by_level_1': 1} + + +