mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[ADD] mrp_operations_start_without_material closes #921
mrp_operations_extension: Added function to avoid repeat code
This commit is contained in:
15
mrp_operations_start_without_material/README.rst
Normal file
15
mrp_operations_start_without_material/README.rst
Normal file
@@ -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 <danielcampos@avanzosc.es>
|
||||
* Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
|
||||
* Ana Juaristi <ajuaristio@gmail.com>
|
||||
6
mrp_operations_start_without_material/__init__.py
Normal file
6
mrp_operations_start_without_material/__init__.py
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
# For copyright and license notices, see __openerp__.py file in root directory
|
||||
##############################################################################
|
||||
|
||||
from . import models
|
||||
35
mrp_operations_start_without_material/__openerp__.py
Normal file
35
mrp_operations_start_without_material/__openerp__.py
Normal file
@@ -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 <danielcampos@avanzosc.es>",
|
||||
"Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>",
|
||||
"Ana Juaristi <ajuaristio@gmail.com>"],
|
||||
'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
|
||||
}
|
||||
8
mrp_operations_start_without_material/models/__init__.py
Normal file
8
mrp_operations_start_without_material/models/__init__.py
Normal file
@@ -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
|
||||
25
mrp_operations_start_without_material/models/mrp_bom.py
Normal file
25
mrp_operations_start_without_material/models/mrp_bom.py
Normal file
@@ -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
|
||||
@@ -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)
|
||||
15
mrp_operations_start_without_material/models/mrp_routing.py
Normal file
15
mrp_operations_start_without_material/models/mrp_routing.py
Normal file
@@ -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.")
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="mrp_production_form_view_SWM" model="ir.ui.view">
|
||||
<field name="name">mrp.production.form.view.swm</field>
|
||||
<field name="model">mrp.production</field>
|
||||
<field name="inherit_id" ref="mrp_operations_extension.mrp_production_form_view_inh" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="do_production" position="after">
|
||||
<field name="init_without_material"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="workcenter_line_form_view_SWM">
|
||||
<field name="name">Workcenter line SWM</field>
|
||||
<field name="model">mrp.production.workcenter.line</field>
|
||||
<field name="inherit_id" ref="mrp_operations_extension.workcenter_line_inh_form_view" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="do_production" position="after">
|
||||
<field name="init_without_material"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="mrp_routing_workcenter_form_view_SWM" model="ir.ui.view">
|
||||
<field name="name">mrp.routing.workcenter.form.swm</field>
|
||||
<field name="model">mrp.routing.workcenter</field>
|
||||
<field name="inherit_id" ref="mrp_operations_extension.mrp_routing_workcenter_form_view_inh" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="previous_operations_finished" position="after">
|
||||
<field name="init_without_material"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
||||
Reference in New Issue
Block a user