From 566b3640f5d6d11df7125d2b5cc35c0ce7b69626 Mon Sep 17 00:00:00 2001 From: Daniel-CA Date: Wed, 29 Jul 2015 16:42:16 +0200 Subject: [PATCH] [ADD] mrp_operations_start_without_material closes #921 mrp_operations_extension: Added function to avoid repeat code --- .../README.rst | 15 ++++++++ .../__init__.py | 6 ++++ .../__openerp__.py | 35 +++++++++++++++++++ .../models/__init__.py | 8 +++++ .../models/mrp_bom.py | 25 +++++++++++++ .../models/mrp_production.py | 22 ++++++++++++ .../models/mrp_routing.py | 15 ++++++++ .../views/mrp_production_view.xml | 25 +++++++++++++ .../views/mrp_routing_view.xml | 15 ++++++++ 9 files changed, 166 insertions(+) create mode 100644 mrp_operations_start_without_material/README.rst create mode 100644 mrp_operations_start_without_material/__init__.py create mode 100644 mrp_operations_start_without_material/__openerp__.py create mode 100644 mrp_operations_start_without_material/models/__init__.py create mode 100644 mrp_operations_start_without_material/models/mrp_bom.py create mode 100644 mrp_operations_start_without_material/models/mrp_production.py create mode 100644 mrp_operations_start_without_material/models/mrp_routing.py create mode 100644 mrp_operations_start_without_material/views/mrp_production_view.xml create mode 100644 mrp_operations_start_without_material/views/mrp_routing_view.xml diff --git a/mrp_operations_start_without_material/README.rst b/mrp_operations_start_without_material/README.rst new file mode 100644 index 000000000..fbb4a1041 --- /dev/null +++ b/mrp_operations_start_without_material/README.rst @@ -0,0 +1,15 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :alt: License: AGPL-3 +MRP Operations start without material +===================================== + +This module allows to start WO without having the material assigned. + +Credits +======= + +Contributors +------------ +* Daniel Campos +* Pedro M. Baeza +* Ana Juaristi diff --git a/mrp_operations_start_without_material/__init__.py b/mrp_operations_start_without_material/__init__.py new file mode 100644 index 000000000..ad6c8186c --- /dev/null +++ b/mrp_operations_start_without_material/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +############################################################################## +# For copyright and license notices, see __openerp__.py file in root directory +############################################################################## + +from . import models diff --git a/mrp_operations_start_without_material/__openerp__.py b/mrp_operations_start_without_material/__openerp__.py new file mode 100644 index 000000000..a937e0ab5 --- /dev/null +++ b/mrp_operations_start_without_material/__openerp__.py @@ -0,0 +1,35 @@ + +# -*- 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 General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +############################################################################## + +{ + 'name': 'MRP Operations start without material', + 'version': '1.0', + 'author': 'OdooMRP team', + 'contributors': ["Daniel Campos ", + "Pedro M. Baeza ", + "Ana Juaristi "], + 'website': 'http://www.odoomrp.com', + "depends": ['mrp_operations_extension'], + "category": "Manufacturing", + "data": ['views/mrp_routing_view.xml', + 'views/mrp_production_view.xml' + ], + "installable": True, + "application": True +} diff --git a/mrp_operations_start_without_material/models/__init__.py b/mrp_operations_start_without_material/models/__init__.py new file mode 100644 index 000000000..59e4d535f --- /dev/null +++ b/mrp_operations_start_without_material/models/__init__.py @@ -0,0 +1,8 @@ +# -*- coding: utf-8 -*- +############################################################################## +# For copyright and license notices, see __openerp__.py file in root directory +############################################################################## + +from . import mrp_routing +from . import mrp_production +from . import mrp_bom diff --git a/mrp_operations_start_without_material/models/mrp_bom.py b/mrp_operations_start_without_material/models/mrp_bom.py new file mode 100644 index 000000000..f84b2e494 --- /dev/null +++ b/mrp_operations_start_without_material/models/mrp_bom.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +############################################################################## +# For copyright and license notices, see __openerp__.py file in root directory +############################################################################## + +from openerp import models + + +class MrpBom(models.Model): + _inherit = 'mrp.bom' + + def _get_workorder_operations(self, result2, factor, level=0, + routing_id=False): + res = super(MrpBom, self)._get_workorder_operations( + result2, factor, level, routing_id) + for work_order in res: + if (work_order['sequence'] < level or + work_order.get('routing_wc_line')): + continue + seq = work_order['sequence'] - level + rl = self._get_routing_line_from_workorder( + routing_id, seq, work_order['workcenter_id'], + work_order['name']) + work_order['init_without_material'] = rl.init_without_material + return res diff --git a/mrp_operations_start_without_material/models/mrp_production.py b/mrp_operations_start_without_material/models/mrp_production.py new file mode 100644 index 000000000..825d79e91 --- /dev/null +++ b/mrp_operations_start_without_material/models/mrp_production.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################## +# For copyright and license notices, see __openerp__.py file in root directory +############################################################################## + +from openerp import models, fields + + +class MrpProductionWorkcenterLine(models.Model): + _inherit = 'mrp.production.workcenter.line' + + init_without_material = fields.Boolean( + string='Init without material', + help="If enabled, current operation could be initialized even if there" + "is no material assigned to it.") + + def check_operation_moves_state(self, states): + if self.init_without_material: + return True + else: + return super(MrpProductionWorkcenterLine, + self).check_operation_moves_state(states) diff --git a/mrp_operations_start_without_material/models/mrp_routing.py b/mrp_operations_start_without_material/models/mrp_routing.py new file mode 100644 index 000000000..699457532 --- /dev/null +++ b/mrp_operations_start_without_material/models/mrp_routing.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +############################################################################## +# For copyright and license notices, see __openerp__.py file in root directory +############################################################################## + +from openerp import models, fields + + +class MrpRoutingWorkcenter(models.Model): + _inherit = 'mrp.routing.workcenter' + + init_without_material = fields.Boolean( + string='Init without material', + help="If enabled, current operation could be initialized even if there" + "is no material assigned to it.") diff --git a/mrp_operations_start_without_material/views/mrp_production_view.xml b/mrp_operations_start_without_material/views/mrp_production_view.xml new file mode 100644 index 000000000..c4367aaf7 --- /dev/null +++ b/mrp_operations_start_without_material/views/mrp_production_view.xml @@ -0,0 +1,25 @@ + + + + + mrp.production.form.view.swm + mrp.production + + + + + + + + + Workcenter line SWM + mrp.production.workcenter.line + + + + + + + + + diff --git a/mrp_operations_start_without_material/views/mrp_routing_view.xml b/mrp_operations_start_without_material/views/mrp_routing_view.xml new file mode 100644 index 000000000..eb82d5ded --- /dev/null +++ b/mrp_operations_start_without_material/views/mrp_routing_view.xml @@ -0,0 +1,15 @@ + + + + + mrp.routing.workcenter.form.swm + mrp.routing.workcenter + + + + + + + + +