[MOD] Issue #528

This commit is contained in:
oihane
2015-01-13 11:39:45 +01:00
parent 1912aa5fe4
commit bd759c83d1
3 changed files with 37 additions and 37 deletions

View File

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

View File

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

View File

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