[IMP] mrp_operations_time_control: OCA adaptation

This commit is contained in:
Pedro M. Baeza
2015-12-07 11:28:43 +01:00
parent fce63d9bce
commit 399d6be0a2
11 changed files with 504 additions and 258 deletions

View File

@@ -0,0 +1,77 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
=======================================
Manufacturing Operations - Time control
=======================================
This module allows to control the duration of the manufacturing
operations (work orders) through the interface controls.
Configuration
=============
Go to *Settings > Manufacturing* and activate "Manage routings and work orders"
for handling the features of this module.
Usage
=====
On *Manufacturing > Manufacturing > Manufacturing Orders* or
*Manufacturing > Manufacturing > Work Orders*, you can see the existing work
orders. In each of them, there are buttons for starting, pausing or stopping
them. Pressing these buttons, there are records that are automatically created
or modified in the tab "Machine up time" for tracking the time spent.
You can also maintain this table by hand going to
*Manufacturing > Manufacturing > Operation Time Lines*.
.. 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/8.0
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:%20
mrp_operations_time_control%0Aversion:%20
8.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Credits
=======
Images
------
* Original Odoo MRP icon
* Thanks to https://openclipart.org/detail/151831/work-bench
* Thanks to https://openclipart.org/detail/3977/stopwatch-no-shading
Contributors
------------
* Mikel Arregi <mikelarregi@avanzosc.es>
* Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>
* Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
* Ana Juaristi <ajuaristio@gmail.com>
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.

View File

@@ -1,19 +1,6 @@
# -*- encoding: utf-8 -*- # -*- coding: utf-8 -*-
############################################################################## # © 2015 Avanzosc
# # © 2015 Pedro M. Baeza
# This program is free software: you can redistribute it and/or modify # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
# 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 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 models from . import models

View File

@@ -1,33 +1,21 @@
# -*- coding: utf-8 -*-
# -*- encoding: utf-8 -*- # © 2015 Avanzosc
############################################################################## # © 2015 Pedro M. Baeza
# # © 2015 Antiun Ingeniería
# This program is free software: you can redistribute it and/or modify # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
# 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 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 Operations Time Control", "name": "MRP Operations Time Control",
"version": "1.0", "version": "8.0.1.1.0",
"depends": [ "depends": [
"base",
"mrp",
"mrp_operations_extension", "mrp_operations_extension",
], ],
"author": "OdooMRP team," "license": "AGPL-3",
"AvanzOSC," "author": "OdooMRP team, "
"Serv. Tecnol. Avanzados - Pedro M. Baeza", "AvanzOSC, "
"Serv. Tecnol. Avanzados - Pedro M. Baeza, "
"Antiun Ingeniería S.L., "
"Odoo Community Association (OCA)",
"website": "http://www.odoomrp.com", "website": "http://www.odoomrp.com",
"contributors": [ "contributors": [
"Mikel Arregi <mikelarregi@avanzosc.es>", "Mikel Arregi <mikelarregi@avanzosc.es>",
@@ -36,14 +24,10 @@
"Ana Juaristi <ajuaristio@gmail.com>" "Ana Juaristi <ajuaristio@gmail.com>"
], ],
"category": "Manufacturing", "category": "Manufacturing",
"description": """
Manufacturing operations time control
""",
'data': [ 'data': [
"views/operation_time_view.xml", "views/operation_time_view.xml",
"views/mrp_production_view.xml", "views/mrp_production_view.xml",
"security/ir.model.access.csv", "security/ir.model.access.csv",
], ],
"installable": True, "installable": True,
"auto_install": False,
} }

View File

@@ -1,147 +0,0 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mrp_operations_time_control
#
# Translators:
msgid ""
msgstr ""
"Project-Id-Version: odoomrp-wip (8.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-10-07 10:43+0000\n"
"PO-Revision-Date: 2015-09-10 16:42+0000\n"
"Last-Translator: <>\n"
"Language-Team: English (United States) (http://www.transifex.com/oca/odoomrp-wip-8-0/language/en_US/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: en_US\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: mrp_operations_time_control
#: field:operation.time.line,create_uid:0
msgid "Created by"
msgstr ""
#. module: mrp_operations_time_control
#: field:operation.time.line,create_date:0
msgid "Created on"
msgstr ""
#. module: mrp_operations_time_control
#: field:operation.time.line,end_date:0
msgid "End Date"
msgstr ""
#. module: mrp_operations_time_control
#: view:mrp.production.workcenter.line:mrp_operations_time_control.operation_time_tree_view
msgid "Finished"
msgstr ""
#. module: mrp_operations_time_control
#: view:operation.time.line:mrp_operations_time_control.view_operation_time_lines_search
msgid "Group By..."
msgstr ""
#. module: mrp_operations_time_control
#: field:operation.time.line,id:0
msgid "ID"
msgstr ""
#. module: mrp_operations_time_control
#: view:mrp.production:mrp_operations_time_control.mrp_production_operation_time_form_view
#: view:mrp.production.workcenter.line:mrp_operations_time_control.operation_time_form_view
msgid "Information"
msgstr ""
#. module: mrp_operations_time_control
#: field:operation.time.line,write_uid:0
msgid "Last Updated by"
msgstr ""
#. module: mrp_operations_time_control
#: field:operation.time.line,write_date:0
msgid "Last Updated on"
msgstr ""
#. module: mrp_operations_time_control
#: model:ir.actions.act_window,name:mrp_operations_time_control.operation_time_lines_action
#: model:ir.ui.menu,name:mrp_operations_time_control.menu_operation_time_lines_action
#: field:mrp.production.workcenter.line,operation_time_lines:0
msgid "Operation Time Lines"
msgstr ""
#. module: mrp_operations_time_control
#: field:operation.time.line,operation_time:0
msgid "Operation time"
msgstr ""
#. module: mrp_operations_time_control
#: view:operation.time.line:mrp_operations_time_control.operation_time_lines_form_view
#: view:operation.time.line:mrp_operations_time_control.operation_time_lines_tree_view
msgid "Operation time lines"
msgstr ""
#. module: mrp_operations_time_control
#: view:mrp.production.workcenter.line:mrp_operations_time_control.operation_time_tree_view
msgid "Pending"
msgstr ""
#. module: mrp_operations_time_control
#: field:operation.time.line,production:0
msgid "Production"
msgstr ""
#. module: mrp_operations_time_control
#: view:operation.time.line:mrp_operations_time_control.view_operation_time_lines_search
msgid "Production Order"
msgstr ""
#. module: mrp_operations_time_control
#: view:mrp.production.workcenter.line:mrp_operations_time_control.operation_time_tree_view
msgid "Resume"
msgstr ""
#. module: mrp_operations_time_control
#: view:operation.time.line:mrp_operations_time_control.view_operation_time_lines_search
msgid "Search Operation Time Lines"
msgstr ""
#. module: mrp_operations_time_control
#: view:mrp.production.workcenter.line:mrp_operations_time_control.operation_time_tree_view
msgid "Set Draft"
msgstr ""
#. module: mrp_operations_time_control
#: view:mrp.production.workcenter.line:mrp_operations_time_control.operation_time_tree_view
msgid "Start"
msgstr ""
#. module: mrp_operations_time_control
#: field:operation.time.line,start_date:0
msgid "Start Date"
msgstr ""
#. module: mrp_operations_time_control
#: view:mrp.production:mrp_operations_time_control.mrp_production_operation_time_form_view
#: view:mrp.production.workcenter.line:mrp_operations_time_control.operation_time_form_view
#: view:operation.time.line:mrp_operations_time_control.operation_time_lines_tree_view
#: field:operation.time.line,uptime:0
msgid "Uptime"
msgstr ""
#. module: mrp_operations_time_control
#: view:operation.time.line:mrp_operations_time_control.view_operation_time_lines_search
#: field:operation.time.line,user:0
msgid "User"
msgstr ""
#. module: mrp_operations_time_control
#: model:ir.model,name:mrp_operations_time_control.model_mrp_production_workcenter_line
#: view:operation.time.line:mrp_operations_time_control.view_operation_time_lines_search
msgid "Work Order"
msgstr "Work Order"
#. module: mrp_operations_time_control
#: view:operation.time.line:mrp_operations_time_control.operation_time_lines_form_view
msgid "hours"
msgstr ""

View File

@@ -1,19 +1,6 @@
# -*- encoding: utf-8 -*- # -*- coding: utf-8 -*-
############################################################################## # © 2015 Avanzosc
# # © 2015 Antiun Ingeniería
# This program is free software: you can redistribute it and/or modify # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
# 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 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 operation_time from . import operation_time

View File

@@ -1,20 +1,7 @@
# -*- encoding: utf-8 -*- # -*- coding: utf-8 -*-
############################################################################## # © 2015 Avanzosc
# # © 2015 Pedro M. Baeza
# This program is free software: you can redistribute it and/or modify # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
# 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 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 import api, models, fields from openerp import api, models, fields
@@ -22,9 +9,8 @@ from openerp import api, models, fields
class MrpProductionWorkcenterLine(models.Model): class MrpProductionWorkcenterLine(models.Model):
_inherit = 'mrp.production.workcenter.line' _inherit = 'mrp.production.workcenter.line'
operation_time_lines = fields.One2many('operation.time.line', operation_time_lines = fields.One2many(
'operation_time', 'operation.time.line', 'operation_time', string='Operation Time Lines')
string='Operation Time Lines')
def _create_operation_line(self): def _create_operation_line(self):
self.env['operation.time.line'].create({ self.env['operation.time.line'].create({
@@ -35,22 +21,26 @@ class MrpProductionWorkcenterLine(models.Model):
def _write_end_date_operation_line(self): def _write_end_date_operation_line(self):
self.operation_time_lines[-1].end_date = fields.Datetime.now() self.operation_time_lines[-1].end_date = fields.Datetime.now()
@api.multi
def action_start_working(self): def action_start_working(self):
result = super(MrpProductionWorkcenterLine, result = super(MrpProductionWorkcenterLine,
self).action_start_working() self).action_start_working()
self._create_operation_line() self._create_operation_line()
return result return result
@api.multi
def action_pause(self): def action_pause(self):
result = super(MrpProductionWorkcenterLine, self).action_pause() result = super(MrpProductionWorkcenterLine, self).action_pause()
self._write_end_date_operation_line() self._write_end_date_operation_line()
return result return result
@api.multi
def action_resume(self): def action_resume(self):
result = super(MrpProductionWorkcenterLine, self).action_resume() result = super(MrpProductionWorkcenterLine, self).action_resume()
self._create_operation_line() self._create_operation_line()
return result return result
@api.multi
def action_done(self): def action_done(self):
result = super(MrpProductionWorkcenterLine, self).action_done() result = super(MrpProductionWorkcenterLine, self).action_done()
self._write_end_date_operation_line() self._write_end_date_operation_line()
@@ -58,7 +48,6 @@ class MrpProductionWorkcenterLine(models.Model):
class OperationTimeLine(models.Model): class OperationTimeLine(models.Model):
_name = 'operation.time.line' _name = 'operation.time.line'
_rec_name = 'operation_time' _rec_name = 'operation_time'
@@ -68,19 +57,18 @@ class OperationTimeLine(models.Model):
start_date = fields.Datetime(string='Start Date') start_date = fields.Datetime(string='Start Date')
end_date = fields.Datetime(string='End Date') end_date = fields.Datetime(string='End Date')
operation_time = fields.Many2one('mrp.production.workcenter.line') operation_time = fields.Many2one('mrp.production.workcenter.line')
uptime = fields.Float(string='Machine up time', compute='operation_uptime', uptime = fields.Float(
store=True, digits=(12, 6)) string='Machine up time', compute='_compute_uptime', store=True,
production = fields.Many2one('mrp.production', digits=(12, 6))
related='operation_time.production_id', production = fields.Many2one(
string='Production', store=True) 'mrp.production', related='operation_time.production_id',
string='Production', store=True)
user = fields.Many2one('res.users', string='User', default=_default_user) user = fields.Many2one('res.users', string='User', default=_default_user)
@api.one @api.one
@api.depends('start_date', 'end_date') @api.depends('start_date', 'end_date')
def operation_uptime(self): def _compute_uptime(self):
if self.end_date and self.start_date: if self.end_date and self.start_date:
timedelta = fields.Datetime.from_string(self.end_date) - \ timedelta = fields.Datetime.from_string(self.end_date) - \
fields.Datetime.from_string(self.start_date) fields.Datetime.from_string(self.start_date)
self.uptime = timedelta.total_seconds() / 3600. self.uptime = timedelta.total_seconds() / 3600.
else:
self.uptime = 0

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 23 KiB

View File

@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
# © 2015 Pedro M. Baeza
# © 2015 Antiun Ingeniería
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from . import test_mrp_operations_time_control

View File

@@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
# © 2015 Pedro M. Baeza
# © 2015 Antiun Ingeniería
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from openerp.tests import common
import time
class TestMrpOperationsTimeControl(common.TransactionCase):
def setUp(self):
super(TestMrpOperationsTimeControl, self).setUp()
self.production = self.env.ref(
'mrp_operations_extension.mrp_production_opeext')
self.production.signal_workflow('button_confirm')
self.production.force_production()
self.workorder = self.production.workcenter_lines[0]
def test_operations_time(self):
self.assertFalse(self.workorder.operation_time_lines)
self.workorder.action_start_working()
self.assertTrue(self.workorder.operation_time_lines)
time.sleep(1)
self.workorder.action_pause()
self.assertEqual(len(self.workorder.operation_time_lines), 1)
self.assertTrue(self.workorder.operation_time_lines[0].uptime)
self.workorder.action_resume()
time.sleep(1)
self.workorder.action_done()
self.assertEqual(len(self.workorder.operation_time_lines), 2)
self.assertTrue(self.workorder.operation_time_lines[1].uptime)

View File

@@ -8,12 +8,18 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<search string="Search Operation Time Lines"> <search string="Search Operation Time Lines">
<group expand="1" string="Group By..."> <group expand="1" string="Group By...">
<filter name="uptimegroup" string="Work Order" <filter name="uptimegroup"
context="{'group_by' : 'operation_time'}" /> string="Work Order"
<filter name="productiongroup" string="Production Order" context="{'group_by' : 'operation_time'}"
context="{'group_by' : 'production'}" /> />
<filter name="usergroup" string="User" <filter name="productiongroup"
context="{'group_by' : 'user'}" /> string="Production Order"
context="{'group_by' : 'production'}"
/>
<filter name="usergroup"
string="User"
context="{'group_by' : 'user'}"
/>
</group> </group>
</search> </search>
</field> </field>
@@ -40,16 +46,31 @@
ref="mrp_operations.mrp_production_workcenter_tree_view_inherit" /> ref="mrp_operations.mrp_production_workcenter_tree_view_inherit" />
<field name="arch" type="xml"> <field name="arch" type="xml">
<field name="state" position="after"> <field name="state" position="after">
<button name="button_draft" string="Set Draft" <button name="button_draft"
states="cancel" icon="gtk-convert" /> string="Set Draft"
<button name="button_start_working" string="Start" states="cancel"
states="draft" icon="gtk-media-play" /> icon="gtk-convert"
<button name="button_resume" string="Resume" />
states="pause" icon="gtk-media-pause" /> <button name="button_start_working"
<button name="button_pause" string="Pending" string="Start"
states="startworking" icon="gtk-media-pause" /> states="draft"
<button name="button_done" string="Finished" icon="gtk-media-play"
states="startworking" icon="terp-check" /> />
<button name="button_resume"
string="Resume"
states="pause"
icon="gtk-media-pause"
/>
<button name="button_pause"
string="Pending"
states="startworking"
icon="gtk-media-pause"
/>
<button name="button_done"
string="Finished"
states="startworking"
icon="terp-check"
/>
</field> </field>
</field> </field>
</record> </record>
@@ -92,12 +113,12 @@
<field name="res_model">operation.time.line</field> <field name="res_model">operation.time.line</field>
<field name="view_type">form</field> <field name="view_type">form</field>
<field name="view_mode">tree,form</field> <field name="view_mode">tree,form</field>
<field name="context">{'search_default_uptimegroup': 1, <field name="context">{'search_default_uptimegroup': 1, 'search_default_internal_loc': 1}</field>
'search_default_internal_loc': 1}</field>
</record> </record>
<menuitem action="operation_time_lines_action" id="menu_operation_time_lines_action" <menuitem action="operation_time_lines_action"
parent="mrp.menu_mrp_manufacturing" sequence="10" /> id="menu_operation_time_lines_action"
parent="mrp.menu_mrp_manufacturing" sequence="10" />
</data> </data>
</openerp> </openerp>