mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[IMP mrp_bom_version]
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user