diff --git a/mrp_production_hierarchy/README.rst b/mrp_production_hierarchy/README.rst index 88d67e140..cd0fcca60 100644 --- a/mrp_production_hierarchy/README.rst +++ b/mrp_production_hierarchy/README.rst @@ -14,13 +14,13 @@ Production Orders Hierarchy :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/10.0/mrp_production_hierarchy + :target: https://github.com/OCA/manufacture/tree/12.0/mrp_production_hierarchy :alt: OCA/manufacture .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/manufacture-10-0/manufacture-10-0-mrp_production_hierarchy + :target: https://translation.odoo-community.org/projects/manufacture-12-0/manufacture-12-0-mrp_production_hierarchy :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/10.0 + :target: https://runbot.odoo-community.org/runbot/129/12.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -40,13 +40,13 @@ Create a new production order (Manufacture / Operations / Manufacturing Orders) with a multi-levels nomenclatured product, and related products configured with 'Manufacture' and 'Make To Order' routes: -.. figure:: mrp_production_hierarchy/static/description/mrp_production_hierarchy_1.png +.. figure:: https://raw.githubusercontent.com/OCA/manufacture/12.0/mrp_production_hierarchy/static/description/mrp_production_hierarchy_1.png Once saved, click on the 'Hierarchy' button at right: -.. figure:: mrp_production_hierarchy/static/description/mrp_production_hierarchy_2.png +.. figure:: https://raw.githubusercontent.com/OCA/manufacture/12.0/mrp_production_hierarchy/static/description/mrp_production_hierarchy_2.png -.. figure:: mrp_production_hierarchy/static/description/mrp_production_hierarchy_3.png +.. figure:: https://raw.githubusercontent.com/OCA/manufacture/12.0/mrp_production_hierarchy/static/description/mrp_production_hierarchy_3.png Known issues / Roadmap ====================== @@ -59,7 +59,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. @@ -70,11 +70,13 @@ Authors ~~~~~~~ * ABF OSIELL +* Sergio Corato Contributors ~~~~~~~~~~~~ * Sébastien Alix (https://osiell.com) +* Sergio Corato Maintainers ~~~~~~~~~~~ @@ -89,6 +91,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_production_hierarchy/__manifest__.py b/mrp_production_hierarchy/__manifest__.py index 6c87fe3a6..04cc1996e 100644 --- a/mrp_production_hierarchy/__manifest__.py +++ b/mrp_production_hierarchy/__manifest__.py @@ -1,13 +1,14 @@ # -*- coding: utf-8 -*- # Copyright 2018 ABF OSIELL +# Copyright 2019 Sergio Corato # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { "name": "Production Orders Hierarchy", "summary": "View the hierarchy of generated production orders", - "version": "10.0.1.0.0", + "version": "12.0.1.0.0", "category": "Manufacturing", "website": "https://github.com/OCA/manufacture", - "author": "ABF OSIELL, Odoo Community Association (OCA)", + "author": "ABF OSIELL, Sergio Corato, Odoo Community Association (OCA)", "license": "AGPL-3", "application": False, "installable": True, diff --git a/mrp_production_hierarchy/models/__init__.py b/mrp_production_hierarchy/models/__init__.py index 36d8d6c54..98912d0ff 100644 --- a/mrp_production_hierarchy/models/__init__.py +++ b/mrp_production_hierarchy/models/__init__.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- from . import mrp_production -from . import procurement_order +from . import stock_rule diff --git a/mrp_production_hierarchy/models/mrp_production.py b/mrp_production_hierarchy/models/mrp_production.py index dfa9d6727..5324c1703 100644 --- a/mrp_production_hierarchy/models/mrp_production.py +++ b/mrp_production_hierarchy/models/mrp_production.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # Copyright 2018 ABF OSIELL +# Copyright 2019 Sergio Corato # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import api, fields, models, _ @@ -21,7 +22,7 @@ class MrpProduction(models.Model): @api.multi def _generate_moves(self): """Overloaded to pass the created production order ID in the context. - It will be used by the 'procurement_order.make_mo()' overload to + It will be used by the 'stock_rule._prepare_mo_vals()' overload to set the parent relation between production orders. """ for prod in self: @@ -38,16 +39,23 @@ class MrpProduction(models.Model): self.ensure_one() if self.child_ids: return { - 'domain': "[('id', '=', %s)]" % self.id, + 'domain': [('root_id', '=', self.id)], 'name': _(u"Hierarchy"), - 'view_type': 'tree', 'view_mode': 'tree', 'res_model': 'mrp.production', - 'view_id': self.env.ref( - 'mrp_production_hierarchy.' - 'mrp_production_tree_view_field_parent').id, + 'views': [ + (self.env.ref( + 'mrp_production_hierarchy.mrp_production_tree_view').id, + 'tree'), + (self.env.ref( + 'mrp_production_hierarchy.mrp_production_form_view').id, + 'form') + ], 'target': 'current', 'type': 'ir.actions.act_window', - 'context': dict(self.env.context), + 'context': dict( + self.env.context, + search_default_group_by_root_id=True, + search_default_group_by_parent_id=True), } return False diff --git a/mrp_production_hierarchy/models/procurement_order.py b/mrp_production_hierarchy/models/procurement_order.py deleted file mode 100644 index 50b50d169..000000000 --- a/mrp_production_hierarchy/models/procurement_order.py +++ /dev/null @@ -1,27 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2018 ABF OSIELL -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -from odoo import api, models - - -class ProcurementOrder(models.Model): - _inherit = 'procurement.order' - - @api.multi - def make_mo(self): - """Overload to set the root and parent production order ID to the - children production orders. - """ - res = super(ProcurementOrder, self).make_mo() - production_ids = [id_ for id_ in res.values() if id_] - productions = self.env['mrp.production'].browse(production_ids) - for production in productions: - if self.env.context.get('parent_mrp_production_id'): - parent_id = self.env.context['parent_mrp_production_id'] - root_id = self.env.context['root_mrp_production_id'] - production.write({ - 'parent_id': parent_id, - 'root_id': root_id, - }) - return res diff --git a/mrp_production_hierarchy/models/stock_rule.py b/mrp_production_hierarchy/models/stock_rule.py new file mode 100644 index 000000000..f07bb6d16 --- /dev/null +++ b/mrp_production_hierarchy/models/stock_rule.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +# Copyright 2019 Sergio Corato +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import models + + +class StockRule(models.Model): + _inherit = 'stock.rule' + + def _prepare_mo_vals(self, product_id, product_qty, product_uom, + location_id, name, origin, values, bom): + res = super()._prepare_mo_vals( + product_id, product_qty, product_uom, location_id, name, origin, + values, bom) + if self.env.context.get('parent_mrp_production_id'): + parent_id = self.env.context['parent_mrp_production_id'] + root_id = self.env.context['root_mrp_production_id'] + res.update({ + 'parent_id': parent_id, + 'root_id': root_id, + }) + return res diff --git a/mrp_production_hierarchy/readme/CONTRIBUTORS.rst b/mrp_production_hierarchy/readme/CONTRIBUTORS.rst index 68ca198d5..060bece16 100644 --- a/mrp_production_hierarchy/readme/CONTRIBUTORS.rst +++ b/mrp_production_hierarchy/readme/CONTRIBUTORS.rst @@ -1 +1,2 @@ * Sébastien Alix (https://osiell.com) +* Sergio Corato \ No newline at end of file diff --git a/mrp_production_hierarchy/readme/USAGE.rst b/mrp_production_hierarchy/readme/USAGE.rst index 34c59473f..d9c2ed3b1 100644 --- a/mrp_production_hierarchy/readme/USAGE.rst +++ b/mrp_production_hierarchy/readme/USAGE.rst @@ -2,10 +2,10 @@ Create a new production order (Manufacture / Operations / Manufacturing Orders) with a multi-levels nomenclatured product, and related products configured with 'Manufacture' and 'Make To Order' routes: -.. figure:: mrp_production_hierarchy/static/description/mrp_production_hierarchy_1.png +.. figure:: ../static/description/mrp_production_hierarchy_1.png Once saved, click on the 'Hierarchy' button at right: -.. figure:: mrp_production_hierarchy/static/description/mrp_production_hierarchy_2.png +.. figure:: ../static/description/mrp_production_hierarchy_2.png -.. figure:: mrp_production_hierarchy/static/description/mrp_production_hierarchy_3.png +.. figure:: ../static/description/mrp_production_hierarchy_3.png diff --git a/mrp_production_hierarchy/static/description/index.html b/mrp_production_hierarchy/static/description/index.html new file mode 100644 index 000000000..a12b80ef5 --- /dev/null +++ b/mrp_production_hierarchy/static/description/index.html @@ -0,0 +1,446 @@ + + + + + + +Production Orders Hierarchy + + + +
+

Production Orders Hierarchy

+ + +

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

+

This module allows to view the hierarchy of generated production orders +when several levels of bill of materials are involved.

+

Table of contents

+ +
+

Usage

+

Create a new production order (Manufacture / Operations / Manufacturing Orders) +with a multi-levels nomenclatured product, and related products configured with +‘Manufacture’ and ‘Make To Order’ routes:

+
+https://raw.githubusercontent.com/OCA/manufacture/12.0/mrp_production_hierarchy/static/description/mrp_production_hierarchy_1.png +
+

Once saved, click on the ‘Hierarchy’ button at right:

+
+https://raw.githubusercontent.com/OCA/manufacture/12.0/mrp_production_hierarchy/static/description/mrp_production_hierarchy_2.png +
+
+https://raw.githubusercontent.com/OCA/manufacture/12.0/mrp_production_hierarchy/static/description/mrp_production_hierarchy_3.png +
+
+
+

Known issues / Roadmap

+
    +
  • Only new production orders will benefit from this feature, it is not compatible with existing orders.
  • +
+
+
+

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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • ABF OSIELL
  • +
  • Sergio Corato
  • +
+
+ +
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

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

+
+
+
+ + diff --git a/mrp_production_hierarchy/static/description/mrp_production_hierarchy_1.png b/mrp_production_hierarchy/static/description/mrp_production_hierarchy_1.png index 59b485a39..35a8e538e 100644 Binary files a/mrp_production_hierarchy/static/description/mrp_production_hierarchy_1.png and b/mrp_production_hierarchy/static/description/mrp_production_hierarchy_1.png differ diff --git a/mrp_production_hierarchy/static/description/mrp_production_hierarchy_2.png b/mrp_production_hierarchy/static/description/mrp_production_hierarchy_2.png index b5abf1793..0e4f4ed31 100644 Binary files a/mrp_production_hierarchy/static/description/mrp_production_hierarchy_2.png and b/mrp_production_hierarchy/static/description/mrp_production_hierarchy_2.png differ diff --git a/mrp_production_hierarchy/static/description/mrp_production_hierarchy_3.png b/mrp_production_hierarchy/static/description/mrp_production_hierarchy_3.png index c3b0607dd..b0c567498 100644 Binary files a/mrp_production_hierarchy/static/description/mrp_production_hierarchy_3.png and b/mrp_production_hierarchy/static/description/mrp_production_hierarchy_3.png differ diff --git a/mrp_production_hierarchy/tests/test_mrp_production_hierarchy.py b/mrp_production_hierarchy/tests/test_mrp_production_hierarchy.py index f9d9465c3..598c1adce 100644 --- a/mrp_production_hierarchy/tests/test_mrp_production_hierarchy.py +++ b/mrp_production_hierarchy/tests/test_mrp_production_hierarchy.py @@ -8,7 +8,7 @@ from odoo.addons.mrp.tests.common import TestMrpCommon class TestMrpProductionHierarchy(TestMrpCommon): def setUp(self): - super(TestMrpProductionHierarchy, self).setUp() + super().setUp() self.bom_2.write({'type': 'normal'}) route_manufacture = self.env.ref('mrp.route_warehouse0_manufacture') route_mto = self.env.ref('stock.route_warehouse0_mto') diff --git a/mrp_production_hierarchy/views/mrp_production.xml b/mrp_production_hierarchy/views/mrp_production.xml index 387d2ccbb..81c63c1d8 100644 --- a/mrp_production_hierarchy/views/mrp_production.xml +++ b/mrp_production_hierarchy/views/mrp_production.xml @@ -49,17 +49,4 @@ - - - mrp.production.tree - mrp.production - child_ids - primary - - - - - - - diff --git a/setup/mrp_production_hierarchy/odoo/addons/mrp_production_hierarchy b/setup/mrp_production_hierarchy/odoo/addons/mrp_production_hierarchy new file mode 120000 index 000000000..921aafc7c --- /dev/null +++ b/setup/mrp_production_hierarchy/odoo/addons/mrp_production_hierarchy @@ -0,0 +1 @@ +../../../../mrp_production_hierarchy \ No newline at end of file diff --git a/setup/mrp_production_hierarchy/setup.py b/setup/mrp_production_hierarchy/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/mrp_production_hierarchy/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)