mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[ADD] add mrp_workcenter_hierarchical
This commit is contained in:
committed by
David Beal
parent
90f5f75889
commit
0268cbc9e7
17
mrp_workcenter_hierarchical/README.rst
Normal file
17
mrp_workcenter_hierarchical/README.rst
Normal file
@@ -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
|
||||
22
mrp_workcenter_hierarchical/__init__.py
Normal file
22
mrp_workcenter_hierarchical/__init__.py
Normal file
@@ -0,0 +1,22 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (C) All Rights Reserved 2015 Akretion
|
||||
# @author David BEAL <david.beal@akretion.com>
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
from . import workcenter
|
||||
93
mrp_workcenter_hierarchical/__openerp__.py
Normal file
93
mrp_workcenter_hierarchical/__openerp__.py
Normal file
@@ -0,0 +1,93 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (C) All Rights Reserved 2015 Akretion
|
||||
# @author David BEAL <david.beal@akretion.com>
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
|
||||
{
|
||||
'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 <david.beal@akretion.com>
|
||||
* Sébastien BEAU <sebastien.beau@akretion.com>
|
||||
|
||||
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,
|
||||
}
|
||||
62
mrp_workcenter_hierarchical/i18n/mrp_workcenter_group.pot
Normal file
62
mrp_workcenter_hierarchical/i18n/mrp_workcenter_group.pot
Normal file
@@ -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 ""
|
||||
|
||||
BIN
mrp_workcenter_hierarchical/static/description/group.png
Normal file
BIN
mrp_workcenter_hierarchical/static/description/group.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 37 KiB |
22
mrp_workcenter_hierarchical/static/description/index.html
Normal file
22
mrp_workcenter_hierarchical/static/description/index.html
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
<section class="oe_container oe_website_only">
|
||||
|
||||
<div class="oe_row oe_more_spaced">
|
||||
<h3 class="oe_slogan">Workcenter Groups</h3>
|
||||
<h3 class="oe_slogan"><a href="http://odoo-community.org/">An OCA module</a> : validated by Odoo community experts</h3>
|
||||
<h4 class="oe_slogan"><a href="http://www.akretion.com/fr">By Akretion</a></h4>
|
||||
<div class="oe_span6">
|
||||
|
||||
<h2>Workcenter Groups</h2>
|
||||
|
||||
<table>
|
||||
<tr><td><h3>Define your workcenter groups</h3><div class="oe_row_img oe_centered"><img class="oe_picture" width="80%" src="group.png"></div><br/><br/></td></tr>
|
||||
<tr><td><h3>Attach a group to your workcenter</h3><div class="oe_row_img oe_centered"><img class="oe_picture" src="workc.png"></div><br/><br/></td></tr>
|
||||
</table>
|
||||
|
||||
<div class="oe_row oe_centeralign oe_more_space">
|
||||
<a href="http://www.akretion.com/contact" class="oe_button oe_big">Contact us</a><br>
|
||||
<a href="https://github.com/OCA/manufacture/tree/7.0" class="oe_button oe_big">Access to the code</a>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
BIN
mrp_workcenter_hierarchical/static/description/workc.png
Normal file
BIN
mrp_workcenter_hierarchical/static/description/workc.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
BIN
mrp_workcenter_hierarchical/static/src/img/icon.png
Normal file
BIN
mrp_workcenter_hierarchical/static/src/img/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.6 KiB |
108
mrp_workcenter_hierarchical/workcenter.py
Normal file
108
mrp_workcenter_hierarchical/workcenter.py
Normal file
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
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),
|
||||
}
|
||||
33
mrp_workcenter_hierarchical/workcenter_view.xml
Normal file
33
mrp_workcenter_hierarchical/workcenter_view.xml
Normal file
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<!--Workcenters-->
|
||||
|
||||
<record id="view_mrp_workcenter_search" model="ir.ui.view">
|
||||
<field name="model">mrp.workcenter</field>
|
||||
<field name="inherit_id" ref="mrp.view_mrp_workcenter_search"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//filter[@string='Type']" position="before">
|
||||
<filter string="Parent Level 1" domain="[]" name="group_by_level_1"
|
||||
context="{'group_by':'parent_level_1_id'}"/>
|
||||
<filter string="Parent Level 2" domain="[]" name="group_by_level_2"
|
||||
context="{'group_by':'parent_level_2_id'}"/>
|
||||
<filter string="Parent Level 3" domain="[]" name="group_by_level_3"
|
||||
context="{'group_by':'parent_level_3_id'}"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="mrp_workcenter_view" model="ir.ui.view">
|
||||
<field name="model">mrp.workcenter</field>
|
||||
<field name="inherit_id" ref="mrp.mrp_workcenter_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="active" position="after">
|
||||
<field name="parent_id"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
Reference in New Issue
Block a user