mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
94
mrp_production_hierarchy/README.rst
Normal file
94
mrp_production_hierarchy/README.rst
Normal file
@@ -0,0 +1,94 @@
|
||||
===========================
|
||||
Production Orders Hierarchy
|
||||
===========================
|
||||
|
||||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
|
||||
:target: https://odoo-community.org/page/development-status
|
||||
:alt: Beta
|
||||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
|
||||
: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
|
||||
: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
|
||||
: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
|
||||
:alt: Try me on Runbot
|
||||
|
||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||
|
||||
This module allows to view the hierarchy of generated production orders
|
||||
when several levels of bill of materials are involved.
|
||||
|
||||
**Table of contents**
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
|
||||
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
|
||||
|
||||
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 smashing it by providing a detailed and welcomed
|
||||
`feedback <https://github.com/OCA/manufacture/issues/new?body=module:%20mrp_production_hierarchy%0Aversion:%2010.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.
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Authors
|
||||
~~~~~~~
|
||||
|
||||
* ABF OSIELL
|
||||
|
||||
Contributors
|
||||
~~~~~~~~~~~~
|
||||
|
||||
* Sébastien Alix <sebastien.alix@osiell.com> (https://osiell.com)
|
||||
|
||||
Maintainers
|
||||
~~~~~~~~~~~
|
||||
|
||||
This module is maintained by the OCA.
|
||||
|
||||
.. image:: https://odoo-community.org/logo.png
|
||||
:alt: Odoo Community Association
|
||||
:target: https://odoo-community.org
|
||||
|
||||
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 <https://github.com/OCA/manufacture/tree/10.0/mrp_production_hierarchy>`_ project on GitHub.
|
||||
|
||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||
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",
|
||||
],
|
||||
}
|
||||
60
mrp_production_hierarchy/i18n/fr.po
Normal file
60
mrp_production_hierarchy/i18n/fr.po
Normal file
@@ -0,0 +1,60 @@
|
||||
# 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-06-05 13:37+0000\n"
|
||||
"PO-Revision-Date: 2018-06-05 13:37+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:46
|
||||
#: 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
|
||||
#: model:ir.ui.view,arch_db:mrp_production_hierarchy.view_mrp_production_filter
|
||||
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"
|
||||
|
||||
#. module: mrp_production_hierarchy
|
||||
#: model:ir.model.fields,field_description:mrp_production_hierarchy.field_mrp_production_root_id
|
||||
#: model:ir.ui.view,arch_db:mrp_production_hierarchy.view_mrp_production_filter
|
||||
msgid "Root order"
|
||||
msgstr "OF racine"
|
||||
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
|
||||
53
mrp_production_hierarchy/models/mrp_production.py
Normal file
53
mrp_production_hierarchy/models/mrp_production.py
Normal file
@@ -0,0 +1,53 @@
|
||||
# -*- 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'
|
||||
|
||||
root_id = fields.Many2one(
|
||||
'mrp.production', u"Root order",
|
||||
index=True, ondelete='restrict', readonly=True)
|
||||
parent_id = fields.Many2one(
|
||||
'mrp.production', u"Parent order",
|
||||
index=True, ondelete='restrict', readonly=True)
|
||||
child_ids = fields.One2many(
|
||||
'mrp.production', 'parent_id', u"Child orders",
|
||||
domain=[('state', '!=', 'cancel')])
|
||||
|
||||
@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.
|
||||
"""
|
||||
for prod in self:
|
||||
# Set the initial root production order ID
|
||||
if not prod.env.context.get('root_mrp_production_id'):
|
||||
prod = prod.with_context(root_mrp_production_id=self.id)
|
||||
# Set the parent production order ID
|
||||
prod = prod.with_context(parent_mrp_production_id=self.id)
|
||||
super(MrpProduction, prod)._generate_moves()
|
||||
return True
|
||||
|
||||
@api.multi
|
||||
def open_production_tree(self):
|
||||
self.ensure_one()
|
||||
if self.child_ids:
|
||||
return {
|
||||
'domain': "[('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
|
||||
27
mrp_production_hierarchy/models/procurement_order.py
Normal file
27
mrp_production_hierarchy/models/procurement_order.py
Normal file
@@ -0,0 +1,27 @@
|
||||
# -*- 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 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
|
||||
1
mrp_production_hierarchy/readme/CONTRIBUTORS.rst
Normal file
1
mrp_production_hierarchy/readme/CONTRIBUTORS.rst
Normal file
@@ -0,0 +1 @@
|
||||
* Sébastien Alix <sebastien.alix@osiell.com> (https://osiell.com)
|
||||
2
mrp_production_hierarchy/readme/DESCRIPTION.rst
Normal file
2
mrp_production_hierarchy/readme/DESCRIPTION.rst
Normal file
@@ -0,0 +1,2 @@
|
||||
This module allows to view the hierarchy of generated production orders
|
||||
when several levels of bill of materials are involved.
|
||||
1
mrp_production_hierarchy/readme/ROADMAP.rst
Normal file
1
mrp_production_hierarchy/readme/ROADMAP.rst
Normal file
@@ -0,0 +1 @@
|
||||
* Only new production orders will benefit from this feature, it is not compatible with existing orders.
|
||||
11
mrp_production_hierarchy/readme/USAGE.rst
Normal file
11
mrp_production_hierarchy/readme/USAGE.rst
Normal file
@@ -0,0 +1,11 @@
|
||||
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
|
||||
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: 76 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 36 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,41 @@
|
||||
# -*- 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):
|
||||
# bom_3 (product_6) -> bom_2 (product_5) -> bom_1 (product_4)
|
||||
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)
|
||||
self.assertIn(
|
||||
self.bom_2.product_id, man_order.child_ids.mapped('product_id'))
|
||||
for child in man_order.child_ids:
|
||||
self.assertIn(child.product_id, [self.product_5, self.product_4])
|
||||
self.assertEqual(child.root_id, man_order)
|
||||
self.assertEqual(child.parent_id, man_order)
|
||||
if child.product_id == self.bom_2.product_id:
|
||||
self.assertTrue(child.child_ids)
|
||||
self.assertTrue(child.open_production_tree())
|
||||
for child2 in child.child_ids:
|
||||
self.assertIn(child2.product_id, [self.product_4])
|
||||
self.assertEqual(child2.root_id, man_order)
|
||||
self.assertEqual(child2.parent_id, child)
|
||||
self.assertTrue(man_order.open_production_tree())
|
||||
65
mrp_production_hierarchy/views/mrp_production.xml
Normal file
65
mrp_production_hierarchy/views/mrp_production.xml
Normal file
@@ -0,0 +1,65 @@
|
||||
<?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 name="origin" position="after">
|
||||
<field name="root_id" attrs="{'invisible': [('root_id', '=', False)]}"/>
|
||||
<field name="parent_id" attrs="{'invisible': [('parent_id', '=', False)]}"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="mrp_production_tree_view" model="ir.ui.view">
|
||||
<field name="name">mrp.production.tree</field>
|
||||
<field name="model">mrp.production</field>
|
||||
<field name="mode">extension</field>
|
||||
<field name="inherit_id" ref="mrp.mrp_production_tree_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="name" position="before">
|
||||
<field name="root_id"/>
|
||||
<field name="parent_id"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_mrp_production_filter" model="ir.ui.view">
|
||||
<field name="name">mrp.production.search.inherit</field>
|
||||
<field name="model">mrp.production</field>
|
||||
<field name="inherit_id" ref="mrp.view_mrp_production_filter"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//group[last()]" position="inside">
|
||||
<filter name="group_by_root_id" string="Root order"
|
||||
domain="[]"
|
||||
context="{'group_by': 'root_id'}"/>
|
||||
<filter name="group_by_parent_id" string="Parent order"
|
||||
domain="[]"
|
||||
context="{'group_by': 'parent_id'}"/>
|
||||
</xpath>
|
||||
</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