From 94b9ea423ab74c4e86878e1da84dec4d3602e49d Mon Sep 17 00:00:00 2001 From: alfredo Date: Tue, 28 Oct 2014 15:16:12 +0100 Subject: [PATCH] [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')]}