From 48e460498a43e48432d76456427eb9a41b0f8875 Mon Sep 17 00:00:00 2001 From: alfredo Date: Thu, 23 Oct 2014 17:23:28 +0200 Subject: [PATCH 01/37] [NEW mrp_bom_version] --- mrp_bom_version/__init__.py | 18 ++++ mrp_bom_version/__openerp__.py | 53 ++++++++++ mrp_bom_version/data/mrp_bom_data.xml | 11 ++ mrp_bom_version/data/mrp_bom_workflow.xml | 40 ++++++++ mrp_bom_version/i18n/es.po | 95 ++++++++++++++++++ mrp_bom_version/i18n/mrp_bom_version.pot | 95 ++++++++++++++++++ mrp_bom_version/models/__init__.py | 18 ++++ mrp_bom_version/models/mrp.py | 116 ++++++++++++++++++++++ mrp_bom_version/views/mrp_bom_view.xml | 113 +++++++++++++++++++++ 9 files changed, 559 insertions(+) create mode 100644 mrp_bom_version/__init__.py create mode 100644 mrp_bom_version/__openerp__.py create mode 100644 mrp_bom_version/data/mrp_bom_data.xml create mode 100644 mrp_bom_version/data/mrp_bom_workflow.xml create mode 100644 mrp_bom_version/i18n/es.po create mode 100644 mrp_bom_version/i18n/mrp_bom_version.pot create mode 100644 mrp_bom_version/models/__init__.py create mode 100644 mrp_bom_version/models/mrp.py create mode 100644 mrp_bom_version/views/mrp_bom_view.xml diff --git a/mrp_bom_version/__init__.py b/mrp_bom_version/__init__.py new file mode 100644 index 000000000..c58ee95de --- /dev/null +++ b/mrp_bom_version/__init__.py @@ -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 diff --git a/mrp_bom_version/__openerp__.py b/mrp_bom_version/__openerp__.py new file mode 100644 index 000000000..54d5ab046 --- /dev/null +++ b/mrp_bom_version/__openerp__.py @@ -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 +} 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/data/mrp_bom_workflow.xml b/mrp_bom_version/data/mrp_bom_workflow.xml new file mode 100644 index 000000000..f06bf7132 --- /dev/null +++ b/mrp_bom_version/data/mrp_bom_workflow.xml @@ -0,0 +1,40 @@ + + + + + mrp.bom.basic + mrp.bom + True + + + + True + draft + function + action_draft() + + + + active + function + action_active() + + + + True + historical + function + action_historical() + + + + + button_active + + + + + button_historical + + + \ No newline at end of file diff --git a/mrp_bom_version/i18n/es.po b/mrp_bom_version/i18n/es.po new file mode 100644 index 000000000..a551e0ec6 --- /dev/null +++ b/mrp_bom_version/i18n/es.po @@ -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 \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')]}" + 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..f99295cce --- /dev/null +++ b/mrp_bom_version/i18n/mrp_bom_version.pot @@ -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 "" + diff --git a/mrp_bom_version/models/__init__.py b/mrp_bom_version/models/__init__.py new file mode 100644 index 000000000..86314fbb3 --- /dev/null +++ b/mrp_bom_version/models/__init__.py @@ -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 diff --git a/mrp_bom_version/models/mrp.py b/mrp_bom_version/models/mrp.py new file mode 100644 index 000000000..b63ef0c83 --- /dev/null +++ b/mrp_bom_version/models/mrp.py @@ -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 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..f9483b65e --- /dev/null +++ b/mrp_bom_version/views/mrp_bom_view.xml @@ -0,0 +1,113 @@ + + + + + mrp.bom.tree.view + mrp.bom + + + + + + + + + + + + mrp.bom.form.view.inh.version + mrp.bom + + + +
+
+
+ + + + + + + + {'readonly':[('state', '=', 'historical')]} + + + {'readonly':[('state', '=', 'historical')]} + + + {'readonly':[('state', '=', 'historical')]} + + + {'readonly':[('state', '=', 'historical')]} + + + {'readonly':[('state', '!=', 'draft')]} + + + {'readonly':[('state', '=', 'historical')]} + + + {'readonly':[('state', '=', 'historical')]} + + + {'readonly':[('state', '=', 'historical')]} + + + {'readonly':[('state', '=', 'historical')]} + + + {'readonly':[('state', '!=', 'draft')]} + + + {'readonly':[('state', '=', 'historical')]} + + + {'readonly':[('state', '=', 'historical')]} + + + {'readonly':[('state', '=', 'historical')]} + + + {'readonly':[('state', '=', 'historical')]} + + + {'readonly':[('state', '=', 'historical')]} + + + {'readonly':[('state', '=', 'historical')]} + + + {'readonly':[('state', '=', 'historical')]} + + + {'readonly':[('state', '=', 'historical')]} + + + {'readonly':[('state', '=', 'historical')]} + + + {'readonly':[('state', '=', 'historical')]} + +
+
+ + view.mrp.bom.filter.inh.version + mrp.bom + + + + + + + + + + + + +
+
From 94b9ea423ab74c4e86878e1da84dec4d3602e49d Mon Sep 17 00:00:00 2001 From: alfredo Date: Tue, 28 Oct 2014 15:16:12 +0100 Subject: [PATCH 02/37] [IMP mrp_bom_version] --- mrp_bom_version/__openerp__.py | 16 ++---- mrp_bom_version/data/mrp_bom_workflow.xml | 40 --------------- mrp_bom_version/i18n/es.po | 21 ++++---- mrp_bom_version/i18n/mrp_bom_version.pot | 19 +++---- mrp_bom_version/models/mrp.py | 32 +++++------- mrp_bom_version/views/mrp_bom_view.xml | 62 +++++++++++------------ 6 files changed, 70 insertions(+), 120 deletions(-) delete mode 100644 mrp_bom_version/data/mrp_bom_workflow.xml diff --git a/mrp_bom_version/__openerp__.py b/mrp_bom_version/__openerp__.py index 54d5ab046..5f24fba0d 100644 --- a/mrp_bom_version/__openerp__.py +++ b/mrp_bom_version/__openerp__.py @@ -19,34 +19,28 @@ "name": "MRP BoM Version", "version": "1.0", "author": "OdooMRP team", - "category": "MRP", + "category": "Manufacturing", "website": "http://www.odoomrp.com", "description": """ This module performs the following: - 1.- In the MRP BoM list object, 3 new fields are added: + 1.- In the MRP BoM list object, 2 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 + 1.1.- Historical Date, of type date. + 1.2.- 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. + Also creates a constraint for the sequence field to be unique. """, "depends": ['mrp', ], "data": ['data/mrp_bom_data.xml', - 'data/mrp_bom_workflow.xml', 'views/mrp_bom_view.xml', ], "installable": True diff --git a/mrp_bom_version/data/mrp_bom_workflow.xml b/mrp_bom_version/data/mrp_bom_workflow.xml deleted file mode 100644 index f06bf7132..000000000 --- a/mrp_bom_version/data/mrp_bom_workflow.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - mrp.bom.basic - mrp.bom - True - - - - True - draft - function - action_draft() - - - - active - function - action_active() - - - - True - historical - function - action_historical() - - - - - button_active - - - - - button_historical - - - \ No newline at end of file diff --git a/mrp_bom_version/i18n/es.po b/mrp_bom_version/i18n/es.po index a551e0ec6..8f25cf7e8 100644 --- a/mrp_bom_version/i18n/es.po +++ b/mrp_bom_version/i18n/es.po @@ -6,8 +6,8 @@ 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" +"POT-Creation-Date: 2014-11-10 09:13+0000\n" +"PO-Revision-Date: 2014-11-10 10:14+0100\n" "Last-Translator: Alfredo \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -47,6 +47,12 @@ msgstr "Fecha historificación" msgid "In active" msgstr "En activo" +#. 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 "MRP BoM Active" + #. module: mrp_bom_version #: view:mrp.bom:mrp_bom_version.mrp_bom_tree_view msgid "MRP BoMs" @@ -62,11 +68,6 @@ msgstr "Órden de producción" 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" @@ -78,10 +79,10 @@ msgid "Status" msgstr "Estatus" #. module: mrp_bom_version -#: code:addons/mrp_bom_version/models/mrp.py:49 +#: code:addons/mrp_bom_version/models/mrp.py:53 #, python-format -msgid "The version number must be unique" -msgstr "El número de versión debe ser única" +msgid "The sequence must be unique" +msgstr "La secuencia debe ser única." #. module: mrp_bom_version #: view:mrp.bom:mrp_bom_version.mrp_bom_form_view_inh_version diff --git a/mrp_bom_version/i18n/mrp_bom_version.pot b/mrp_bom_version/i18n/mrp_bom_version.pot index f99295cce..a2aa517a0 100644 --- a/mrp_bom_version/i18n/mrp_bom_version.pot +++ b/mrp_bom_version/i18n/mrp_bom_version.pot @@ -6,8 +6,8 @@ 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" +"POT-Creation-Date: 2014-11-10 09:13+0000\n" +"PO-Revision-Date: 2014-11-10 09:13+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -47,6 +47,12 @@ msgstr "" msgid "In active" 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 #: view:mrp.bom:mrp_bom_version.mrp_bom_tree_view msgid "MRP BoMs" @@ -62,11 +68,6 @@ msgstr "" 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" @@ -78,9 +79,9 @@ msgid "Status" msgstr "" #. module: mrp_bom_version -#: code:addons/mrp_bom_version/models/mrp.py:49 +#: code:addons/mrp_bom_version/models/mrp.py:53 #, python-format -msgid "The version number must be unique" +msgid "The sequence must be unique" msgstr "" #. module: mrp_bom_version diff --git a/mrp_bom_version/models/mrp.py b/mrp_bom_version/models/mrp.py index b63ef0c83..9315bcd53 100644 --- a/mrp_bom_version/models/mrp.py +++ b/mrp_bom_version/models/mrp.py @@ -16,8 +16,6 @@ # ############################################################################## from openerp import models, fields, api, exceptions, _ -from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT -import time class MrpBom(models.Model): @@ -30,7 +28,6 @@ class MrpBom(models.Model): }, } - review = fields.Integer(string='Review') historical_date = fields.Date(string='Historical Date', readonly=True) state = fields.Selection([('draft', 'Draft'), ('active', 'Active'), @@ -39,9 +36,9 @@ class MrpBom(models.Model): default='draft', copy=False) @api.one - @api.constrains('review') - def check_mrp_bom_version(self): - domain = [('id', '!=', self.id), ('review', '=', self.review)] + @api.constrains('sequence') + def check_mrp_bom_sequence(self): + domain = [('id', '!=', self.id), ('sequence', '=', self.sequence)] if self.product_tmpl_id: domain.append(('product_tmpl_id', '=', self.product_tmpl_id.id)) else: @@ -53,25 +50,25 @@ class MrpBom(models.Model): found = self.search(domain) if found: raise exceptions.Warning( - _('The version number must be unique')) + _('The sequence must be unique')) def copy(self, cr, uid, id, default=None, context=None): if default is None: default = {} - default.update({'review': 0}) + bom_ids = self.search(cr, uid, [], order='sequence desc', + context=context) + bom = self.browse(cr, uid, bom_ids[0], context=context) + maxseq = bom.sequence + 1 + default.update({'sequence': maxseq}) 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): + def button_active(self): return self.write({'state': 'active'}) @api.multi - def action_historical(self): + def button_historical(self): return self.write({'state': 'historical', 'historical_date': fields.Date.today()}) @@ -98,12 +95,9 @@ class MrpProduction(models.Model): ('product_tmpl_id', '=', product_tmpl_id) ] domain = domain + ['|', ('date_start', '=', False), - ('date_start', '<=', - time.strftime(DEFAULT_SERVER_DATETIME_FORMAT)), + ('date_start', '<=', fields.Datetime.now()), '|', ('date_stop', '=', False), - ('date_stop', '>=', - time.strftime( - DEFAULT_SERVER_DATETIME_FORMAT))] + ('date_stop', '>=', fields.Datetime.now())] bom_ids = bom_obj.search(cr, uid, domain, context=context) bom_id = 0 min_seq = 0 diff --git a/mrp_bom_version/views/mrp_bom_view.xml b/mrp_bom_version/views/mrp_bom_view.xml index f9483b65e..33764e3b0 100644 --- a/mrp_bom_version/views/mrp_bom_view.xml +++ b/mrp_bom_version/views/mrp_bom_view.xml @@ -8,7 +8,7 @@ - + @@ -21,68 +21,68 @@
-
- - + {'readonly':[('state', '=', 'historical')]} - + {'readonly':[('state', '=', 'historical')]} - - + + {'readonly':[('state', '=', 'historical')]} - - + + {'readonly':[('state', '=', 'historical')]} - + {'readonly':[('state', '!=', 'draft')]} - + {'readonly':[('state', '=', 'historical')]} - - + + {'readonly':[('state', '=', 'historical')]} - - + + {'readonly':[('state', '=', 'historical')]} - + {'readonly':[('state', '=', 'historical')]} {'readonly':[('state', '!=', 'draft')]} - + {'readonly':[('state', '=', 'historical')]} - - + + {'readonly':[('state', '=', 'historical')]} - - + + {'readonly':[('state', '=', 'historical')]} - - + + {'readonly':[('state', '=', 'historical')]} - - + + {'readonly':[('state', '=', 'historical')]} - - + + {'readonly':[('state', '=', 'historical')]} - - + + {'readonly':[('state', '=', 'historical')]} - + {'readonly':[('state', '=', 'historical')]} From 386929ccfad1f8da599029e092f05c988e074984 Mon Sep 17 00:00:00 2001 From: oihane Date: Thu, 13 Nov 2014 11:57:15 +0100 Subject: [PATCH 03/37] [FIX] Pylint fixing --- mrp_bom_version/models/mrp.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/mrp_bom_version/models/mrp.py b/mrp_bom_version/models/mrp.py index 9315bcd53..61d2caf86 100644 --- a/mrp_bom_version/models/mrp.py +++ b/mrp_bom_version/models/mrp.py @@ -52,16 +52,12 @@ class MrpBom(models.Model): raise exceptions.Warning( _('The sequence must be unique')) - def copy(self, cr, uid, id, default=None, context=None): - if default is None: - default = {} - bom_ids = self.search(cr, uid, [], order='sequence desc', - context=context) - bom = self.browse(cr, uid, bom_ids[0], context=context) + @api.one + def copy(self, default=None): + bom = self.search([], order='sequence desc', limit=1) maxseq = bom.sequence + 1 default.update({'sequence': maxseq}) - return super(MrpBom, self).copy(cr, uid, id, default=default, - context=context) + return super(MrpBom, self).copy(default=default) @api.multi def button_active(self): From bb12352728d663a087c40e4778f51e5b7471b84f Mon Sep 17 00:00:00 2001 From: oihane Date: Tue, 13 Jan 2015 11:39:45 +0100 Subject: [PATCH 04/37] [MOD] Issue #528 --- mrp_bom_version/README.rst | 18 ++++++++++++++++++ mrp_bom_version/__openerp__.py | 31 ++++++++----------------------- mrp_bom_version/models/mrp.py | 25 +++++++++++-------------- 3 files changed, 37 insertions(+), 37 deletions(-) create mode 100644 mrp_bom_version/README.rst diff --git a/mrp_bom_version/README.rst b/mrp_bom_version/README.rst new file mode 100644 index 000000000..f66a2b32c --- /dev/null +++ b/mrp_bom_version/README.rst @@ -0,0 +1,18 @@ +MRP - BoM version +================= + +This module performs the following: + +1.- In the MRP BoM list object, 2 new fields are added: + + 1.1.- Historical Date, of type date. + 1.2.- 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. + +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. +It also adds a constraint for the sequence field to be unique. diff --git a/mrp_bom_version/__openerp__.py b/mrp_bom_version/__openerp__.py index 5f24fba0d..a9b57c916 100644 --- a/mrp_bom_version/__openerp__.py +++ b/mrp_bom_version/__openerp__.py @@ -16,32 +16,17 @@ # ############################################################################## { - "name": "MRP BoM Version", + "name": "MRP - BoM Version", "version": "1.0", "author": "OdooMRP team", "category": "Manufacturing", "website": "http://www.odoomrp.com", - "description": """ - This module performs the following: - - 1.- In the MRP BoM list object, 2 new fields are added: - - 1.1.- Historical Date, of type date. - 1.2.- 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. - - 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. - Also creates a constraint for the sequence field to be unique. - """, - "depends": ['mrp', - ], - "data": ['data/mrp_bom_data.xml', - 'views/mrp_bom_view.xml', - ], + "depends": [ + "mrp", + ], + "data": [ + "data/mrp_bom_data.xml", + "views/mrp_bom_view.xml", + ], "installable": True } diff --git a/mrp_bom_version/models/mrp.py b/mrp_bom_version/models/mrp.py index 61d2caf86..644e33fe5 100644 --- a/mrp_bom_version/models/mrp.py +++ b/mrp_bom_version/models/mrp.py @@ -28,35 +28,32 @@ class MrpBom(models.Model): }, } + def _get_max_sequence(self): + bom = self.search([], order='sequence desc', limit=1) + maxseq = bom.sequence + 1 + return maxseq + 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) + sequence = fields.Integer(default=_get_max_sequence) @api.one @api.constrains('sequence') def check_mrp_bom_sequence(self): - domain = [('id', '!=', self.id), ('sequence', '=', self.sequence)] - 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: + domain = [('id', '!=', self.id), ('sequence', '=', self.sequence), + ('product_tmpl_id', '=', self.product_tmpl_id.id), + ('product_id', '=', self.product_id.id)] + if self.search(domain): raise exceptions.Warning( _('The sequence must be unique')) @api.one def copy(self, default=None): - bom = self.search([], order='sequence desc', limit=1) - maxseq = bom.sequence + 1 - default.update({'sequence': maxseq}) + default.update({'sequence': self._get_max_sequence()}) return super(MrpBom, self).copy(default=default) @api.multi From 4fdf662953ef012bd45dce4df29967a7bcacccd2 Mon Sep 17 00:00:00 2001 From: oihane Date: Tue, 13 Jan 2015 13:22:37 +0100 Subject: [PATCH 05/37] [MOD] Changed default not recalculated, if copy is not set to false --- mrp_bom_version/models/mrp.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/mrp_bom_version/models/mrp.py b/mrp_bom_version/models/mrp.py index 644e33fe5..af2fbe70a 100644 --- a/mrp_bom_version/models/mrp.py +++ b/mrp_bom_version/models/mrp.py @@ -39,7 +39,7 @@ class MrpBom(models.Model): ('historical', 'Historical'), ], string='Status', index=True, readonly=True, default='draft', copy=False) - sequence = fields.Integer(default=_get_max_sequence) + sequence = fields.Integer(default=_get_max_sequence, copy=False) @api.one @api.constrains('sequence') @@ -51,11 +51,6 @@ class MrpBom(models.Model): raise exceptions.Warning( _('The sequence must be unique')) - @api.one - def copy(self, default=None): - default.update({'sequence': self._get_max_sequence()}) - return super(MrpBom, self).copy(default=default) - @api.multi def button_active(self): return self.write({'state': 'active'}) From 80efea8d3d11f3eb829dea670f95bf85befb2e9b Mon Sep 17 00:00:00 2001 From: alfredo Date: Wed, 14 Jan 2015 10:29:32 +0100 Subject: [PATCH 06/37] [IMP mrp_bom_version] [DEL mrp_bom_version, NEW mrp_bom_state] --- mrp_bom_version/README.rst | 18 ---- mrp_bom_version/__init__.py | 18 ---- mrp_bom_version/__openerp__.py | 32 ------- mrp_bom_version/data/mrp_bom_data.xml | 11 --- mrp_bom_version/i18n/es.po | 96 ------------------- mrp_bom_version/i18n/mrp_bom_version.pot | 96 ------------------- mrp_bom_version/models/__init__.py | 18 ---- mrp_bom_version/models/mrp.py | 98 -------------------- mrp_bom_version/views/mrp_bom_view.xml | 113 ----------------------- 9 files changed, 500 deletions(-) delete mode 100644 mrp_bom_version/README.rst delete mode 100644 mrp_bom_version/__init__.py delete mode 100644 mrp_bom_version/__openerp__.py delete mode 100644 mrp_bom_version/data/mrp_bom_data.xml delete mode 100644 mrp_bom_version/i18n/es.po delete mode 100644 mrp_bom_version/i18n/mrp_bom_version.pot delete mode 100644 mrp_bom_version/models/__init__.py delete mode 100644 mrp_bom_version/models/mrp.py delete mode 100644 mrp_bom_version/views/mrp_bom_view.xml diff --git a/mrp_bom_version/README.rst b/mrp_bom_version/README.rst deleted file mode 100644 index f66a2b32c..000000000 --- a/mrp_bom_version/README.rst +++ /dev/null @@ -1,18 +0,0 @@ -MRP - BoM version -================= - -This module performs the following: - -1.- In the MRP BoM list object, 2 new fields are added: - - 1.1.- Historical Date, of type date. - 1.2.- 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. - -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. -It also adds a constraint for the sequence field to be unique. diff --git a/mrp_bom_version/__init__.py b/mrp_bom_version/__init__.py deleted file mode 100644 index c58ee95de..000000000 --- a/mrp_bom_version/__init__.py +++ /dev/null @@ -1,18 +0,0 @@ -# -*- 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 diff --git a/mrp_bom_version/__openerp__.py b/mrp_bom_version/__openerp__.py deleted file mode 100644 index a9b57c916..000000000 --- a/mrp_bom_version/__openerp__.py +++ /dev/null @@ -1,32 +0,0 @@ -# -*- 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": "Manufacturing", - "website": "http://www.odoomrp.com", - "depends": [ - "mrp", - ], - "data": [ - "data/mrp_bom_data.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 deleted file mode 100644 index 2fe6424ca..000000000 --- a/mrp_bom_version/data/mrp_bom_data.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - MRP BoM Active - mrp.bom - - MRP BoM Active - - - diff --git a/mrp_bom_version/i18n/es.po b/mrp_bom_version/i18n/es.po deleted file mode 100644 index 8f25cf7e8..000000000 --- a/mrp_bom_version/i18n/es.po +++ /dev/null @@ -1,96 +0,0 @@ -# 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-11-10 09:13+0000\n" -"PO-Revision-Date: 2014-11-10 10:14+0100\n" -"Last-Translator: Alfredo \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 -#: 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 "MRP BoM Active" - -#. 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 -#: 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:53 -#, python-format -msgid "The sequence must be unique" -msgstr "La secuencia 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')]}" - diff --git a/mrp_bom_version/i18n/mrp_bom_version.pot b/mrp_bom_version/i18n/mrp_bom_version.pot deleted file mode 100644 index a2aa517a0..000000000 --- a/mrp_bom_version/i18n/mrp_bom_version.pot +++ /dev/null @@ -1,96 +0,0 @@ -# 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-11-10 09:13+0000\n" -"PO-Revision-Date: 2014-11-10 09:13+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 -#: 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 -#: 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 -#: 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:53 -#, python-format -msgid "The sequence 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 "" - diff --git a/mrp_bom_version/models/__init__.py b/mrp_bom_version/models/__init__.py deleted file mode 100644 index 86314fbb3..000000000 --- a/mrp_bom_version/models/__init__.py +++ /dev/null @@ -1,18 +0,0 @@ -# -*- 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 diff --git a/mrp_bom_version/models/mrp.py b/mrp_bom_version/models/mrp.py deleted file mode 100644 index af2fbe70a..000000000 --- a/mrp_bom_version/models/mrp.py +++ /dev/null @@ -1,98 +0,0 @@ -# -*- 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, _ - - -class MrpBom(models.Model): - _inherit = 'mrp.bom' - - _track = { - 'state': { - 'mrp_bom_version.mt_active': lambda self, cr, uid, obj, - ctx=None: obj.state == 'active', - }, - } - - def _get_max_sequence(self): - bom = self.search([], order='sequence desc', limit=1) - maxseq = bom.sequence + 1 - return maxseq - - 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) - sequence = fields.Integer(default=_get_max_sequence, copy=False) - - @api.one - @api.constrains('sequence') - def check_mrp_bom_sequence(self): - domain = [('id', '!=', self.id), ('sequence', '=', self.sequence), - ('product_tmpl_id', '=', self.product_tmpl_id.id), - ('product_id', '=', self.product_id.id)] - if self.search(domain): - raise exceptions.Warning( - _('The sequence must be unique')) - - @api.multi - def button_active(self): - return self.write({'state': 'active'}) - - @api.multi - def button_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', '<=', 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/views/mrp_bom_view.xml b/mrp_bom_version/views/mrp_bom_view.xml deleted file mode 100644 index 33764e3b0..000000000 --- a/mrp_bom_version/views/mrp_bom_view.xml +++ /dev/null @@ -1,113 +0,0 @@ - - - - - mrp.bom.tree.view - mrp.bom - - - - - - - - - - - - mrp.bom.form.view.inh.version - mrp.bom - - - -
-
-
- - - - - - - {'readonly':[('state', '=', 'historical')]} - - - {'readonly':[('state', '=', 'historical')]} - - - {'readonly':[('state', '=', 'historical')]} - - - {'readonly':[('state', '=', 'historical')]} - - - {'readonly':[('state', '!=', 'draft')]} - - - {'readonly':[('state', '=', 'historical')]} - - - {'readonly':[('state', '=', 'historical')]} - - - {'readonly':[('state', '=', 'historical')]} - - - {'readonly':[('state', '=', 'historical')]} - - - {'readonly':[('state', '!=', 'draft')]} - - - {'readonly':[('state', '=', 'historical')]} - - - {'readonly':[('state', '=', 'historical')]} - - - {'readonly':[('state', '=', 'historical')]} - - - {'readonly':[('state', '=', 'historical')]} - - - {'readonly':[('state', '=', 'historical')]} - - - {'readonly':[('state', '=', 'historical')]} - - - {'readonly':[('state', '=', 'historical')]} - - - {'readonly':[('state', '=', 'historical')]} - - - {'readonly':[('state', '=', 'historical')]} - - - {'readonly':[('state', '=', 'historical')]} - -
-
- - view.mrp.bom.filter.inh.version - mrp.bom - - - - - - - - - - - - -
-
From aa3e0a4d92b0127668e753e307b7f7691fa5fe94 Mon Sep 17 00:00:00 2001 From: InakiZabala Date: Mon, 25 May 2015 10:57:20 +0200 Subject: [PATCH 07/37] [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 --- mrp_bom_version/README.rst | 26 ++++ mrp_bom_version/__init__.py | 5 + mrp_bom_version/__openerp__.py | 45 ++++++ mrp_bom_version/data/mrp_bom_data.xml | 11 ++ mrp_bom_version/i18n/es.po | 125 +++++++++++++++++ mrp_bom_version/i18n/mrp_bom_version.pot | 116 ++++++++++++++++ mrp_bom_version/models/__init__.py | 6 + mrp_bom_version/models/mrp.py | 130 ++++++++++++++++++ mrp_bom_version/models/res_config.py | 14 ++ .../security/mrp_bom_version_security.xml | 9 ++ mrp_bom_version/views/mrp_bom_view.xml | 86 ++++++++++++ mrp_bom_version/views/res_config_view.xml | 18 +++ 12 files changed, 591 insertions(+) create mode 100644 mrp_bom_version/README.rst create mode 100644 mrp_bom_version/__init__.py create mode 100644 mrp_bom_version/__openerp__.py create mode 100644 mrp_bom_version/data/mrp_bom_data.xml create mode 100644 mrp_bom_version/i18n/es.po create mode 100644 mrp_bom_version/i18n/mrp_bom_version.pot create mode 100644 mrp_bom_version/models/__init__.py create mode 100644 mrp_bom_version/models/mrp.py create mode 100644 mrp_bom_version/models/res_config.py create mode 100644 mrp_bom_version/security/mrp_bom_version_security.xml create mode 100644 mrp_bom_version/views/mrp_bom_view.xml create mode 100644 mrp_bom_version/views/res_config_view.xml 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 + + + +
+ +
+
+
+
+
+
From 7a580442ce4babce8d94e36f882008d5f48a3c93 Mon Sep 17 00:00:00 2001 From: oihane Date: Tue, 2 Jun 2015 17:26:01 +0200 Subject: [PATCH 08/37] [IMP] Renamed file --- mrp_bom_version/models/__init__.py | 3 ++- mrp_bom_version/models/{mrp.py => mrp_bom.py} | 0 2 files changed, 2 insertions(+), 1 deletion(-) rename mrp_bom_version/models/{mrp.py => mrp_bom.py} (100%) diff --git a/mrp_bom_version/models/__init__.py b/mrp_bom_version/models/__init__.py index 99464ac48..9f3a5c8da 100644 --- a/mrp_bom_version/models/__init__.py +++ b/mrp_bom_version/models/__init__.py @@ -2,5 +2,6 @@ ############################################################################## # For copyright and license notices, see __openerp__.py file in root directory ############################################################################## -from . import mrp + +from . import mrp_bom from . import res_config diff --git a/mrp_bom_version/models/mrp.py b/mrp_bom_version/models/mrp_bom.py similarity index 100% rename from mrp_bom_version/models/mrp.py rename to mrp_bom_version/models/mrp_bom.py From a2c4b4eb26426a718fd0b5189daa53b0bbf37dc0 Mon Sep 17 00:00:00 2001 From: oihane Date: Tue, 2 Jun 2015 18:21:02 +0200 Subject: [PATCH 09/37] [IMP] If BoM exist it is active so state must be 'active' --- mrp_bom_version/__init__.py | 11 +++++++++++ mrp_bom_version/__openerp__.py | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/mrp_bom_version/__init__.py b/mrp_bom_version/__init__.py index 2bbe2de99..b5a8708e0 100644 --- a/mrp_bom_version/__init__.py +++ b/mrp_bom_version/__init__.py @@ -2,4 +2,15 @@ ############################################################################## # For copyright and license notices, see __openerp__.py file in root directory ############################################################################## + from . import models +from openerp import SUPERUSER_ID + + +def set_bom_inactive(cr, registry): + """Set all draft or historical state BoMs inactive.""" + mrp_bom_obj = registry['mrp.bom'] + mrp_bom_ids = mrp_bom_obj.search(cr, SUPERUSER_ID, + [('active', '=', True)]) + for mrp_bom in mrp_bom_obj.browse(cr, SUPERUSER_ID, mrp_bom_ids): + mrp_bom_obj.write(cr, SUPERUSER_ID, mrp_bom.id, {'state': 'active'}) diff --git a/mrp_bom_version/__openerp__.py b/mrp_bom_version/__openerp__.py index cbbf0af8d..5491ead05 100644 --- a/mrp_bom_version/__openerp__.py +++ b/mrp_bom_version/__openerp__.py @@ -41,5 +41,6 @@ "views/res_config_view.xml", "views/mrp_bom_view.xml", ], - "installable": True + "installable": True, + "post_init_hook": "set_bom_inactive", } From ca239349596521a97c52a7e6522f3554cbcd5acf Mon Sep 17 00:00:00 2001 From: oihane Date: Wed, 3 Jun 2015 17:23:55 +0200 Subject: [PATCH 10/37] [IMP] Older versions shown in each BoM --- mrp_bom_version/models/mrp_bom.py | 65 ++++++++++++++++++-------- mrp_bom_version/views/mrp_bom_view.xml | 17 ++++++- 2 files changed, 60 insertions(+), 22 deletions(-) diff --git a/mrp_bom_version/models/mrp_bom.py b/mrp_bom_version/models/mrp_bom.py index 02727e625..0abd28fa2 100644 --- a/mrp_bom_version/models/mrp_bom.py +++ b/mrp_bom_version/models/mrp_bom.py @@ -15,15 +15,23 @@ class MrpBom(models.Model): }, } + @api.one + def _get_old_versions(self): + parent = self.parent_bom + old_version = self.env['mrp.bom'] + while parent: + old_version += parent + parent = parent.parent_bom + self.old_versions = old_version + 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) + state = fields.Selection( + selection=[('draft', 'Draft'), ('active', 'Active'), + ('historical', 'Historical')], string='State', + index=True, readonly=True, default='draft', copy=False) product_tmpl_id = fields.Many2one( readonly=True, states={'draft': [('readonly', False)]}) product_id = fields.Many2one( @@ -62,6 +70,11 @@ class MrpBom(models.Model): states={'historical': [('readonly', True)]}) version = fields.Integer(states={'historical': [('readonly', True)]}, copy=False, default=1) + parent_bom = fields.Many2one( + comodel_name='mrp.bom', string='Parent BoM') + old_versions = fields.Many2many( + comodel_name='mrp.bom', string='Old Versions', + compute='_get_old_versions') @api.multi def button_draft(self): @@ -70,27 +83,39 @@ class MrpBom(models.Model): @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', - } + new_bom = self.copy({ + 'version': self.version + 1, + 'active': True, + 'parent_bom': self.id, + }) + self.write({ + 'active': False, + 'state': 'historical', + 'historical_date': fields.Date.today(), + }) + 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'}) + self.write({ + 'active': True, + 'state': 'active' + }) @api.one def button_historical(self): - return self.write({'active': False, 'state': 'historical', - 'historical_date': fields.Date.today()}) + self.write({ + 'active': False, + 'state': 'historical', + 'historical_date': fields.Date.today() + }) class MrpProduction(models.Model): diff --git a/mrp_bom_version/views/mrp_bom_view.xml b/mrp_bom_version/views/mrp_bom_view.xml index fe7e6de29..650ea4e57 100644 --- a/mrp_bom_version/views/mrp_bom_view.xml +++ b/mrp_bom_version/views/mrp_bom_view.xml @@ -1,6 +1,10 @@ + + ['|',('active','=',True),('active','=',False)] + + mrp.bom.tree.parent.view mrp.bom @@ -63,6 +67,11 @@ + + + + + @@ -75,10 +84,14 @@ - + + + + + - + From 890cdafdb293cc201fb0ab048384da14549ad901 Mon Sep 17 00:00:00 2001 From: Daniel-CA Date: Wed, 24 Jun 2015 11:09:16 +0200 Subject: [PATCH 11/37] [FIX] mrp_bom_version invisble draft button: security rules to appropiate group --- mrp_bom_version/models/res_config.py | 2 +- mrp_bom_version/views/mrp_bom_view.xml | 2 +- mrp_bom_version/views/res_config_view.xml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mrp_bom_version/models/res_config.py b/mrp_bom_version/models/res_config.py index 5d75d8bb6..cef8ad797 100644 --- a/mrp_bom_version/models/res_config.py +++ b/mrp_bom_version/models/res_config.py @@ -8,7 +8,7 @@ from openerp import models, fields class MrpConfigSettings(models.TransientModel): _inherit = 'mrp.config.settings' - group_mrp_bom_state = fields.Boolean( + group_mrp_bom_version = 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/views/mrp_bom_view.xml b/mrp_bom_version/views/mrp_bom_view.xml index 650ea4e57..f66cd9170 100644 --- a/mrp_bom_version/views/mrp_bom_view.xml +++ b/mrp_bom_version/views/mrp_bom_view.xml @@ -40,7 +40,7 @@