[IMP] mrp_bom_version: renamed module mrp_bom_state to mrp_bom_version

[IMP] mrp_bom_version: fix flake8

[IMP]mrp_bom_version: fix travis
This commit is contained in:
InakiZabala
2015-05-25 10:57:20 +02:00
committed by oihane
parent 90258728c6
commit 8b84e06b86
12 changed files with 591 additions and 0 deletions

View File

@@ -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

View File

@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
##############################################################################
# For copyright and license notices, see __openerp__.py file in root directory
##############################################################################
from . import models

View File

@@ -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 <http://www.gnu.org/licenses/>.
#
##############################################################################
{
"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 <pedro.baeza@serviciosbaeza.com",
"Ana Juaristi <anajuaristi@avanzosc.es>",
"Alfredo de la Fuente <alfredodelafuente@avanzosc.es>",
],
"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
}

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record id="mt_active" model="mail.message.subtype">
<field name="name">MRP BoM Active</field>
<field name="res_model">mrp.bom</field>
<field name="default" eval="False"/>
<field name="description">MRP BoM Active</field>
</record>
</data>
</openerp>

125
mrp_bom_version/i18n/es.po Normal file
View File

@@ -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?"

View File

@@ -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 ""

View File

@@ -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

View File

@@ -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

View File

@@ -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')

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data noupdate="1">
<record id="group_mrp_bom_version" model="res.groups">
<field name="name">MRP BoM version</field>
<field name="category_id" ref="base.module_category_hidden" />
</record>
</data>
</openerp>

View File

@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="mrp.mrp_bom_tree_parent_view" model="ir.ui.view">
<field name="name">mrp.bom.tree.parent.view</field>
<field name="model">mrp.bom</field>
<field name="arch" type="xml">
<tree string="MRP BoMs">
<field name="code"/>
<field name="name"/>
</tree>
</field>
</record>
<record id="mrp_bom_state_tree_view" model="ir.ui.view">
<field name="name">mrp.bom.state.tree.view</field>
<field name="model">mrp.bom</field>
<field name="inherit_id" ref="mrp.mrp_bom_tree_parent_view"/>
<field name="arch" type="xml">
<field name="name" position="after">
<field name="active" />
<field name="version" />
<field name="state" />
<field name="historical_date"/>
</field>
</field>
</record>
<record id="mrp_bom_form_view_inh_state" model="ir.ui.view">
<field name="name">mrp.bom.form.view.inh.state</field>
<field name="model">mrp.bom</field>
<field name="inherit_id" ref="mrp.mrp_bom_form_view"/>
<field name="arch" type="xml">
<xpath expr="//form/group" position="before">
<header>
<button name="button_draft"
type="object"
string="Draft"
groups="mrp_bom_state.group_mrp_bom_state"
attrs="{'invisible':[('state','!=','active')]}"
class="oe_highlight" />
<button name="button_activate"
type="object" string="Activate"
attrs="{'invisible':[('state','not in',(False, 'draft'))]}"
class="oe_highlight"
confirm="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?"/>
<button name="button_new_version"
type="object"
string="New version"
attrs="{'invisible':[('state','==','historical')]}"
class="oe_highlight"
confirm="You are going to create a new version of this BoM. Are you sure?"/>
<button name="button_historical"
type="object"
string="Historical"
attrs="{'invisible':[('state','!=','active')]}"
class="oe_highlight"
confirm="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?"/>
<field name="state" widget="statusbar" statusbar_visible="draft,active,historical" />
</header>
</xpath>
<field name="company_id" position="after">
<field name="version" />
<field name="historical_date" attrs="{'invisible': [('state','!=','historical')]}"/>
</field>
</field>
</record>
<record id="view_mrp_bom_filter_inh_state" model="ir.ui.view">
<field name="name">view.mrp.bom.filter.inh.state</field>
<field name="model">mrp.bom</field>
<field name="inherit_id" ref="mrp.view_mrp_bom_filter"/>
<field name="arch" type="xml">
<field name="name" position="after">
<field name="active" />
<field name="state" />
</field>
<filter string="Product" position="before">
<filter string="Active" domain="[]" context="{'group_by':'active'}"/>
<filter string="State" domain="[]" context="{'group_by':'state'}"/>
</filter>
</field>
</record>
</data>
</openerp>

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record model="ir.ui.view" id="view_mrp_config_inh_bomstate">
<field name="name">view.mrp.config.inh.bomstate</field>
<field name="model">mrp.config.settings</field>
<field name="inherit_id" ref="mrp.view_mrp_config" />
<field name="arch" type="xml">
<xpath expr="//field[@name='module_mrp_repair']/.." position="after">
<div>
<field name="group_mrp_bom_state" class="oe_inline"/>
<label for="group_mrp_bom_state"/>
</div>
</xpath>
</field>
</record>
</data>
</openerp>