diff --git a/mrp_bom_version/README.rst b/mrp_bom_version/README.rst
new file mode 100644
index 000000000..9c538b285
--- /dev/null
+++ b/mrp_bom_version/README.rst
@@ -0,0 +1,26 @@
+MRP - BoM version
+=================
+
+This module provides a state in the LdM whether to allow their use in
+manufacturing, to do the following states are defined:
+
+* **Draft**:
+ The form will be available for data entry, and may move to "active" state.
+* **Active**:
+ You can modify all of the form fields except for the fields: routing, BoM
+ lines, and the new field Active, for false default when you create a new BoM.
+ The "active" state may be passed back to state "draft", if we mark the new
+ field "Allow re-edit the BoM list", this new field is defined in
+ *Configuration > Configuration > Manufacturing*.
+ The active state may move to state "Historical".
+* **Historical**:
+ This is the last state of the LdM, you can not change any field on the form.
+
+When the MRP BoM list is put to active, a record of who has activated, and when
+will include in chatter/log. It also adds a constraint for the sequence field
+to be unique.
+
+* **New version** :
+ By clicking the button version, current BOM is moved to historical state,
+ and a new BOM is creating based on this but with version number +1 and
+ changing state to draft
\ No newline at end of file
diff --git a/mrp_bom_version/__init__.py b/mrp_bom_version/__init__.py
new file mode 100644
index 000000000..2bbe2de99
--- /dev/null
+++ b/mrp_bom_version/__init__.py
@@ -0,0 +1,5 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+# For copyright and license notices, see __openerp__.py file in root directory
+##############################################################################
+from . import models
diff --git a/mrp_bom_version/__openerp__.py b/mrp_bom_version/__openerp__.py
new file mode 100644
index 000000000..cbbf0af8d
--- /dev/null
+++ b/mrp_bom_version/__openerp__.py
@@ -0,0 +1,45 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# Copyright (c)
+# 2015 Serv. Tec. Avanzados - Pedro M. Baeza (http://www.serviciosbaeza.com)
+# 2015 AvanzOsc (http://www.avanzosc.es)
+#
+# 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 Affero 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 .
+#
+##############################################################################
+{
+ "name": "MRP - BoM version",
+ "version": "1.0",
+ "author": "OdooMRP team,"
+ "AvanzOSC,"
+ "Serv. Tecnol. Avanzados - Pedro M. Baeza",
+ "website": "http://www.odoomrp.com",
+ "contributors": [
+ "Pedro M. Baeza ",
+ "Alfredo de la Fuente ",
+ ],
+ "category": "Manufacturing",
+ "depends": [
+ "mrp",
+ ],
+ "data": [
+ "data/mrp_bom_data.xml",
+ "security/mrp_bom_version_security.xml",
+ "views/res_config_view.xml",
+ "views/mrp_bom_view.xml",
+ ],
+ "installable": True
+}
diff --git a/mrp_bom_version/data/mrp_bom_data.xml b/mrp_bom_version/data/mrp_bom_data.xml
new file mode 100644
index 000000000..2fe6424ca
--- /dev/null
+++ b/mrp_bom_version/data/mrp_bom_data.xml
@@ -0,0 +1,11 @@
+
+
+
+
+ MRP BoM Active
+ mrp.bom
+
+ MRP BoM Active
+
+
+
diff --git a/mrp_bom_version/i18n/es.po b/mrp_bom_version/i18n/es.po
new file mode 100644
index 000000000..7c64b9ac7
--- /dev/null
+++ b/mrp_bom_version/i18n/es.po
@@ -0,0 +1,125 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * mrp_bom_version
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: Odoo Server 8.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2015-05-22 08:58+0000\n"
+"PO-Revision-Date: 2015-05-22 11:02+0100\n"
+"Last-Translator: <>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: \n"
+"X-Generator: Poedit 1.5.4\n"
+
+#. module: mrp_bom_version
+#: view:mrp.bom:mrp_bom_version.mrp_bom_form_view_inh_state
+msgid "Activate"
+msgstr "Activar"
+
+#. module: mrp_bom_version
+#: view:mrp.bom:mrp_bom_version.view_mrp_bom_filter_inh_state
+#: selection:mrp.bom,state:0
+msgid "Active"
+msgstr "Activa"
+
+#. module: mrp_bom_version
+#: field:mrp.config.settings,group_mrp_bom_state:0
+msgid "Allow to re-edit BoMs"
+msgstr "Permitir re-editar las listas de materiales."
+
+#. module: mrp_bom_version
+#: model:ir.model,name:mrp_bom_version.model_mrp_bom
+msgid "Bill of Material"
+msgstr "Lista de material"
+
+#. module: mrp_bom_version
+#: view:mrp.bom:mrp_bom_version.mrp_bom_form_view_inh_state
+#: selection:mrp.bom,state:0
+msgid "Draft"
+msgstr "Borrador"
+
+#. module: mrp_bom_version
+#: view:mrp.bom:mrp_bom_version.mrp_bom_form_view_inh_state
+#: selection:mrp.bom,state:0
+msgid "Historical"
+msgstr "Histórica"
+
+#. module: mrp_bom_version
+#: field:mrp.bom,historical_date:0
+msgid "Historical Date"
+msgstr "Fecha historificación"
+
+#. module: mrp_bom_version
+#: model:mail.message.subtype,description:mrp_bom_version.mt_active
+#: model:mail.message.subtype,name:mrp_bom_version.mt_active
+msgid "MRP BoM Active"
+msgstr "Estado LdM"
+
+#. module: mrp_bom_version
+#: model:res.groups,name:mrp_bom_version.group_mrp_bom_version
+msgid "MRP BoM version"
+msgstr "Version LdM"
+
+#. module: mrp_bom_version
+#: model:ir.model,name:mrp_bom_version.model_mrp_production
+msgid "Manufacturing Order"
+msgstr "Órden de producción"
+
+#. module: mrp_bom_version
+#: view:mrp.bom:mrp_bom_version.mrp_bom_form_view_inh_state
+msgid "New version"
+msgstr "Nueva versión"
+
+#. module: mrp_bom_version
+#: view:mrp.bom:mrp_bom_version.view_mrp_bom_filter_inh_state
+msgid "Product"
+msgstr "Producto"
+
+#. module: mrp_bom_version
+#: view:mrp.bom:mrp_bom_version.view_mrp_bom_filter_inh_state
+msgid "State"
+msgstr "Estado"
+
+#. module: mrp_bom_version
+#: field:mrp.bom,state:0
+msgid "Status"
+msgstr "Estatus"
+
+#. module: mrp_bom_version
+#: help:mrp.config.settings,group_mrp_bom_state:0
+msgid "The active state may be passed back to state draft"
+msgstr "El estado activo puede ser devuelto al estado de borrador"
+
+#. module: mrp_bom_version
+#: field:mrp.bom,version:0
+msgid "Version"
+msgstr "Versión"
+
+#. module: mrp_bom_version
+#: view:mrp.bom:mrp_bom_version.mrp_bom_form_view_inh_state
+msgid "You are going to create a new version of this BoM. Are you sure?"
+msgstr ""
+" Está a punto de crear una nueva versión de esta LdM. ¿Desea continuar?"
+
+#. module: mrp_bom_version
+#: view:mrp.bom:mrp_bom_version.mrp_bom_form_view_inh_state
+msgid ""
+"You are going to historize an BoM. Doing, not be able to unlock it unless "
+"you make a copy. Are you sure you want to proceed?"
+msgstr ""
+"Va a historificar una LdM. Si lo hace, no podrá volver a activarla a no ser "
+"que saque una copia ¿Está seguro de que desea proceder?"
+
+#. module: mrp_bom_version
+#: view:mrp.bom:mrp_bom_version.mrp_bom_form_view_inh_state
+msgid ""
+"You will activate the BoM. If you haven't set a route yet, then you won't be "
+"able to do it after this. Are you sure you want to proceed?"
+msgstr ""
+"Va a activar la LdM. Si no ha puesto ruta, no podrá ya ponerla. ¿Está seguro "
+"de que desea proceder?"
diff --git a/mrp_bom_version/i18n/mrp_bom_version.pot b/mrp_bom_version/i18n/mrp_bom_version.pot
new file mode 100644
index 000000000..b37901133
--- /dev/null
+++ b/mrp_bom_version/i18n/mrp_bom_version.pot
@@ -0,0 +1,116 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * mrp_bom_version
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: Odoo Server 8.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2015-05-22 08:58+0000\n"
+"PO-Revision-Date: 2015-05-22 08:58+0000\n"
+"Last-Translator: <>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Plural-Forms: \n"
+
+#. module: mrp_bom_version
+#: view:mrp.bom:mrp_bom_version.mrp_bom_form_view_inh_state
+msgid "Activate"
+msgstr ""
+
+#. module: mrp_bom_version
+#: view:mrp.bom:mrp_bom_version.view_mrp_bom_filter_inh_state
+#: selection:mrp.bom,state:0
+msgid "Active"
+msgstr ""
+
+#. module: mrp_bom_version
+#: field:mrp.config.settings,group_mrp_bom_state:0
+msgid "Allow to re-edit BoMs"
+msgstr ""
+
+#. module: mrp_bom_version
+#: model:ir.model,name:mrp_bom_version.model_mrp_bom
+msgid "Bill of Material"
+msgstr ""
+
+#. module: mrp_bom_version
+#: view:mrp.bom:mrp_bom_version.mrp_bom_form_view_inh_state
+#: selection:mrp.bom,state:0
+msgid "Draft"
+msgstr ""
+
+#. module: mrp_bom_version
+#: view:mrp.bom:mrp_bom_version.mrp_bom_form_view_inh_state
+#: selection:mrp.bom,state:0
+msgid "Historical"
+msgstr ""
+
+#. module: mrp_bom_version
+#: field:mrp.bom,historical_date:0
+msgid "Historical Date"
+msgstr ""
+
+#. module: mrp_bom_version
+#: model:mail.message.subtype,description:mrp_bom_version.mt_active
+#: model:mail.message.subtype,name:mrp_bom_version.mt_active
+msgid "MRP BoM Active"
+msgstr ""
+
+#. module: mrp_bom_version
+#: model:res.groups,name:mrp_bom_version.group_mrp_bom_version
+msgid "MRP BoM version"
+msgstr ""
+
+#. module: mrp_bom_version
+#: model:ir.model,name:mrp_bom_version.model_mrp_production
+msgid "Manufacturing Order"
+msgstr ""
+
+#. module: mrp_bom_version
+#: view:mrp.bom:mrp_bom_version.mrp_bom_form_view_inh_state
+msgid "New version"
+msgstr ""
+
+#. module: mrp_bom_version
+#: view:mrp.bom:mrp_bom_version.view_mrp_bom_filter_inh_state
+msgid "Product"
+msgstr ""
+
+#. module: mrp_bom_version
+#: view:mrp.bom:mrp_bom_version.view_mrp_bom_filter_inh_state
+msgid "State"
+msgstr ""
+
+#. module: mrp_bom_version
+#: field:mrp.bom,state:0
+msgid "Status"
+msgstr ""
+
+#. module: mrp_bom_version
+#: help:mrp.config.settings,group_mrp_bom_state:0
+msgid "The active state may be passed back to state draft"
+msgstr ""
+
+#. module: mrp_bom_version
+#: field:mrp.bom,version:0
+msgid "Version"
+msgstr ""
+
+#. module: mrp_bom_version
+#: view:mrp.bom:mrp_bom_version.mrp_bom_form_view_inh_state
+msgid "You are going to create a new version of this BoM. Are you sure?"
+msgstr ""
+
+#. module: mrp_bom_version
+#: view:mrp.bom:mrp_bom_version.mrp_bom_form_view_inh_state
+msgid "You are going to historize an BoM. Doing, not be able to unlock it unless you make a copy. Are you sure you want to proceed?"
+msgstr ""
+
+#. module: mrp_bom_version
+#: view:mrp.bom:mrp_bom_version.mrp_bom_form_view_inh_state
+msgid "You will activate the BoM. If you haven't set a route yet, then you won't be able to do it after this. Are you sure you want to proceed?"
+msgstr ""
+
diff --git a/mrp_bom_version/models/__init__.py b/mrp_bom_version/models/__init__.py
new file mode 100644
index 000000000..99464ac48
--- /dev/null
+++ b/mrp_bom_version/models/__init__.py
@@ -0,0 +1,6 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+# For copyright and license notices, see __openerp__.py file in root directory
+##############################################################################
+from . import mrp
+from . import res_config
diff --git a/mrp_bom_version/models/mrp.py b/mrp_bom_version/models/mrp.py
new file mode 100644
index 000000000..02727e625
--- /dev/null
+++ b/mrp_bom_version/models/mrp.py
@@ -0,0 +1,130 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+# For copyright and license notices, see __openerp__.py file in root directory
+##############################################################################
+from openerp import models, fields, api
+
+
+class MrpBom(models.Model):
+ _inherit = 'mrp.bom'
+
+ _track = {
+ 'state': {
+ 'mrp_bom_version.mt_active': lambda self, cr, uid, obj,
+ ctx=None: obj.state == 'active',
+ },
+ }
+
+ active = fields.Boolean(
+ string='Active', default=False, readonly=True,
+ states={'draft': [('readonly', False)]})
+ historical_date = fields.Date(string='Historical Date', readonly=True)
+ state = fields.Selection([('draft', 'Draft'),
+ ('active', 'Active'),
+ ('historical', 'Historical'),
+ ], string='Status', index=True, readonly=True,
+ default='draft', copy=False)
+ product_tmpl_id = fields.Many2one(
+ readonly=True, states={'draft': [('readonly', False)]})
+ product_id = fields.Many2one(
+ readonly=True, states={'draft': [('readonly', False)]})
+ product_qty = fields.Float(
+ readonly=True, states={'draft': [('readonly', False)]})
+ name = fields.Char(
+ states={'historical': [('readonly', True)]})
+ code = fields.Char(
+ states={'historical': [('readonly', True)]})
+ type = fields.Selection(
+ states={'historical': [('readonly', True)]})
+ company_id = fields.Many2one(
+ states={'historical': [('readonly', True)]})
+ product_uom = fields.Many2one(
+ states={'historical': [('readonly', True)]})
+ routing_id = fields.Many2one(
+ readonly=True, states={'draft': [('readonly', False)]})
+ bom_line_ids = fields.One2many(
+ readonly=True, states={'draft': [('readonly', False)]})
+ position = fields.Char(
+ states={'historical': [('readonly', True)]})
+ date_start = fields.Date(
+ states={'historical': [('readonly', True)]})
+ date_stop = fields.Date(
+ states={'historical': [('readonly', True)]})
+ property_ids = fields.Many2many(
+ states={'historical': [('readonly', True)]})
+ product_rounding = fields.Float(
+ states={'historical': [('readonly', True)]})
+ product_efficiency = fields.Float(
+ states={'historical': [('readonly', True)]})
+ message_follower_ids = fields.Many2many(
+ states={'historical': [('readonly', True)]})
+ message_ids = fields.One2many(
+ states={'historical': [('readonly', True)]})
+ version = fields.Integer(states={'historical': [('readonly', True)]},
+ copy=False, default=1)
+
+ @api.multi
+ def button_draft(self):
+ self.state = 'draft'
+
+ @api.multi
+ def button_new_version(self):
+ self.ensure_one()
+ self.write({'active': False, 'state': 'historical',
+ 'historical_date': fields.Date.today()})
+ version = self.version + 1
+ new_bom = self.copy({'version': version})
+ new_bom.active = True
+ return {'type': 'ir.actions.act_window',
+ 'view_type': 'form, tree',
+ 'view_mode': 'form',
+ 'res_model': 'mrp.bom',
+ 'res_id': new_bom.id,
+ 'target': 'new',
+ }
+
+ @api.one
+ def button_activate(self):
+ return self.write({'active': True, 'state': 'active'})
+
+ @api.one
+ def button_historical(self):
+ return self.write({'active': False, 'state': 'historical',
+ 'historical_date': fields.Date.today()})
+
+
+class MrpProduction(models.Model):
+ _inherit = 'mrp.production'
+
+ def product_id_change(self, cr, uid, ids, product_id, product_qty=0,
+ context=None):
+ bom_obj = self.pool['mrp.bom']
+ product_obj = self.pool['product.product']
+ res = super(MrpProduction, self).product_id_change(
+ cr, uid, ids, product_id=product_id, product_qty=product_qty,
+ context=context)
+ if product_id:
+ res['value'].update({'bom_id': False})
+ product_tmpl_id = product_obj.browse(
+ cr, uid, product_id, context=context).product_tmpl_id.id
+ domain = [('state', '=', 'active'),
+ '|',
+ ('product_id', '=', product_id),
+ '&',
+ ('product_id', '=', False),
+ ('product_tmpl_id', '=', product_tmpl_id)
+ ]
+ domain = domain + ['|', ('date_start', '=', False),
+ ('date_start', '<=', fields.Datetime.now()),
+ '|', ('date_stop', '=', False),
+ ('date_stop', '>=', fields.Datetime.now())]
+ bom_ids = bom_obj.search(cr, uid, domain, context=context)
+ bom_id = 0
+ min_seq = 0
+ for bom in bom_obj.browse(cr, uid, bom_ids, context=context):
+ if min_seq == 0 or bom.sequence < min_seq:
+ min_seq = bom.sequence
+ bom_id = bom.id
+ if bom_id > 0:
+ res['value'].update({'bom_id': bom_id})
+ return res
diff --git a/mrp_bom_version/models/res_config.py b/mrp_bom_version/models/res_config.py
new file mode 100644
index 000000000..5d75d8bb6
--- /dev/null
+++ b/mrp_bom_version/models/res_config.py
@@ -0,0 +1,14 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+# For copyright and license notices, see __openerp__.py file in root directory
+##############################################################################
+from openerp import models, fields
+
+
+class MrpConfigSettings(models.TransientModel):
+ _inherit = 'mrp.config.settings'
+
+ group_mrp_bom_state = fields.Boolean(
+ string='Allow to re-edit BoMs',
+ implied_group='mrp_bom_version.group_mrp_bom_version',
+ help='The active state may be passed back to state draft')
diff --git a/mrp_bom_version/security/mrp_bom_version_security.xml b/mrp_bom_version/security/mrp_bom_version_security.xml
new file mode 100644
index 000000000..a0ea08559
--- /dev/null
+++ b/mrp_bom_version/security/mrp_bom_version_security.xml
@@ -0,0 +1,9 @@
+
+
+
+
+ MRP BoM version
+
+
+
+
diff --git a/mrp_bom_version/views/mrp_bom_view.xml b/mrp_bom_version/views/mrp_bom_view.xml
new file mode 100644
index 000000000..fe7e6de29
--- /dev/null
+++ b/mrp_bom_version/views/mrp_bom_view.xml
@@ -0,0 +1,86 @@
+
+
+
+
+ mrp.bom.tree.parent.view
+ mrp.bom
+
+
+
+
+
+
+
+
+
+ mrp.bom.state.tree.view
+ mrp.bom
+
+
+
+
+
+
+
+
+
+
+
+
+ mrp.bom.form.view.inh.state
+ mrp.bom
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ view.mrp.bom.filter.inh.state
+ mrp.bom
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/mrp_bom_version/views/res_config_view.xml b/mrp_bom_version/views/res_config_view.xml
new file mode 100644
index 000000000..d5c21a928
--- /dev/null
+++ b/mrp_bom_version/views/res_config_view.xml
@@ -0,0 +1,18 @@
+
+
+
+
+ view.mrp.config.inh.bomstate
+ mrp.config.settings
+
+
+
+