[ADD] mrp_operations_extension

This commit is contained in:
campos
2014-08-20 10:50:04 +02:00
committed by Pedro M. Baeza
parent 96e670ab66
commit b543da32ea
15 changed files with 696 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2008-2014 AvanzOSC (Daniel). All Rights Reserved
# Date: 10/07/2014
#
# 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/.
#
##############################################################################
from . import models

View File

@@ -0,0 +1,51 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2008-2014 AvanzOSC (Daniel). All Rights Reserved
# Date: 10/07/2014
#
# 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 Extension",
"version": "1.0",
"description": """
This module adds:
- New table to store operations to avoid typing them again.
- Adds a relation from WorkcenterLines to BOM Lists.
- Adds a relation from WorkcenterLines to Manufacturing Orders in
Scheduled/Consumed/Finished Products.
- Add a relation between Routing Work Center Lines and Work Center extra
Info.
""",
'author': 'OdooMRP team',
'website': "http://www.odoomrp.com",
"depends": ['mrp_operations', 'mrp'],
"category": "Manufacturing",
"data": ['views/mrp_workcenter_view.xml',
'views/mrp_routing_operation_view.xml',
'views/mrp_production_view.xml',
'views/mrp_bom_view.xml',
'views/mrp_workcenter_view.xml',
'views/mrp_routing_workcenter_view.xml',
],
"installable": True
}

View File

@@ -0,0 +1,25 @@
# -*- 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/.
#
##############################################################################
from . import mrp_routing_operation
from . import stock_move
from . import mrp_routing_workcenter
from . import mrp_production
from . import mrp_bom
from . import mrp_workcenter

View File

@@ -0,0 +1,62 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2008-2014 AvanzOSC (Daniel). All Rights Reserved
# Date: 10/07/2014
#
# 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/.
#
##############################################################################
from openerp import models, fields, tools
class MrpBom(models.Model):
_inherit = 'mrp.bom'
def _bom_explode(self, cr, uid, bom, product, factor, properties=None,
level=0, routing_id=False, previous_products=None,
master_bom=None, context=None):
routing_line_obj = self.pool['mrp.routing.workcenter']
res = super(MrpBom, self)._bom_explode(cr, uid, bom, product, factor,
properties=None, level=0,
routing_id=False,
previous_products=None,
master_bom=None,
context=context)
result, result2 = res
for work_order in result2:
seq = work_order['sequence'] - level
routing_lines = routing_line_obj.search(cr, uid, [
('routing_id', '=', routing_id), ('sequence', '=', seq)])
routing_line_id = False
if len(routing_lines) == 1:
routing_line_id = routing_lines[0]
elif len(routing_lines) > 1:
for routing_line in routing_line_obj.browse(cr, uid,
routing_lines):
name_val = tools.ustr(routing_line.name) + ' - '
if name_val in work_order['name']:
routing_line_id = routing_line.id
break
work_order['routing_wc_line'] = routing_line_id
return result, result2
class MrpBomLine(models.Model):
_inherit = 'mrp.bom.line'
operation = fields.Many2one('mrp.routing.workcenter', 'Consumed')

View File

@@ -0,0 +1,69 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Daniel Campos (danielcampos@avanzosc.es) Date: 28/08/2014
#
# 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/.
#
##############################################################################
from openerp import models, fields, api
class MrpProduction(models.Model):
_inherit = 'mrp.production'
@api.multi
def _action_compute_lines(self, properties=None):
res = super(MrpProduction,
self)._action_compute_lines(properties=properties)
workcenter_lines = self.workcenter_lines
product_lines = self.product_lines
for p_line in product_lines:
mrp_bom = self.env['mrp.bom'].search([
('routing_id', '=', self.routing_id.id),
('product_tmpl_id', '=', self.product_id.product_tmpl_id.id)])
for bom_line in mrp_bom[0].bom_line_ids:
if bom_line.product_id.id == p_line.product_id.id:
for wc_line in workcenter_lines:
if wc_line.routing_wc_line.id == bom_line.operation.id:
p_line.work_order = wc_line.id
break
return res
@api.multi
def action_confirm(self):
res = super(MrpProduction, self).action_confirm()
for move_line in self.move_lines:
for product_line in self.product_lines:
if product_line.product_id.id == move_line.product_id.id:
move_line.work_order = product_line.work_order.id
return res
class MrpProductionProductLine(models.Model):
_inherit = 'mrp.production.product.line'
work_order = fields.Many2one('mrp.production.workcenter.line',
'Work Order')
class mrp_production_workcenter_line(models.Model):
_inherit = 'mrp.production.workcenter.line'
product_line = fields.One2many('mrp.production.product.line',
'work_order', string='Product Lines')
routing_wc_line = fields.Many2one('mrp.routing.workcenter',
string='Routing WC Line')

View File

@@ -0,0 +1,66 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Daniel Campos (danielcampos@avanzosc.es) Date: 12/09/2014
#
# 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/.
#
##############################################################################
from openerp import models, fields, api, exceptions
class MrpOperationWorkcenter(models.Model):
_name = 'mrp.operation.workcenter'
_description = 'MRP Operation Workcenter'
workcenter = fields.Many2one('mrp.workcenter', string='Work Center')
routing_workcenter = fields.Many2one('mrp.routing.workcenter',
'Routing Workcenter')
time_efficiency = fields.Float('Efficiency Factor')
capacity_per_cycle = fields.Float('Capacity per Cycle')
time_cycle = fields.Float('Time for 1 cycle (hour)',
help="Time in hours for doing one cycle.")
time_start = fields.Float('Time before prod.',
help="Time in hours for the setup.")
time_stop = fields.Float('Time after prod.',
help="Time in hours for the cleaning.")
op_number = fields.Integer('Número de Persona', default='0')
default = fields.Boolean('Default')
@api.one
@api.onchange('workcenter')
def onchange_workcenter(self):
if self.workcenter:
self.capacity_per_cycle = self.workcenter.capacity_per_cycle
self.time_efficiency = self.workcenter.time_efficiency
self.time_cycle = self.workcenter.time_cycle
self.time_start = self.workcenter.time_start
self.time_stop = self.workcenter.time_stop
self.default = False
class MrpRoutingOperation(models.Model):
_name = 'mrp.routing.operation'
_description = 'MRP Routing Operation'
name = fields.Char('Name', required=True)
code = fields.Char('Code')
description = fields.Text('Description')
steps = fields.Text('Relevant Steps')
workcenters = fields.Many2many(
'mrp.workcenter', 'mrp_operation_workcenter_rel', 'operation',
'workcenter', 'Work centers')
op_number = fields.Integer('Número de Persona', default='0')

View File

@@ -0,0 +1,83 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2008-2014 AvanzOSC (Daniel). All Rights Reserved
# Date: 10/07/2014
#
# 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/.
#
##############################################################################
from openerp import models, fields, api, exceptions, _
class MrpRoutingWorkcenter(models.Model):
_inherit = 'mrp.routing.workcenter'
operation = fields.Many2one('mrp.routing.operation', string='Operation')
op_wc_lines = fields.One2many('mrp.operation.workcenter',
'routing_workcenter',
'Workcenter Info Lines')
@api.one
@api.onchange('operation')
def onchange_operation(self):
if self.operation:
self.name = self.operation.name
self.note = self.operation.description
op_wc_lst = []
data = {}
for operation_wc in self.operation.workcenters:
data = {'workcenter': operation_wc.id,
'capacity_per_cycle': operation_wc.capacity_per_cycle,
'time_efficiency': operation_wc.time_efficiency,
'time_cycle': operation_wc.time_cycle,
'time_start': operation_wc.time_start,
'time_stop': operation_wc.time_stop,
'default': False,
'op_number': self.operation.op_number
}
op_wc_lst.append(data)
self.op_wc_lines = op_wc_lst
@api.multi
@api.onchange('op_wc_lines')
def onchange_default(self):
for record in self:
kont = 0
wkc = False
for opwc_line in record.op_wc_lines:
if opwc_line.default:
kont += 1
if not wkc:
record.workcenter_id = opwc_line.workcenter.id
if kont > 1:
raise exceptions.Warning(_('There is another line set as '
'default, disable it first.'))
@api.one
@api.constrains('op_wc_lines')
def _check_default(self):
kont = 0
wkc = False
for opwc_line in self.op_wc_lines:
if opwc_line.default:
kont += 1
if not wkc:
self.workcenter_id = opwc_line.workcenter.id
if kont > 1:
raise exceptions.Warning(_('There is another line set as '
'default, disable it first.'))

View File

@@ -0,0 +1,36 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2008-2014 AvanzOSC (Daniel). All Rights Reserved
# Date: 10/07/2014
#
# 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/.
#
##############################################################################
from openerp import models, fields
class MrpWorkcenter(models.Model):
_inherit = 'mrp.workcenter'
pre_op_product = fields.Many2one('product.product',
string='Pre Operation Cost')
post_op_product = fields.Many2one('product.product',
string='Post Operation Cost')
rt_operations = fields.Many2many(
'mrp.routing.operation', 'mrp_operation_workcenter_rel', 'workcenter',
'operation', 'Routing Operations')

View File

@@ -0,0 +1,29 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Daniel Campos (danielcampos@avanzosc.es) Date: 25/08/2014
#
# 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/.
#
##############################################################################
from openerp import models, fields
class StockMove(models.Model):
_inherit = "stock.move"
work_order = fields.Many2one('mrp.production.workcenter.line',
string='Work Order')

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="mrp_bom_form_view_inh" model="ir.ui.view">
<field name="name">mrp.bom.form.inh</field>
<field name="model">mrp.bom</field>
<field name="inherit_id" ref="mrp.mrp_bom_form_view" />
<field name="arch" type="xml">
<xpath expr="//tree/field[@name='product_id']" position="after">
<field name="operation" domain="[('routing_id', '=', parent.routing_id)]"/>
</xpath>
</field>
</record>
</data>
</openerp>

View File

@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="operation_workcenter_tree" model="ir.ui.view">
<field name="name">rountig.operation.tree</field>
<field name="model">mrp.operation.workcenter</field>
<field name="arch" type="xml">
<tree string="Operation Workcenter">
<field name="workcenter" />
</tree>
</field>
</record>
<record id="operation_workcenter_form" model="ir.ui.view">
<field name="name">rountig.operation.tree</field>
<field name="model">mrp.operation.workcenter</field>
<field name="arch" type="xml">
<form string="Operation Workcenter">
<group>
<field name="workcenter"/>
<field name="time_efficiency" />
<field name="capacity_per_cycle" />
<field name="time_cycle" widget="float_time"/>
<field name="time_start" widget="float_time" />
<field name="time_stop" widget="float_time"/>
</group>
</form>
</field>
</record>
<record id="operation_workcenter_action" model="ir.actions.act_window">
<field name="name">Workcenter Operation</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mrp.operation.workcenter</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
</data>
</openerp>

View File

@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="mrp_production_product_tree_view_inh" model="ir.ui.view">
<field name="name">mrp.production.product.tree.view.inh
</field>
<field name="model">mrp.production.product.line</field>
<field name="inherit_id" ref="mrp.mrp_production_product_tree_view" />
<field name="arch" type="xml">
<field name="product_id" position="after">
<field name="work_order" />
</field>
</field>
</record>
<record id="mrp_production_product_form_view_inh" model="ir.ui.view">
<field name="name">mrp.production.product.form.view.inh
</field>
<field name="model">mrp.production.product.line</field>
<field name="inherit_id" ref="mrp.mrp_production_product_form_view" />
<field name="arch" type="xml">
<field name="product_id" position="after">
<field name="work_order" />
</field>
</field>
</record>
<record id="mrp_production_form_view_inh" model="ir.ui.view">
<field name="name">mrp.production.form.view.inh</field>
<field name="model">mrp.production</field>
<field name="inherit_id" ref="mrp.mrp_production_form_view" />
<field name="arch" type="xml">
<xpath
expr="//page//group[@string='Products to Consume']//field[@name='product_id']"
position="after">
<field name="work_order" />
</xpath>
<xpath
expr="//page//group[@string='Consumed Products']//field[@name='product_id']"
position="after">
<field name="work_order" />
</xpath>
<xpath
expr="//page//group[@string='Products to Produce']//field[@name='product_id']"
position="after">
<field name="work_order" />
</xpath>
<xpath
expr="//page//group[@string='Produced Products']//field[@name='product_id']"
position="after">
<field name="work_order" />
</xpath>
<xpath
expr="//field[@name='workcenter_lines']/form//field[@name='hour']"
position="after">
<field name="routing_wc_line" colspan="4"/>
</xpath>
<xpath
expr="//field[@name='workcenter_lines']/form//group"
position="after">
<notebook>
<page string="Product Lines">
<field name="product_line" nolabel="1" colspan="4"/>
</page>
</notebook>
</xpath>
</field>
</record>
</data>
</openerp>

View File

@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="rountig_operation_tree" model="ir.ui.view">
<field name="name">rountig.operation.tree</field>
<field name="model">mrp.routing.operation</field>
<field name="arch" type="xml">
<tree string="Routing Operation">
<field name="name" />
<field name="code" />
<field name="description" />
</tree>
</field>
</record>
<record id="rountig_operation_form" model="ir.ui.view">
<field name="name">rountig.operation.form</field>
<field name="model">mrp.routing.operation</field>
<field name="arch" type="xml">
<form string="Routing Operation">
<group col="4">
<field name="name" colspan="2"/>
<field name="code" colspan="2"/>
<field name="description" colspan="2"/>
<field name="steps" colspan="2"/>
<field name="op_number" colspan="4" />
</group>
<notebook>
<page string="Workcenters">
<field name="workcenters" colspan="4" nolabel="1"/>
</page>
</notebook>
</form>
</field>
</record>
<record id="mrp_routing_operation_action" model="ir.actions.act_window">
<field name="name">Routing Operation</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mrp.routing.operation</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem action="mrp_routing_operation_action" name="Operations"
id="mrp_routing_menu" parent="mrp.menu_mrp_configuration" />
</data>
</openerp>

View File

@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="mrp_routing_workcenter_tree_view_inh" model="ir.ui.view">
<field name="name">mrp.routing.workcenter.tree.inh</field>
<field name="model">mrp.routing.workcenter</field>
<field name="inherit_id" ref="mrp.mrp_routing_workcenter_tree_view" />
<field name="arch" type="xml">
<field name="name" position="before">
<field name="operation"/>
</field>
</field>
</record>
<record id="mrp_routing_workcenter_form_view_inh" model="ir.ui.view">
<field name="name">mrp.routing.workcenter.form.inh</field>
<field name="model">mrp.routing.workcenter</field>
<field name="inherit_id" ref="mrp.mrp_routing_workcenter_form_view" />
<field name="arch" type="xml">
<field name="name" position="before">
<field name="operation" />
<newline/>
</field>
<field name="workcenter_id" position="after">
<field name="op_wc_lines" colspan="4">
<tree editable="bottom">
<field name="workcenter"/>
<field name="time_efficiency" />
<field name="capacity_per_cycle" />
<field name="time_start" widget="float_time" />
<field name="time_stop" widget="float_time" />
<field name="time_cycle" widget="float_time"/>
<field name="op_number"/>
<field name="default"/>
</tree>
<form string="Workcenter Info Lines">
<group>
<field name="workcenter"/>
<field name="time_efficiency" />
<field name="capacity_per_cycle" />
<field name="time_cycle" widget="float_time"/>
<field name="time_start" widget="float_time" />
<field name="time_stop" widget="float_time" />
<field name="op_number"/>
<field name="default"/>
</group>
</form>
</field>
</field>
</field>
</record>
</data>
</openerp>

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="mrp_workcenter_form_view_inh" model="ir.ui.view">
<field name="name">mrp.workcenter.tree.inh</field>
<field name="model">mrp.workcenter</field>
<field name="inherit_id" ref="mrp.mrp_workcenter_view" />
<field name="arch" type="xml">
<field name="time_start" position="after">
<field name="pre_op_product"/>
</field>
<field name="time_stop" position="after">
<field name="post_op_product"/>
</field>
<xpath expr="//page[@string='General Information']" position="after">
<page string="Routing Operations">
<field name="rt_operations" nolabel="1"/>
</page>
</xpath>
</field>
</record>
</data>
</openerp>