mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[ADD] New module 'mrp_production_hierarchy'
This commit is contained in:
72
mrp_production_hierarchy/README.rst
Normal file
72
mrp_production_hierarchy/README.rst
Normal file
@@ -0,0 +1,72 @@
|
||||
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png
|
||||
:target: https://www.gnu.org/licenses/agpl
|
||||
:alt: License: AGPL-3
|
||||
|
||||
===========================
|
||||
Production Orders Hierarchy
|
||||
===========================
|
||||
|
||||
This module allows to view the hierarchy of generated production orders
|
||||
when several levels of bill of materials are involved.
|
||||
|
||||
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:
|
||||
|
||||
.. figure:: 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:: mrp_production_hierarchy/static/description/mrp_production_hierarchy_3.png
|
||||
|
||||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
|
||||
:alt: Try me on Runbot
|
||||
:target: https://runbot.odoo-community.org/runbot/129/10.0
|
||||
|
||||
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
|
||||
<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 smash it by providing detailed and welcomed feedback.
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Images
|
||||
------
|
||||
|
||||
* Odoo Community Association: `Icon <https://odoo-community.org/logo.png>`_.
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
||||
* Sébastien Alix <sebastien.alix@osiell.com> (https://osiell.com)
|
||||
|
||||
Do not contact contributors directly about support or help with technical issues.
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
|
||||
.. image:: https://odoo-community.org/logo.png
|
||||
:alt: Odoo Community Association
|
||||
:target: https://odoo-community.org
|
||||
|
||||
This module is maintained by the OCA.
|
||||
|
||||
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.
|
||||
|
||||
To contribute to this module, please visit https://odoo-community.org.
|
||||
2
mrp_production_hierarchy/__init__.py
Normal file
2
mrp_production_hierarchy/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from . import models
|
||||
20
mrp_production_hierarchy/__manifest__.py
Normal file
20
mrp_production_hierarchy/__manifest__.py
Normal file
@@ -0,0 +1,20 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2018 ABF OSIELL <http://osiell.com>
|
||||
# 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",
|
||||
"category": "Manufacturing",
|
||||
"website": "https://github.com/OCA/manufacture",
|
||||
"author": "ABF OSIELL, Odoo Community Association (OCA)",
|
||||
"license": "AGPL-3",
|
||||
"application": False,
|
||||
"installable": True,
|
||||
"depends": [
|
||||
"mrp",
|
||||
],
|
||||
"data": [
|
||||
"views/mrp_production.xml",
|
||||
],
|
||||
}
|
||||
53
mrp_production_hierarchy/i18n/fr.po
Normal file
53
mrp_production_hierarchy/i18n/fr.po
Normal file
@@ -0,0 +1,53 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * mrp_production_hierarchy
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 10.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2018-05-18 13:30+0000\n"
|
||||
"PO-Revision-Date: 2018-05-18 13:30+0000\n"
|
||||
"Last-Translator: <>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Plural-Forms: \n"
|
||||
|
||||
#. module: mrp_production_hierarchy
|
||||
#: model:ir.model.fields,field_description:mrp_production_hierarchy.field_mrp_production_child_ids
|
||||
msgid "Child orders"
|
||||
msgstr "OF générés"
|
||||
|
||||
#. module: mrp_production_hierarchy
|
||||
#: code:addons/mrp_production_hierarchy/models/mrp_production.py:37
|
||||
#: model:ir.ui.view,arch_db:mrp_production_hierarchy.mrp_production_form_view
|
||||
#, python-format
|
||||
msgid "Hierarchy"
|
||||
msgstr "Hiérarchie"
|
||||
|
||||
#. module: mrp_production_hierarchy
|
||||
#: model:ir.model.fields,field_description:mrp_production_hierarchy.field_mrp_production_parent_left
|
||||
msgid "Left Parent"
|
||||
msgstr "Parent gauche"
|
||||
|
||||
#. module: mrp_production_hierarchy
|
||||
#: model:ir.model,name:mrp_production_hierarchy.model_mrp_production
|
||||
msgid "Manufacturing Order"
|
||||
msgstr "Ordre de fabrication"
|
||||
|
||||
#. module: mrp_production_hierarchy
|
||||
#: model:ir.model.fields,field_description:mrp_production_hierarchy.field_mrp_production_parent_id
|
||||
msgid "Parent order"
|
||||
msgstr "OF d'origine"
|
||||
|
||||
#. module: mrp_production_hierarchy
|
||||
#: model:ir.model,name:mrp_production_hierarchy.model_procurement_order
|
||||
msgid "Procurement"
|
||||
msgstr "Approvisionnement"
|
||||
|
||||
#. module: mrp_production_hierarchy
|
||||
#: model:ir.model.fields,field_description:mrp_production_hierarchy.field_mrp_production_parent_right
|
||||
msgid "Right Parent"
|
||||
msgstr "Parent à droite"
|
||||
54
mrp_production_hierarchy/i18n/mrp_production_hierarchy.pot
Normal file
54
mrp_production_hierarchy/i18n/mrp_production_hierarchy.pot
Normal file
@@ -0,0 +1,54 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * mrp_production_hierarchy
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 10.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2018-05-18 13:30+0000\n"
|
||||
"PO-Revision-Date: 2018-05-18 13:30+0000\n"
|
||||
"Last-Translator: <>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Plural-Forms: \n"
|
||||
|
||||
#. module: mrp_production_hierarchy
|
||||
#: model:ir.model.fields,field_description:mrp_production_hierarchy.field_mrp_production_child_ids
|
||||
msgid "Child orders"
|
||||
msgstr ""
|
||||
|
||||
#. module: mrp_production_hierarchy
|
||||
#: code:addons/mrp_production_hierarchy/models/mrp_production.py:37
|
||||
#: model:ir.ui.view,arch_db:mrp_production_hierarchy.mrp_production_form_view
|
||||
#, python-format
|
||||
msgid "Hierarchy"
|
||||
msgstr ""
|
||||
|
||||
#. module: mrp_production_hierarchy
|
||||
#: model:ir.model.fields,field_description:mrp_production_hierarchy.field_mrp_production_parent_left
|
||||
msgid "Left Parent"
|
||||
msgstr ""
|
||||
|
||||
#. module: mrp_production_hierarchy
|
||||
#: model:ir.model,name:mrp_production_hierarchy.model_mrp_production
|
||||
msgid "Manufacturing Order"
|
||||
msgstr ""
|
||||
|
||||
#. module: mrp_production_hierarchy
|
||||
#: model:ir.model.fields,field_description:mrp_production_hierarchy.field_mrp_production_parent_id
|
||||
msgid "Parent order"
|
||||
msgstr ""
|
||||
|
||||
#. module: mrp_production_hierarchy
|
||||
#: model:ir.model,name:mrp_production_hierarchy.model_procurement_order
|
||||
msgid "Procurement"
|
||||
msgstr ""
|
||||
|
||||
#. module: mrp_production_hierarchy
|
||||
#: model:ir.model.fields,field_description:mrp_production_hierarchy.field_mrp_production_parent_right
|
||||
msgid "Right Parent"
|
||||
msgstr ""
|
||||
|
||||
3
mrp_production_hierarchy/models/__init__.py
Normal file
3
mrp_production_hierarchy/models/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from . import mrp_production
|
||||
from . import procurement_order
|
||||
48
mrp_production_hierarchy/models/mrp_production.py
Normal file
48
mrp_production_hierarchy/models/mrp_production.py
Normal file
@@ -0,0 +1,48 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2018 ABF OSIELL <http://osiell.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
|
||||
|
||||
class MrpProduction(models.Model):
|
||||
_inherit = 'mrp.production'
|
||||
_parent_name = "parent_id"
|
||||
_parent_store = True
|
||||
_parent_order = 'name'
|
||||
|
||||
parent_id = fields.Many2one(
|
||||
'mrp.production', u"Parent order",
|
||||
index=True, ondelete='restrict')
|
||||
child_ids = fields.One2many(
|
||||
'mrp.production', 'parent_id', u"Child orders")
|
||||
parent_left = fields.Integer('Left Parent', index=True)
|
||||
parent_right = fields.Integer('Right Parent', index=True)
|
||||
|
||||
@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
|
||||
set the parent relation between production orders.
|
||||
"""
|
||||
self = self.with_context(parent_mrp_production_id=self.id)
|
||||
return super(MrpProduction, self)._generate_moves()
|
||||
|
||||
@api.multi
|
||||
def open_production_tree(self):
|
||||
self.ensure_one()
|
||||
if self.child_ids:
|
||||
return {
|
||||
'domain': "[('parent_id', '=', %s)]" % 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,
|
||||
'target': 'current',
|
||||
'type': 'ir.actions.act_window',
|
||||
'context': dict(self.env.context),
|
||||
}
|
||||
return False
|
||||
21
mrp_production_hierarchy/models/procurement_order.py
Normal file
21
mrp_production_hierarchy/models/procurement_order.py
Normal file
@@ -0,0 +1,21 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2018 ABF OSIELL <http://osiell.com>
|
||||
# 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 parent production order ID to its childs."""
|
||||
res = super(ProcurementOrder, self).make_mo()
|
||||
production_ids = res.values()
|
||||
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']
|
||||
production.parent_id = parent_id
|
||||
return res
|
||||
BIN
mrp_production_hierarchy/static/description/icon.png
Normal file
BIN
mrp_production_hierarchy/static/description/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 50 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 77 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
5
mrp_production_hierarchy/tests/__init__.py
Normal file
5
mrp_production_hierarchy/tests/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2018 ABF OSIELL <http://osiell.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import test_mrp_production_hierarchy
|
||||
@@ -0,0 +1,30 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2018 ABF OSIELL <http://osiell.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo.addons.mrp.tests.common import TestMrpCommon
|
||||
|
||||
|
||||
class TestMrpProductionHierarchy(TestMrpCommon):
|
||||
|
||||
def setUp(self):
|
||||
super(TestMrpProductionHierarchy, self).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')
|
||||
(self.bom_1 | self.bom_2 | self.bom_3).mapped('product_id').write(
|
||||
{'route_ids': [(6, 0, [route_manufacture.id, route_mto.id])]})
|
||||
|
||||
def test_production_hierarchy(self):
|
||||
man_order = self.env['mrp.production'].create({
|
||||
'name': 'MO-Test',
|
||||
'product_id': self.product_6.id,
|
||||
'product_uom_id': self.product_6.uom_id.id,
|
||||
'product_qty': 2,
|
||||
'bom_id': self.bom_3.id,
|
||||
})
|
||||
self.assertEqual(len(man_order.child_ids), 2)
|
||||
for child in man_order.child_ids:
|
||||
self.assertIn(child.product_id, [self.product_5, self.product_4])
|
||||
for child2 in child.child_ids:
|
||||
self.assertIn(child2.product_id, [self.product_4])
|
||||
32
mrp_production_hierarchy/views/mrp_production.xml
Normal file
32
mrp_production_hierarchy/views/mrp_production.xml
Normal file
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="mrp_production_form_view" model="ir.ui.view">
|
||||
<field name="name">mrp.production.form</field>
|
||||
<field name="model">mrp.production</field>
|
||||
<field name="inherit_id" ref="mrp.mrp_production_form_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<div name="button_box" position="inside">
|
||||
<field name="child_ids" invisible="1"/>
|
||||
<button name="open_production_tree" type="object"
|
||||
string="Hierarchy" class="oe_stat_button"
|
||||
icon="fa-sitemap"
|
||||
attrs="{'invisible': [('child_ids', '=', [])]}"/>
|
||||
</div>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- New tree view based on the standard one but with 'field_parent' configured. -->
|
||||
<record id="mrp_production_tree_view_field_parent" model="ir.ui.view">
|
||||
<field name="name">mrp.production.tree</field>
|
||||
<field name="model">mrp.production</field>
|
||||
<field name="field_parent">child_ids</field>
|
||||
<field name="mode">primary</field>
|
||||
<field name="inherit_id" ref="mrp.mrp_production_tree_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<tree position="inside">
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user