diff --git a/mrp_workcenter_hierarchical/README.rst b/mrp_workcenter_hierarchical/README.rst new file mode 100644 index 000000000..9e2514ac3 --- /dev/null +++ b/mrp_workcenter_hierarchical/README.rst @@ -0,0 +1,17 @@ +Description +=========== + +See __openerp__.py + +Define your workcenter groups +----------------------------- + + .. image:: static/description/group.png + :alt: Define your workcenter groups on Odoo ERP + + +Attach a group to your workcenter +--------------------------------- + + .. image:: static/description/workc.png + :alt: Attach a group to your workcenter with Odoo ERP diff --git a/mrp_workcenter_hierarchical/__init__.py b/mrp_workcenter_hierarchical/__init__.py new file mode 100644 index 000000000..d6571b201 --- /dev/null +++ b/mrp_workcenter_hierarchical/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (C) All Rights Reserved 2015 Akretion +# @author David BEAL +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################### + +from . import workcenter diff --git a/mrp_workcenter_hierarchical/__openerp__.py b/mrp_workcenter_hierarchical/__openerp__.py new file mode 100644 index 000000000..0dc0392f3 --- /dev/null +++ b/mrp_workcenter_hierarchical/__openerp__.py @@ -0,0 +1,93 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (C) All Rights Reserved 2015 Akretion +# @author David BEAL +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################### + + +{ + 'name': 'MRP Workcenter Hierarchical', + 'version': '0.5', + 'author': 'Akretion,Odoo Community Association (OCA)', + 'summary': "Organise Workcenters by section", + 'category': 'Manufacturing', + 'depends': [ + 'mrp_operations', + ], + 'description': """ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :alt: License + +MRP Workcenter Hierarchical +=============================== + +* Add the possibility to define a parent workcenter to a workcenter + +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 + +Usage +===== + +To use this module, you need to go to: + + * Manufacturing > Configuration > Workcenter Hierarchical + + +Credits +======= + +Contributors +------------ + +* David BEAL +* Sébastien BEAU + +Maintainer +---------- + +.. image:: http://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: http://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 http://odoo-community.org. +""", + 'website': 'http://www.akretion.com/', + 'data': [ + 'workcenter_view.xml', + ], + 'demo': [ + ], + 'license': 'AGPL-3', + 'tests': [], + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/mrp_workcenter_hierarchical/i18n/mrp_workcenter_group.pot b/mrp_workcenter_hierarchical/i18n/mrp_workcenter_group.pot new file mode 100644 index 000000000..b404fd8d9 --- /dev/null +++ b/mrp_workcenter_hierarchical/i18n/mrp_workcenter_group.pot @@ -0,0 +1,62 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * mrp_workcenter_group +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-03-19 10:15+0000\n" +"PO-Revision-Date: 2015-03-19 10:15+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_workcenter_group +#: field:workcenter.group,active:0 +msgid "Active" +msgstr "" + +#. module: mrp_workcenter_group +#: view:mrp.workcenter:0 +#: field:mrp.workcenter,workcenter_group_id:0 +#: view:workcenter.group:0 +msgid "Group" +msgstr "" + +#. module: mrp_workcenter_group +#: view:workcenter.group:0 +#: field:workcenter.group,workcenter_ids:0 +msgid "Linked Workcenters" +msgstr "" + +#. module: mrp_workcenter_group +#: field:workcenter.group,name:0 +msgid "Name" +msgstr "" + +#. module: mrp_workcenter_group +#: field:workcenter.group,sequence:0 +msgid "Sequence" +msgstr "" + +#. module: mrp_workcenter_group +#: code:_description:0 +#: model:ir.model,name:mrp_workcenter_group.model_mrp_workcenter +#, python-format +msgid "Work Center" +msgstr "" + +#. module: mrp_workcenter_group +#: code:_description:0 +#: model:ir.actions.act_window,name:mrp_workcenter_group.act_open_workcenter_group_view +#: model:ir.model,name:mrp_workcenter_group.model_workcenter_group +#: model:ir.ui.menu,name:mrp_workcenter_group.menu_mrp_workcenter_group +#: view:workcenter.group:0 +#, python-format +msgid "Workcenter Groups" +msgstr "" + diff --git a/mrp_workcenter_hierarchical/static/description/group.png b/mrp_workcenter_hierarchical/static/description/group.png new file mode 100644 index 000000000..f61dcd097 Binary files /dev/null and b/mrp_workcenter_hierarchical/static/description/group.png differ diff --git a/mrp_workcenter_hierarchical/static/description/index.html b/mrp_workcenter_hierarchical/static/description/index.html new file mode 100644 index 000000000..3b1eb19c4 --- /dev/null +++ b/mrp_workcenter_hierarchical/static/description/index.html @@ -0,0 +1,22 @@ + +
+ +
+

Workcenter Groups

+

An OCA module : validated by Odoo community experts

+

By Akretion

+
+ +

Workcenter Groups

+ + + + +

Define your workcenter groups



Attach a group to your workcenter



+ + + +
diff --git a/mrp_workcenter_hierarchical/static/description/workc.png b/mrp_workcenter_hierarchical/static/description/workc.png new file mode 100644 index 000000000..d20197176 Binary files /dev/null and b/mrp_workcenter_hierarchical/static/description/workc.png differ diff --git a/mrp_workcenter_hierarchical/static/src/img/icon.png b/mrp_workcenter_hierarchical/static/src/img/icon.png new file mode 100644 index 000000000..99ee21578 Binary files /dev/null and b/mrp_workcenter_hierarchical/static/src/img/icon.png differ diff --git a/mrp_workcenter_hierarchical/workcenter.py b/mrp_workcenter_hierarchical/workcenter.py new file mode 100644 index 000000000..9d21bad29 --- /dev/null +++ b/mrp_workcenter_hierarchical/workcenter.py @@ -0,0 +1,108 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: David BEAL +# Copyright 2015 Akretion +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp.osv import orm, fields + +class MrpWorkcenter(orm.Model): + _inherit = 'mrp.workcenter' + _order = 'parent_left' + + def _get_workcenter_ids_to_recompute_level(self, cr, uid, ids, context=None): + return self.search(cr, uid, [ + '|', + ('parent_id', 'child_of', ids), + ('id', 'in', ids), + ]) + + def _get_parent_ids(self, workcenter): + if workcenter.parent_id: + ids = self._get_parent_ids(workcenter.parent_id) + ids.append(workcenter.parent_id.id) + else: + ids = [] + return ids + + def _get_parent_level(self, cr, uid, ids, field_name, args, context=None): + result = {} + def get_next_level(parent_ids, workcenter): + return parent_ids and parent_ids.pop(0) or ( + workcenter.child_ids and workcenter.id + or workcenter.parent_id.id) + + for workcenter in self.browse(cr, uid, ids, context=context): + parent_ids = self._get_parent_ids(workcenter) + parent_level_1_id = get_next_level(parent_ids, workcenter) + parent_level_2_id = get_next_level(parent_ids, workcenter) + parent_level_3_id = get_next_level(parent_ids, workcenter) + result[workcenter.id] = { + 'parent_level_1_id': parent_level_1_id, + 'parent_level_2_id': parent_level_2_id, + 'parent_level_3_id': parent_level_3_id, + } + return result + + _columns = { + 'parent_id': fields.many2one( + 'mrp.workcenter', + string='Parent'), + 'child_ids': fields.one2many( + 'mrp.workcenter', + 'parent_id', + string='Children'), + 'parent_level_1_id': fields.function( + _get_parent_level, + relation='mrp.workcenter', + type='many2one', + string='Parent Level 1', + multi='parent_level', + store={ + 'mrp.workcenter': ( + _get_workcenter_ids_to_recompute_level, + ['parent_id'], + 10), + },), + 'parent_level_2_id': fields.function( + _get_parent_level, + relation='mrp.workcenter', + type='many2one', + string='Parent Level 2', + multi='parent_level', + store={ + 'mrp.workcenter': ( + _get_workcenter_ids_to_recompute_level, + ['parent_id'], + 10), + },), + 'parent_level_3_id': fields.function( + _get_parent_level, + relation='mrp.workcenter', + type='many2one', + string='Parent Level 3', + multi='parent_level', + store={ + 'mrp.workcenter': ( + _get_workcenter_ids_to_recompute_level, + ['parent_id'], + 10), + },), + 'parent_left': fields.integer('Left Parent', select=1), + 'parent_right': fields.integer('Right Parent', select=1), + } diff --git a/mrp_workcenter_hierarchical/workcenter_view.xml b/mrp_workcenter_hierarchical/workcenter_view.xml new file mode 100644 index 000000000..ba87ef4ac --- /dev/null +++ b/mrp_workcenter_hierarchical/workcenter_view.xml @@ -0,0 +1,33 @@ + + + + + + + + mrp.workcenter + + + + + + + + + + + + mrp.workcenter + + + + + + + + + +