[NEW mrp_bom_version]

This commit is contained in:
alfredo
2014-10-23 17:23:28 +02:00
committed by Kay K. Cross
parent 560104a973
commit 48e460498a
9 changed files with 559 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
# -*- 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 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/.
#
##############################################################################
from . import models

View File

@@ -0,0 +1,53 @@
# -*- 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 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",
"category": "MRP",
"website": "http://www.odoomrp.com",
"description": """
This module performs the following:
1.- In the MRP BoM list object, 3 new fields are added:
1.1.- Review, of type integer, defined by hand. When saving the list
verified that there is another with the same sequence.
1.2.- Historical Date, of type date.
1.3.- Status, of type selection, with these values: draft, in active
and historical. This new field has gotten because it has added a
workflow to MRP BoM list object.
2.- In the MRP bom List object, a workflow is added, is this:
2.1.- Draft -> In Active -> Historical, and you can not go back.
You can only modify the components and / or production process if it is in
draft status. The other fields can only be changed if they are not in
historical state.
when the MRP BoM list is put to active, a record of who has activated,
and when will include in chatter/log.
""",
"depends": ['mrp',
],
"data": ['data/mrp_bom_data.xml',
'data/mrp_bom_workflow.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>

View File

@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record id="wkf_mrp_bom" model="workflow">
<field name="name">mrp.bom.basic</field>
<field name="osv">mrp.bom</field>
<field name="on_create">True</field>
</record>
<record id="act_draft" model="workflow.activity">
<field name="wkf_id" ref="wkf_mrp_bom"/>
<field name="flow_start">True</field>
<field name="name">draft</field>
<field name="kind">function</field>
<field name="action">action_draft()</field>
</record>
<record id="act_active" model="workflow.activity">
<field name="wkf_id" ref="wkf_mrp_bom"/>
<field name="name">active</field>
<field name="kind">function</field>
<field name="action">action_active()</field>
</record>
<record id="act_historical" model="workflow.activity">
<field name="wkf_id" ref="wkf_mrp_bom"/>
<field name="flow_end">True</field>
<field name="name">historical</field>
<field name="kind">function</field>
<field name="action">action_historical()</field>
</record>
<record id="trans_draft_active" model="workflow.transition">
<field name="act_from" ref="act_draft"/>
<field name="act_to" ref="act_active"/>
<field name="signal">button_active</field>
</record>
<record id="trans_active_historical" model="workflow.transition">
<field name="act_from" ref="act_active"/>
<field name="act_to" ref="act_historical"/>
<field name="signal">button_historical</field>
</record>
</data>
</openerp>

View File

@@ -0,0 +1,95 @@
# 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: 2014-10-23 14:36+0000\n"
"PO-Revision-Date: 2014-10-23 16:40+0100\n"
"Last-Translator: Alfredo <alfredodelafuente@avanzosc.com>\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"
#. module: mrp_bom_version
#: view:mrp.bom:mrp_bom_version.view_mrp_bom_filter_inh_version
#: selection:mrp.bom,state:0
msgid "Active"
msgstr "Activo"
#. 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
#: selection:mrp.bom,state:0
msgid "Draft"
msgstr "Borrador"
#. module: mrp_bom_version
#: view:mrp.bom:mrp_bom_version.mrp_bom_form_view_inh_version
#: 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
#: view:mrp.bom:mrp_bom_version.mrp_bom_form_view_inh_version
msgid "In active"
msgstr "En activo"
#. module: mrp_bom_version
#: view:mrp.bom:mrp_bom_version.mrp_bom_tree_view
msgid "MRP BoMs"
msgstr "MRP LdMs"
#. 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.view_mrp_bom_filter_inh_version
msgid "Product"
msgstr "Producto"
#. module: mrp_bom_version
#: field:mrp.bom,review:0
msgid "Review"
msgstr "Revisión"
#. module: mrp_bom_version
#: view:mrp.bom:mrp_bom_version.view_mrp_bom_filter_inh_version
msgid "State"
msgstr "Estado"
#. module: mrp_bom_version
#: field:mrp.bom,state:0
msgid "Status"
msgstr "Estatus"
#. module: mrp_bom_version
#: code:addons/mrp_bom_version/models/mrp.py:49
#, python-format
msgid "The version number must be unique"
msgstr "El número de versión debe ser única"
#. module: mrp_bom_version
#: view:mrp.bom:mrp_bom_version.mrp_bom_form_view_inh_version
msgid "{'readonly':[('state', '!=', 'draft')]}"
msgstr "{'readonly':[('state', '!=', 'draft')]}"
#. module: mrp_bom_version
#: view:mrp.bom:mrp_bom_version.mrp_bom_form_view_inh_version
msgid "{'readonly':[('state', '=', 'historical')]}"
msgstr "{'readonly':[('state', '=', 'historical')]}"

View File

@@ -0,0 +1,95 @@
# 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: 2014-10-23 14:35+0000\n"
"PO-Revision-Date: 2014-10-23 14:35+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.view_mrp_bom_filter_inh_version
#: selection:mrp.bom,state:0
msgid "Active"
msgstr ""
#. module: mrp_bom_version
#: model:ir.model,name:mrp_bom_version.model_mrp_bom
msgid "Bill of Material"
msgstr ""
#. module: mrp_bom_version
#: selection:mrp.bom,state:0
msgid "Draft"
msgstr ""
#. module: mrp_bom_version
#: view:mrp.bom:mrp_bom_version.mrp_bom_form_view_inh_version
#: 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
#: view:mrp.bom:mrp_bom_version.mrp_bom_form_view_inh_version
msgid "In active"
msgstr ""
#. module: mrp_bom_version
#: view:mrp.bom:mrp_bom_version.mrp_bom_tree_view
msgid "MRP BoMs"
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.view_mrp_bom_filter_inh_version
msgid "Product"
msgstr ""
#. module: mrp_bom_version
#: field:mrp.bom,review:0
msgid "Review"
msgstr ""
#. module: mrp_bom_version
#: view:mrp.bom:mrp_bom_version.view_mrp_bom_filter_inh_version
msgid "State"
msgstr ""
#. module: mrp_bom_version
#: field:mrp.bom,state:0
msgid "Status"
msgstr ""
#. module: mrp_bom_version
#: code:addons/mrp_bom_version/models/mrp.py:49
#, python-format
msgid "The version number must be unique"
msgstr ""
#. module: mrp_bom_version
#: view:mrp.bom:mrp_bom_version.mrp_bom_form_view_inh_version
msgid "{'readonly':[('state', '!=', 'draft')]}"
msgstr ""
#. module: mrp_bom_version
#: view:mrp.bom:mrp_bom_version.mrp_bom_form_view_inh_version
msgid "{'readonly':[('state', '=', 'historical')]}"
msgstr ""

View File

@@ -0,0 +1,18 @@
# -*- 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 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/.
#
##############################################################################
from . import mrp

View File

@@ -0,0 +1,116 @@
# -*- 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 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/.
#
##############################################################################
from openerp import models, fields, api, exceptions, _
from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT
import time
class MrpBom(models.Model):
_inherit = 'mrp.bom'
_track = {
'state': {
'mrp_bom_version.mt_active': lambda self, cr, uid, obj,
ctx=None: obj.state == 'active',
},
}
review = fields.Integer(string='Review')
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)
@api.one
@api.constrains('review')
def check_mrp_bom_version(self):
domain = [('id', '!=', self.id), ('review', '=', self.review)]
if self.product_tmpl_id:
domain.append(('product_tmpl_id', '=', self.product_tmpl_id.id))
else:
domain.append(('product_tmpl_id', '=', False))
if self.product_id:
domain.append(('product_id', '=', self.product_id.id))
else:
domain.append(('product_id', '=', False))
found = self.search(domain)
if found:
raise exceptions.Warning(
_('The version number must be unique'))
def copy(self, cr, uid, id, default=None, context=None):
if default is None:
default = {}
default.update({'review': 0})
return super(MrpBom, self).copy(cr, uid, id, default=default,
context=context)
@api.multi
def action_draft(self):
return self.write({'state': 'draft'})
@api.multi
def action_active(self):
return self.write({'state': 'active'})
@api.multi
def action_historical(self):
return self.write({'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', '<=',
time.strftime(DEFAULT_SERVER_DATETIME_FORMAT)),
'|', ('date_stop', '=', False),
('date_stop', '>=',
time.strftime(
DEFAULT_SERVER_DATETIME_FORMAT))]
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,113 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="mrp_bom_tree_view" model="ir.ui.view">
<field name="name">mrp.bom.tree.view</field>
<field name="model">mrp.bom</field>
<field name="arch" type="xml">
<tree string="MRP BoMs">
<field name="name"/>
<field name="active" />
<field name="review" />
<field name="state" />
<field name="historical_date"/>
</tree>
</field>
</record>
<record id="mrp_bom_form_view_inh_version" model="ir.ui.view">
<field name="name">mrp.bom.form.view.inh.version</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_active" states="draft" string="In active" class="oe_highlight" />
<button name="button_historical" states="active" string="Historical" class="oe_highlight"/>
<field name="state" widget="statusbar" statusbar_visible="draft,open,paid" />
</header>
</xpath>
<field name="company_id" position="after">
<group colspan="2" col="4">
<field name="review" attrs="{'readonly':[('state', '=', 'historical')]}" />
<field name="historical_date" />
</group>
</field>
<field name="product_tmpl_id" position="attributes">
<attribute name="attrs">{'readonly':[('state', '=', 'historical')]}</attribute>
</field>
<field name="product_id" position="attributes">
<attribute name="attrs">{'readonly':[('state', '=', 'historical')]}</attribute>
</field>
<field name="product_qty" position="attributes">
<attribute name="attrs">{'readonly':[('state', '=', 'historical')]}</attribute>
</field>
<field name="product_uom" position="attributes">
<attribute name="attrs">{'readonly':[('state', '=', 'historical')]}</attribute>
</field>
<field name="routing_id" position="attributes">
<attribute name="attrs">{'readonly':[('state', '!=', 'draft')]}</attribute>
</field>
<field name="name" position="attributes">
<attribute name="attrs">{'readonly':[('state', '=', 'historical')]}</attribute>
</field>
<field name="code" position="attributes">
<attribute name="attrs">{'readonly':[('state', '=', 'historical')]}</attribute>
</field>
<field name="type" position="attributes">
<attribute name="attrs">{'readonly':[('state', '=', 'historical')]}</attribute>
</field>
<field name="company_id" position="attributes">
<attribute name="attrs">{'readonly':[('state', '=', 'historical')]}</attribute>
</field>
<field name="bom_line_ids" position="attributes">
<attribute name="attrs">{'readonly':[('state', '!=', 'draft')]}</attribute>
</field>
<field name="position" position="attributes">
<attribute name="attrs">{'readonly':[('state', '=', 'historical')]}</attribute>
</field>
<field name="sequence" position="attributes">
<attribute name="attrs">{'readonly':[('state', '=', 'historical')]}</attribute>
</field>
<field name="active" position="attributes">
<attribute name="attrs">{'readonly':[('state', '=', 'historical')]}</attribute>
</field>
<field name="date_start" position="attributes">
<attribute name="attrs">{'readonly':[('state', '=', 'historical')]}</attribute>
</field>
<field name="date_stop" position="attributes">
<attribute name="attrs">{'readonly':[('state', '=', 'historical')]}</attribute>
</field>
<field name="product_rounding" position="attributes">
<attribute name="attrs">{'readonly':[('state', '=', 'historical')]}</attribute>
</field>
<field name="product_efficiency" position="attributes">
<attribute name="attrs">{'readonly':[('state', '=', 'historical')]}</attribute>
</field>
<field name="property_ids" position="attributes">
<attribute name="attrs">{'readonly':[('state', '=', 'historical')]}</attribute>
</field>
<field name="message_follower_ids" position="attributes">
<attribute name="attrs">{'readonly':[('state', '=', 'historical')]}</attribute>
</field>
<field name="message_ids" position="attributes">
<attribute name="attrs">{'readonly':[('state', '=', 'historical')]}</attribute>
</field>
</field>
</record>
<record id="view_mrp_bom_filter_inh_version" model="ir.ui.view">
<field name="name">view.mrp.bom.filter.inh.version</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>