mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
no msg
This commit is contained in:
committed by
lreficent
parent
e5d34062ba
commit
07eb03b22a
@@ -127,6 +127,11 @@ class QcProof(orm.Model):
|
||||
'active': lambda *a: True,
|
||||
}
|
||||
|
||||
_sql_constraints = [
|
||||
('proof_method_unique', 'UNIQUE (proof_id, method_id)',
|
||||
_('Proof-Method relation alredy exists!')),
|
||||
]
|
||||
|
||||
def name_search(self, cr, uid, name='', args=None, operator='ilike',
|
||||
context=None, limit=None):
|
||||
result = super(QcProof, self).name_search(cr, uid, name=name,
|
||||
@@ -327,12 +332,12 @@ class QcTestTemplateLine(orm.Model):
|
||||
'sequence': fields.integer('Sequence', required=True),
|
||||
'test_template_id': fields.many2one('qc.test.template',
|
||||
'Test Template', select="1"),
|
||||
'proof_id': fields.many2one('qc.proof', 'Proof', required=True,
|
||||
'proof_id': fields.many2one('qc.proof', 'Question', required=True,
|
||||
select="1"),
|
||||
'valid_value_ids': fields.many2many('qc.posible.value',
|
||||
'qc_template_value_rel',
|
||||
'template_line_id', 'value_id',
|
||||
'Values'),
|
||||
'Answers'),
|
||||
'method_id': fields.many2one('qc.proof.method', 'Method', select="1"),
|
||||
'notes': fields.text('Notes'),
|
||||
'min_value': fields.float('Min', digits=(16, 5)), # Quantitative only
|
||||
@@ -421,6 +426,7 @@ class QcTest(orm.Model):
|
||||
('waiting', 'Waiting Supervisor Approval'),
|
||||
('success', 'Quality Success'),
|
||||
('failed', 'Quality Failed'),
|
||||
('canceled', 'Canceled'),
|
||||
], 'State', readonly=True, select="1"),
|
||||
'success': fields.function(_success, method=True, type='boolean',
|
||||
string='Success',
|
||||
@@ -491,43 +497,49 @@ class QcTest(orm.Model):
|
||||
test_line_obj.unlink(cr, uid,
|
||||
[x.id for x in test.test_line_ids],
|
||||
context=context)
|
||||
test_lines = self._prepare_test_lines(
|
||||
cr, uid, test, force_fill=force_fill, context=context)
|
||||
test_obj.write(cr, uid, id, {'test_line_ids': test_lines}, context)
|
||||
|
||||
fill = False
|
||||
if test.test_template_id.fill_correct_values:
|
||||
fill = True
|
||||
for line in test.test_template_id.test_template_line_ids:
|
||||
data = {
|
||||
'test_id': id,
|
||||
'method_id': line.method_id.id,
|
||||
'proof_id': line.proof_id.id,
|
||||
'test_template_line_id': line.id,
|
||||
'notes': line.notes,
|
||||
'min_value': line.min_value,
|
||||
'max_value': line.max_value,
|
||||
'uom_id': line.uom_id.id,
|
||||
'test_uom_id': line.uom_id.id,
|
||||
'proof_type': line.type,
|
||||
def _prepare_test_lines(self, cr, uid, test, force_fill=False,
|
||||
context=None):
|
||||
new_data = []
|
||||
fill = False
|
||||
if test.test_template_id.fill_correct_values:
|
||||
fill = True
|
||||
for line in test.test_template_id.test_template_line_ids:
|
||||
data = self.self._prepare_test_line(
|
||||
cr, uid, test, line, fill=fill or force_fill, context=context)
|
||||
new_data.append((0, 0, data))
|
||||
return new_data
|
||||
|
||||
def _prepare_test_line(self, cr, uid, test, line, fill=None, context=None):
|
||||
data = {}
|
||||
data = {'test_id': test.id,
|
||||
'method_id': line.method_id.id,
|
||||
'proof_id': line.proof_id.id,
|
||||
'test_template_line_id': line.id,
|
||||
'notes': line.notes,
|
||||
'min_value': line.min_value,
|
||||
'max_value': line.max_value,
|
||||
'uom_id': line.uom_id.id,
|
||||
'test_uom_id': line.uom_id.id,
|
||||
'proof_type': line.type,
|
||||
}
|
||||
if fill or force_fill:
|
||||
if line.type == 'qualitative':
|
||||
# Fill with the first correct value finded.
|
||||
data['actual_value_ql'] = (
|
||||
len(line.valid_value_ids) and
|
||||
line.valid_value_ids[0] and
|
||||
line.valid_value_ids[0].id or False)
|
||||
|
||||
else:
|
||||
# Fill with value inside range.
|
||||
data['actual_value_qt'] = line.min_value
|
||||
data['test_uom_id'] = line.uom_id.id
|
||||
|
||||
test_line_id = test_line_obj.create(cr, uid, data,
|
||||
context=context)
|
||||
test_line_obj.write(
|
||||
cr, uid, [test_line_id],
|
||||
{'valid_value_ids':
|
||||
[(6, 0, [x.id for x in line.valid_value_ids])]},
|
||||
context=context)
|
||||
if fill:
|
||||
if line.type == 'qualitative':
|
||||
# Fill with the first correct value found.
|
||||
data['actual_value_ql'] = (
|
||||
len(line.valid_value_ids) and
|
||||
line.valid_value_ids[0] and
|
||||
line.valid_value_ids[0].id or False)
|
||||
else:
|
||||
# Fill with value inside range.
|
||||
data['actual_value_qt'] = line.min_value
|
||||
data['test_uom_id'] = line.uom_id.id
|
||||
data['valid_value_ids'] = [(6, 0, [x.id for x in
|
||||
line.valid_value_ids])]
|
||||
return data
|
||||
|
||||
|
||||
class QcTestLine(orm.Model):
|
||||
@@ -571,13 +583,13 @@ class QcTestLine(orm.Model):
|
||||
'test_template_line_id': fields.many2one('qc.test.template.line',
|
||||
'Test Template Line',
|
||||
readonly=True),
|
||||
'proof_id': fields.many2one('qc.proof', 'Proof', readonly=True),
|
||||
'proof_id': fields.many2one('qc.proof', 'Question', readonly=True),
|
||||
'method_id': fields.many2one('qc.proof.method', 'Method',
|
||||
readonly=True),
|
||||
'valid_value_ids': fields.many2many('qc.posible.value',
|
||||
'qc_test_value_rel',
|
||||
'test_line_id', 'value_id',
|
||||
'Values'),
|
||||
'Answers'),
|
||||
'actual_value_qt': fields.float('Qt.Value', digits=(16, 5),
|
||||
help="Value of the result if it is a"
|
||||
" quantitative proof."),
|
||||
|
||||
Reference in New Issue
Block a user