diff --git a/mrp_operations_time_control/README.rst b/mrp_operations_time_control/README.rst new file mode 100644 index 000000000..cbd251dfe --- /dev/null +++ b/mrp_operations_time_control/README.rst @@ -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 +`_. 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 +`_. + +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 +* Oihane Crucelaegui +* Pedro M. Baeza +* Ana Juaristi + +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. diff --git a/mrp_operations_time_control/__init__.py b/mrp_operations_time_control/__init__.py index 7fc7c09f9..ac746c0bd 100644 --- a/mrp_operations_time_control/__init__.py +++ b/mrp_operations_time_control/__init__.py @@ -1,19 +1,6 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# 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 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/. -# -############################################################################## +# -*- coding: utf-8 -*- +# © 2015 Avanzosc +# © 2015 Pedro M. Baeza +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html from . import models diff --git a/mrp_operations_time_control/__openerp__.py b/mrp_operations_time_control/__openerp__.py index 034991327..68c2cf035 100644 --- a/mrp_operations_time_control/__openerp__.py +++ b/mrp_operations_time_control/__openerp__.py @@ -1,33 +1,21 @@ - -# -*- encoding: utf-8 -*- -############################################################################## -# -# 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 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/. -# -############################################################################## +# -*- coding: utf-8 -*- +# © 2015 Avanzosc +# © 2015 Pedro M. Baeza +# © 2015 Antiun Ingeniería +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html { "name": "MRP Operations Time Control", - "version": "1.0", + "version": "8.0.1.1.0", "depends": [ - "base", - "mrp", "mrp_operations_extension", ], - "author": "OdooMRP team," - "AvanzOSC," - "Serv. Tecnol. Avanzados - Pedro M. Baeza", + "license": "AGPL-3", + "author": "OdooMRP team, " + "AvanzOSC, " + "Serv. Tecnol. Avanzados - Pedro M. Baeza, " + "Antiun Ingeniería S.L., " + "Odoo Community Association (OCA)", "website": "http://www.odoomrp.com", "contributors": [ "Mikel Arregi ", @@ -36,14 +24,10 @@ "Ana Juaristi " ], "category": "Manufacturing", - "description": """ - Manufacturing operations time control - """, 'data': [ "views/operation_time_view.xml", "views/mrp_production_view.xml", "security/ir.model.access.csv", ], "installable": True, - "auto_install": False, } diff --git a/mrp_operations_time_control/i18n/en_US.po b/mrp_operations_time_control/i18n/en_US.po deleted file mode 100644 index c87c0dc7b..000000000 --- a/mrp_operations_time_control/i18n/en_US.po +++ /dev/null @@ -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 "" diff --git a/mrp_operations_time_control/models/__init__.py b/mrp_operations_time_control/models/__init__.py index fd411f163..557357a98 100644 --- a/mrp_operations_time_control/models/__init__.py +++ b/mrp_operations_time_control/models/__init__.py @@ -1,19 +1,6 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# 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 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/. -# -############################################################################## +# -*- coding: utf-8 -*- +# © 2015 Avanzosc +# © 2015 Antiun Ingeniería +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html from . import operation_time diff --git a/mrp_operations_time_control/models/operation_time.py b/mrp_operations_time_control/models/operation_time.py index 82c4a158b..764ec541e 100644 --- a/mrp_operations_time_control/models/operation_time.py +++ b/mrp_operations_time_control/models/operation_time.py @@ -1,20 +1,7 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# 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 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/. -# -############################################################################## +# -*- coding: utf-8 -*- +# © 2015 Avanzosc +# © 2015 Pedro M. Baeza +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html from openerp import api, models, fields @@ -22,9 +9,8 @@ from openerp import api, models, fields class MrpProductionWorkcenterLine(models.Model): _inherit = 'mrp.production.workcenter.line' - operation_time_lines = fields.One2many('operation.time.line', - 'operation_time', - string='Operation Time Lines') + operation_time_lines = fields.One2many( + 'operation.time.line', 'operation_time', string='Operation Time Lines') def _create_operation_line(self): self.env['operation.time.line'].create({ @@ -35,22 +21,26 @@ class MrpProductionWorkcenterLine(models.Model): def _write_end_date_operation_line(self): self.operation_time_lines[-1].end_date = fields.Datetime.now() + @api.multi def action_start_working(self): result = super(MrpProductionWorkcenterLine, self).action_start_working() self._create_operation_line() return result + @api.multi def action_pause(self): result = super(MrpProductionWorkcenterLine, self).action_pause() self._write_end_date_operation_line() return result + @api.multi def action_resume(self): result = super(MrpProductionWorkcenterLine, self).action_resume() self._create_operation_line() return result + @api.multi def action_done(self): result = super(MrpProductionWorkcenterLine, self).action_done() self._write_end_date_operation_line() @@ -58,7 +48,6 @@ class MrpProductionWorkcenterLine(models.Model): class OperationTimeLine(models.Model): - _name = 'operation.time.line' _rec_name = 'operation_time' @@ -68,19 +57,18 @@ class OperationTimeLine(models.Model): start_date = fields.Datetime(string='Start Date') end_date = fields.Datetime(string='End Date') operation_time = fields.Many2one('mrp.production.workcenter.line') - uptime = fields.Float(string='Machine up time', compute='operation_uptime', - store=True, digits=(12, 6)) - production = fields.Many2one('mrp.production', - related='operation_time.production_id', - string='Production', store=True) + uptime = fields.Float( + string='Machine up time', compute='_compute_uptime', store=True, + digits=(12, 6)) + production = fields.Many2one( + 'mrp.production', related='operation_time.production_id', + string='Production', store=True) user = fields.Many2one('res.users', string='User', default=_default_user) @api.one @api.depends('start_date', 'end_date') - def operation_uptime(self): + def _compute_uptime(self): if self.end_date and self.start_date: timedelta = fields.Datetime.from_string(self.end_date) - \ fields.Datetime.from_string(self.start_date) self.uptime = timedelta.total_seconds() / 3600. - else: - self.uptime = 0 diff --git a/mrp_operations_time_control/static/description/icon.png b/mrp_operations_time_control/static/description/icon.png new file mode 100644 index 000000000..abca09104 Binary files /dev/null and b/mrp_operations_time_control/static/description/icon.png differ diff --git a/mrp_operations_time_control/static/description/icon.svg b/mrp_operations_time_control/static/description/icon.svg new file mode 100644 index 000000000..ad7dfef1a --- /dev/null +++ b/mrp_operations_time_control/static/description/icon.svg @@ -0,0 +1,312 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mrp_operations_time_control/tests/__init__.py b/mrp_operations_time_control/tests/__init__.py new file mode 100644 index 000000000..12c05261b --- /dev/null +++ b/mrp_operations_time_control/tests/__init__.py @@ -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 diff --git a/mrp_operations_time_control/tests/test_mrp_operations_time_control.py b/mrp_operations_time_control/tests/test_mrp_operations_time_control.py new file mode 100644 index 000000000..eb56bfc88 --- /dev/null +++ b/mrp_operations_time_control/tests/test_mrp_operations_time_control.py @@ -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) diff --git a/mrp_operations_time_control/views/operation_time_view.xml b/mrp_operations_time_control/views/operation_time_view.xml index 3087798a3..9a6df5e2f 100644 --- a/mrp_operations_time_control/views/operation_time_view.xml +++ b/mrp_operations_time_control/views/operation_time_view.xml @@ -8,12 +8,18 @@ - - - + + + @@ -40,16 +46,31 @@ ref="mrp_operations.mrp_production_workcenter_tree_view_inherit" /> -