规范视图和代码格式
This commit is contained in:
parent
b358a83e64
commit
a270d9f6e3
|
@ -45,7 +45,7 @@ class qc_proof_method(osv.osv):
|
|||
|
||||
_columns = {
|
||||
'name': fields.char('Name', size=100, required=True, select=True,
|
||||
translate=True),
|
||||
translate=True),
|
||||
'active': fields.boolean('Active', select=True),
|
||||
'company_id': fields.many2one('res.company', 'Company'),
|
||||
}
|
||||
|
@ -53,9 +53,12 @@ class qc_proof_method(osv.osv):
|
|||
_defaults = {
|
||||
'active': lambda *a: True,
|
||||
'company_id': lambda self, cr, uid, c:
|
||||
self.pool.get('res.company')._company_default_get(cr, uid,
|
||||
'qc.proof.method', context=c),
|
||||
self.pool.get('res.company')._company_default_get(cr, uid,
|
||||
'qc.proof.method',
|
||||
context=c),
|
||||
}
|
||||
|
||||
|
||||
qc_proof_method()
|
||||
|
||||
|
||||
|
@ -67,7 +70,7 @@ class qc_posible_value(osv.osv):
|
|||
|
||||
_columns = {
|
||||
'name': fields.char('Name', size=200, required=True, select=True,
|
||||
translate=True),
|
||||
translate=True),
|
||||
'active': fields.boolean('Active', select=True),
|
||||
'company_id': fields.many2one('res.company', 'Company'),
|
||||
}
|
||||
|
@ -75,12 +78,13 @@ class qc_posible_value(osv.osv):
|
|||
_defaults = {
|
||||
'active': lambda *a: True,
|
||||
'company_id': lambda self, cr, uid, c:
|
||||
self.pool.get('res.company')._company_default_get(cr, uid,
|
||||
'qc.posible.value', context=c),
|
||||
self.pool.get('res.company')._company_default_get(cr, uid,
|
||||
'qc.posible.value',
|
||||
context=c),
|
||||
}
|
||||
|
||||
def search(self, cr, uid, args, offset=0, limit=None, order=None,
|
||||
context=None, count=False):
|
||||
context=None, count=False):
|
||||
if context is None:
|
||||
context = {}
|
||||
if context.get('proof_id'):
|
||||
|
@ -90,12 +94,15 @@ class qc_posible_value(osv.osv):
|
|||
# ('proof_ids', 'in', [context['proof_id']]),
|
||||
# ], context=ctx)
|
||||
proof = self.pool.get('qc.proof').browse(cr, uid,
|
||||
context['proof_id'], ctx)
|
||||
context['proof_id'], ctx)
|
||||
result = [x.id for x in proof.value_ids]
|
||||
args = args[:]
|
||||
args.append(('id', 'in', result))
|
||||
return super(qc_posible_value, self).search(cr, uid, args, offset,
|
||||
limit, order, context, count)
|
||||
return super(qc_posible_value, self).search(cr, uid, args, offset,
|
||||
limit, order, context,
|
||||
count)
|
||||
|
||||
|
||||
qc_posible_value()
|
||||
|
||||
|
||||
|
@ -124,43 +131,42 @@ class qc_proof(osv.osv):
|
|||
|
||||
_columns = {
|
||||
'name': fields.char('Name', size=200, required=True, select=True,
|
||||
translate=True),
|
||||
translate=True),
|
||||
'ref': fields.char('Code', size=30, select=True),
|
||||
'active': fields.boolean('Active', select=True),
|
||||
'synonym_ids': fields.one2many('qc.proof.synonym', 'proof_id',
|
||||
'Synonyms'),
|
||||
'type': fields.selection([
|
||||
('qualitative', 'Qualitative'),
|
||||
('quantitative', 'Quantitative'),
|
||||
], 'Type', select=True, required=True),
|
||||
'Synonyms'),
|
||||
'type': fields.selection([('qualitative', 'Qualitative'),
|
||||
('quantitative', 'Quantitative'), ], 'Type',
|
||||
select=True, required=True),
|
||||
'value_ids': fields.many2many('qc.posible.value',
|
||||
'qc_proof_posible_value_rel', 'proof_id', 'posible_value_id',
|
||||
'Posible Values'),
|
||||
'qc_proof_posible_value_rel', 'proof_id',
|
||||
'posible_value_id',
|
||||
'Posible Values'),
|
||||
'synonyms': fields.function(_synonyms, method=True, type='char',
|
||||
size='1000', string='Synonyms', store=False),
|
||||
size='1000', string='Synonyms',
|
||||
store=False),
|
||||
'company_id': fields.many2one('res.company', 'Company'),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'active': lambda *a: True,
|
||||
'company_id': lambda self, cr, uid, c:
|
||||
self.pool.get('res.company')._company_default_get(cr, uid,
|
||||
'qc.proof', context=c),
|
||||
self.pool.get('res.company')._company_default_get(cr, uid, 'qc.proof',
|
||||
context=c),
|
||||
}
|
||||
|
||||
# qc.proof
|
||||
def name_search(self, cr, uid, name='', args=None, operator='ilike',
|
||||
context=None, limit=None):
|
||||
context=None, limit=None):
|
||||
result = super(qc_proof, self).name_search(cr, uid, name, args,
|
||||
operator, context, limit)
|
||||
operator, context, limit)
|
||||
if name:
|
||||
ids = [x[0] for x in result]
|
||||
new_ids = []
|
||||
syns = self.pool.get('qc.proof.synonym').name_search(cr, uid, name,
|
||||
args, operator, context, limit)
|
||||
syns = self.pool.get('qc.proof.synonym').name_search(cr, uid, name, args, operator, context, limit)
|
||||
syns = [x[0] for x in syns]
|
||||
for syn in self.pool.get('qc.proof.synonym').browse(cr, uid, syns,
|
||||
context):
|
||||
for syn in self.pool.get('qc.proof.synonym').browse(cr, uid, syns, context):
|
||||
if not syn.proof_id.id in ids:
|
||||
new_ids.append(syn.proof_id.id)
|
||||
result += self.name_get(cr, uid, new_ids, context)
|
||||
|
@ -175,6 +181,8 @@ class qc_proof(osv.osv):
|
|||
text += " [%s]" % proof.synonyms
|
||||
result.append((proof.id, text))
|
||||
return result
|
||||
|
||||
|
||||
qc_proof()
|
||||
|
||||
|
||||
|
@ -187,16 +195,19 @@ class qc_proof_synonym(osv.osv):
|
|||
|
||||
_columns = {
|
||||
'name': fields.char('Name', size=200, required=True, select=True,
|
||||
translate=True),
|
||||
translate=True),
|
||||
'proof_id': fields.many2one('qc.proof', 'Proof', required=True),
|
||||
'company_id': fields.many2one('res.company', 'Company'),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'company_id': lambda self, cr, uid, c:
|
||||
self.pool.get('res.company')._company_default_get(cr, uid,
|
||||
'qc.proof.synonym', context=c),
|
||||
}
|
||||
self.pool.get('res.company')._company_default_get(cr, uid,
|
||||
'qc.proof.synonym',
|
||||
context=c),
|
||||
}
|
||||
|
||||
|
||||
qc_proof_synonym()
|
||||
|
||||
|
||||
|
@ -229,6 +240,8 @@ class qc_test_link(osv.osv):
|
|||
_defaults = {
|
||||
'priority': 5,
|
||||
}
|
||||
|
||||
|
||||
qc_test_link()
|
||||
|
||||
|
||||
|
@ -243,9 +256,9 @@ class qc_test_template_category(osv.osv):
|
|||
if not len(ids):
|
||||
return []
|
||||
reads = self.read(cr, uid, ids, [
|
||||
'name',
|
||||
'parent_id',
|
||||
], context=context)
|
||||
'name',
|
||||
'parent_id',
|
||||
], context=context)
|
||||
res = []
|
||||
for record in reads:
|
||||
name = record['name']
|
||||
|
@ -274,29 +287,32 @@ class qc_test_template_category(osv.osv):
|
|||
|
||||
_columns = {
|
||||
'name': fields.char('Category Name', required=True, size=64,
|
||||
translate=True),
|
||||
translate=True),
|
||||
'parent_id': fields.many2one('qc.test.template.category',
|
||||
'Parent Category', select=True),
|
||||
'Parent Category', select=True),
|
||||
'complete_name': fields.function(_complete_name, method=True,
|
||||
type='char', string='Full Name'),
|
||||
type='char', string='Full Name'),
|
||||
'child_ids': fields.one2many('qc.test.template.category', 'parent_id',
|
||||
'Child Categories'),
|
||||
'Child Categories'),
|
||||
'active': fields.boolean('Active', help="The active field allows you "
|
||||
"to hide the category without removing it."),
|
||||
"to hide the category without removing it."),
|
||||
'company_id': fields.many2one('res.company', 'Company'),
|
||||
}
|
||||
|
||||
_constraints = [
|
||||
(_check_recursion, 'Error ! You can not create recursive categories.',
|
||||
['parent_id'])
|
||||
['parent_id'])
|
||||
]
|
||||
|
||||
_defaults = {
|
||||
'active': lambda *a: True,
|
||||
'company_id': lambda self, cr, uid, c:
|
||||
self.pool.get('res.company')._company_default_get(cr, uid,
|
||||
'qc.test.template.category', context=c),
|
||||
self.pool.get('res.company')._company_default_get(cr, uid,
|
||||
'qc.test.template.category',
|
||||
context=c),
|
||||
}
|
||||
|
||||
|
||||
qc_test_template_category()
|
||||
|
||||
|
||||
|
@ -315,7 +331,9 @@ class qc_test_template(osv.osv):
|
|||
ref_id = context.get('active_id')
|
||||
if ref_id:
|
||||
source = self.pool.get(context['reference_model']).browse(cr,
|
||||
uid, ref_id, context)
|
||||
uid,
|
||||
ref_id,
|
||||
context)
|
||||
if hasattr(source, 'name'):
|
||||
return source.name
|
||||
|
||||
|
@ -323,7 +341,7 @@ class qc_test_template(osv.osv):
|
|||
def _default_object_id(self, cr, uid, context=None):
|
||||
if context and context.get('reference_model', False):
|
||||
return '%s,%d' % (context['reference_model'],
|
||||
context['reference_id'])
|
||||
context['reference_id'])
|
||||
else:
|
||||
return False
|
||||
|
||||
|
@ -337,18 +355,18 @@ class qc_test_template(osv.osv):
|
|||
_columns = {
|
||||
'active': fields.boolean('Active', select=True),
|
||||
'name': fields.char('Name', size=200, required=True, translate=True,
|
||||
select=True),
|
||||
select=True),
|
||||
'test_template_line_ids': fields.one2many('qc.test.template.line',
|
||||
'test_template_id', 'Lines'),
|
||||
'test_template_id', 'Lines'),
|
||||
'object_id': fields.reference('Reference Object', selection=_links_get,
|
||||
size=128),
|
||||
size=128),
|
||||
'fill_correct_values': fields.boolean('Fill With Correct Values'),
|
||||
'type': fields.selection([
|
||||
('generic', 'Generic'),
|
||||
('related', 'Related'),
|
||||
], 'Type', select=True),
|
||||
('generic', 'Generic'),
|
||||
('related', 'Related'),
|
||||
], 'Type', select=True),
|
||||
'category_id': fields.many2one('qc.test.template.category',
|
||||
'Category'),
|
||||
'Category'),
|
||||
'formula': fields.text('Formula'),
|
||||
'company_id': fields.many2one('res.company', 'Company'),
|
||||
'uom_id': fields.many2one('product.uom', 'UoM'),
|
||||
|
@ -360,9 +378,12 @@ class qc_test_template(osv.osv):
|
|||
'object_id': _default_object_id,
|
||||
'type': _default_type,
|
||||
'company_id': lambda self, cr, uid, c:
|
||||
self.pool.get('res.company')._company_default_get(cr, uid,
|
||||
'qc.test.template', context=c),
|
||||
self.pool.get('res.company')._company_default_get(cr, uid,
|
||||
'qc.test.template',
|
||||
context=c),
|
||||
}
|
||||
|
||||
|
||||
qc_test_template()
|
||||
|
||||
|
||||
|
@ -384,34 +405,40 @@ class qc_test_template_line(osv.osv):
|
|||
'name': fields.char('Name', size=64),
|
||||
'sequence': fields.integer('Sequence', required=True),
|
||||
'test_template_id': fields.many2one('qc.test.template',
|
||||
'Test Template', select=True),
|
||||
'Test Template', select=True),
|
||||
'proof_id': fields.many2one('qc.proof', 'Proof', required=True,
|
||||
select=True),
|
||||
select=True),
|
||||
'valid_value_ids': fields.many2many('qc.posible.value',
|
||||
'qc_template_value_rel', 'template_line_id', 'value_id',
|
||||
'Values'),
|
||||
'qc_template_value_rel',
|
||||
'template_line_id', 'value_id',
|
||||
'Values'),
|
||||
'method_id': fields.many2one('qc.proof.method', 'Method', select=True),
|
||||
'notes': fields.text('Notes'),
|
||||
# Only if quantitative
|
||||
'min_value': fields.float('Min',
|
||||
digits_compute=dp.get_precision('Quality Control')),
|
||||
digits_compute=dp.get_precision(
|
||||
'Quality Control')),
|
||||
# Only if quantitative
|
||||
'max_value': fields.float('Max',
|
||||
digits_compute=dp.get_precision('Quality Control')),
|
||||
digits_compute=dp.get_precision(
|
||||
'Quality Control')),
|
||||
# Only if quantitative
|
||||
'uom_id': fields.many2one('product.uom', 'UoM'),
|
||||
'type': fields.selection([
|
||||
('qualitative', 'Qualitative'),
|
||||
('quantitative', 'Quantitative'),
|
||||
], 'Type', select=True),
|
||||
('qualitative', 'Qualitative'),
|
||||
('quantitative', 'Quantitative'),
|
||||
], 'Type', select=True),
|
||||
'company_id': fields.related('test_template_id', 'company_id',
|
||||
type='many2one', relation='res.company', string='Company',
|
||||
store=True, readonly=True),
|
||||
type='many2one', relation='res.company',
|
||||
string='Company',
|
||||
store=True, readonly=True),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'sequence': lambda *b: 1,
|
||||
}
|
||||
|
||||
|
||||
qc_test_template_line()
|
||||
|
||||
|
||||
|
@ -431,7 +458,7 @@ class qc_test(osv.osv):
|
|||
# Check the partner (test method). Check that at least the test
|
||||
# is a test method with some success.
|
||||
proof[line.proof_id.id] = (proof.get(line.proof_id.id, False)
|
||||
or line.success)
|
||||
or line.success)
|
||||
|
||||
for p in proof:
|
||||
if not proof[p]:
|
||||
|
@ -445,8 +472,8 @@ class qc_test(osv.osv):
|
|||
def _default_object_id(self, cr, uid, context=None):
|
||||
if context and context.get('reference_model', False):
|
||||
return '%s,%d' % (
|
||||
context['reference_model'],
|
||||
context['reference_id'])
|
||||
context['reference_model'],
|
||||
context['reference_id'])
|
||||
else:
|
||||
return False
|
||||
|
||||
|
@ -459,7 +486,7 @@ class qc_test(osv.osv):
|
|||
if line.name and line.proof_type == 'quantitative':
|
||||
vals[line.name] = line.actual_value_qt
|
||||
|
||||
if not test.formula:
|
||||
if not test.formula:
|
||||
result[test.id] = 0
|
||||
continue
|
||||
|
||||
|
@ -474,62 +501,62 @@ class qc_test(osv.osv):
|
|||
_columns = {
|
||||
'name': fields.char('Number', size=64, required=True, select=True),
|
||||
'date': fields.datetime('Date', required=True, readonly=True,
|
||||
select=True, states={
|
||||
'draft': [('readonly', False)],
|
||||
}),
|
||||
select=True, states={
|
||||
'draft': [('readonly', False)],
|
||||
}),
|
||||
'object_id': fields.reference('Reference', selection=_links_get,
|
||||
size=128, readonly=True, select=True, states={
|
||||
'draft': [('readonly', False)],
|
||||
}),
|
||||
size=128, readonly=True, select=True,
|
||||
states={
|
||||
'draft': [('readonly', False)],
|
||||
}),
|
||||
'test_template_id': fields.many2one('qc.test.template', 'Test template',
|
||||
select=True, states={
|
||||
'success': [('readonly', True)],
|
||||
'failed': [('readonly', True)],
|
||||
}),
|
||||
select=True, states={
|
||||
'success': [('readonly', True)],
|
||||
'failed': [('readonly', True)],
|
||||
}),
|
||||
'test_line_ids': fields.one2many('qc.test.line', 'test_id',
|
||||
'Test Lines', states={
|
||||
'success': [('readonly', True)],
|
||||
'failed': [('readonly', True)],
|
||||
}),
|
||||
'Test Lines', states={
|
||||
'success': [('readonly', True)],
|
||||
'failed': [('readonly', True)],
|
||||
}),
|
||||
'test_internal_note': fields.text('Internal Note', states={
|
||||
'success': [('readonly', True)],
|
||||
'failed': [('readonly', True)],
|
||||
}),
|
||||
'success': [('readonly', True)],
|
||||
'failed': [('readonly', True)],
|
||||
}),
|
||||
'test_external_note': fields.text('External Note', states={
|
||||
'success': [('readonly', True)],
|
||||
'failed': [('readonly', True)],
|
||||
}),
|
||||
'state': fields.selection([
|
||||
('draft', 'Draft'),
|
||||
('waiting', 'Waiting Supervisor Approval'),
|
||||
('success', 'Quality Success'),
|
||||
('failed', 'Quality Failed'),
|
||||
], 'State', readonly=True, select=True),
|
||||
'success': [('readonly', True)],
|
||||
'failed': [('readonly', True)],
|
||||
}),
|
||||
'state': fields.selection(
|
||||
[('draft', 'Draft'), ('waiting', 'Waiting Approval'),
|
||||
('success', 'Quality Success'), ('failed', 'Quality Failed'), ],
|
||||
'Status', readonly=True, select=True),
|
||||
'success': fields.function(_success, method=True, type='boolean',
|
||||
string='Success', select=True, store=True,
|
||||
help='This field will be active if all tests have succeeded.'),
|
||||
string='Success', select=True, store=True,
|
||||
help='This field will be active if all tests have succeeded.'),
|
||||
'formula': fields.text('Formula', readonly=1),
|
||||
'formula_result': fields.function(_action_calc_formula, method=True,
|
||||
string='Formula Value', type='float',
|
||||
digits_compute=dp.get_precision('Quality Control')),
|
||||
string='Formula Value', type='float',
|
||||
digits_compute=dp.get_precision(
|
||||
'Quality Control')),
|
||||
'uom_id': fields.many2one('product.uom', 'UoM'),
|
||||
'company_id': fields.many2one('res.company', 'Company'),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'name': lambda obj, cr, uid, context: \
|
||||
obj.pool.get('ir.sequence').get(cr, uid, 'qc.test'),
|
||||
obj.pool.get('ir.sequence').get(cr, uid, 'qc.test'),
|
||||
'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'state': 'draft',
|
||||
'success': False,
|
||||
'object_id': _default_object_id,
|
||||
'company_id': lambda s, cr, uid, c: s.pool.get('res.company')\
|
||||
._company_default_get(cr, uid, 'qc.test', context=c),
|
||||
'company_id': lambda s, cr, uid, c: s.pool.get('res.company') \
|
||||
._company_default_get(cr, uid, 'qc.test', context=c),
|
||||
}
|
||||
|
||||
# qc.test
|
||||
def _calc_line_vals_from_template(self, cr, uid, test_id, template_line,
|
||||
fill_correct_values, context):
|
||||
fill_correct_values, context):
|
||||
data = {
|
||||
'name': template_line.name,
|
||||
'test_id': test_id,
|
||||
|
@ -547,9 +574,10 @@ class qc_test(osv.osv):
|
|||
if template_line.type == 'qualitative':
|
||||
# Fill with the first correct value found.
|
||||
data['actual_value_ql'] = (len(template_line.valid_value_ids)
|
||||
and template_line.valid_value_ids[0]
|
||||
and template_line.valid_value_ids[0].id
|
||||
or False)
|
||||
and template_line.valid_value_ids[0]
|
||||
and template_line.valid_value_ids[
|
||||
0].id
|
||||
or False)
|
||||
else:
|
||||
# Fill with value in the range.
|
||||
data['actual_value_qt'] = template_line.min_value
|
||||
|
@ -558,43 +586,47 @@ class qc_test(osv.osv):
|
|||
|
||||
# qc.test
|
||||
def set_test_template(self, cr, uid, ids, template_id, force_fill=False,
|
||||
context=None):
|
||||
context=None):
|
||||
test_line_proxy = self.pool.get('qc.test.line')
|
||||
|
||||
if context is None:
|
||||
context = {}
|
||||
template = self.pool.get('qc.test.template').browse(cr, uid,
|
||||
template_id, context=context)
|
||||
template_id,
|
||||
context=context)
|
||||
for test_id in ids:
|
||||
self.write(cr, uid, test_id, {
|
||||
'test_template_id': template_id,
|
||||
'formula': template.formula,
|
||||
'uom_id': template.uom_id and template.uom_id.id
|
||||
}, context)
|
||||
'test_template_id': template_id,
|
||||
'formula': template.formula,
|
||||
'uom_id': template.uom_id and template.uom_id.id
|
||||
}, context)
|
||||
|
||||
test = self.browse(cr, uid, test_id, context)
|
||||
|
||||
if len(test.test_line_ids) > 0:
|
||||
test_line_proxy.unlink(cr, uid,
|
||||
[x.id for x in test.test_line_ids], context)
|
||||
[x.id for x in test.test_line_ids],
|
||||
context)
|
||||
|
||||
fill = test.test_template_id.fill_correct_values or False
|
||||
for line in test.test_template_id.test_template_line_ids:
|
||||
data = self._calc_line_vals_from_template(cr, uid, test_id,
|
||||
line, fill or force_fill, context)
|
||||
line,
|
||||
fill or force_fill,
|
||||
context)
|
||||
|
||||
test_line_id = test_line_proxy.create(cr, uid,
|
||||
data, context)
|
||||
data, context)
|
||||
test_line_proxy.write(cr, uid, [test_line_id], {
|
||||
'valid_value_ids': [
|
||||
(6, 0, [x.id for x in line.valid_value_ids]),
|
||||
],
|
||||
}, context)
|
||||
# It writes again the test to force to recalculate 'success' field
|
||||
'valid_value_ids': [
|
||||
(6, 0, [x.id for x in line.valid_value_ids]),
|
||||
],
|
||||
}, context)
|
||||
# It writes again the test to force to recalculate 'success' field
|
||||
self.write(cr, uid, test_id, {
|
||||
'formula': template.formula,
|
||||
'uom_id': template.uom_id and template.uom_id.id
|
||||
}, context)
|
||||
'formula': template.formula,
|
||||
'uom_id': template.uom_id and template.uom_id.id
|
||||
}, context)
|
||||
return True
|
||||
|
||||
# qc.test
|
||||
|
@ -615,29 +647,29 @@ class qc_test(osv.osv):
|
|||
# qc.test
|
||||
def action_workflow_draft(self, cr, uid, ids, context=None):
|
||||
self.write(cr, uid, ids, {
|
||||
'state': 'draft'
|
||||
}, context)
|
||||
'state': 'draft'
|
||||
}, context)
|
||||
return True
|
||||
|
||||
# qc.test
|
||||
def action_workflow_waiting(self, cr, uid, ids, context=None):
|
||||
self.write(cr, uid, ids, {
|
||||
'state': 'waiting'
|
||||
}, context)
|
||||
'state': 'waiting'
|
||||
}, context)
|
||||
return True
|
||||
|
||||
# qc.test
|
||||
def action_workflow_success(self, cr, uid, ids, context=None):
|
||||
self.write(cr, uid, ids, {
|
||||
'state': 'success'
|
||||
}, context)
|
||||
'state': 'success'
|
||||
}, context)
|
||||
return True
|
||||
|
||||
# qc.test
|
||||
def action_workflow_failed(self, cr, uid, ids, context=None):
|
||||
self.write(cr, uid, ids, {
|
||||
'state': 'failed'
|
||||
}, context)
|
||||
'state': 'failed'
|
||||
}, context)
|
||||
return True
|
||||
|
||||
# qc.test
|
||||
|
@ -650,12 +682,12 @@ class qc_test(osv.osv):
|
|||
if context is None:
|
||||
context = {}
|
||||
|
||||
if default is None:
|
||||
if default is None:
|
||||
default = {}
|
||||
|
||||
if not 'name' in default:
|
||||
default['name'] = self.pool.get('ir.sequence').get(cr, uid,
|
||||
'qc.test')
|
||||
'qc.test')
|
||||
if not 'date' in default:
|
||||
default['date'] = time.strftime('%Y-%m-%d %H:%M:%S')
|
||||
|
||||
|
@ -665,8 +697,10 @@ class qc_test(osv.osv):
|
|||
def create(self, cr, uid, datas, context=None):
|
||||
if context and context.get('reference_model'):
|
||||
datas['object_id'] = context['reference_model'] + "," + \
|
||||
str(context['reference_id'])
|
||||
str(context['reference_id'])
|
||||
return super(qc_test, self).create(cr, uid, datas, context=context)
|
||||
|
||||
|
||||
qc_test()
|
||||
|
||||
|
||||
|
@ -676,16 +710,18 @@ class qc_test_line(osv.osv):
|
|||
|
||||
# qc.test.line
|
||||
def quality_test_check(self, cr, uid, ids, field_name, field_value,
|
||||
context):
|
||||
context):
|
||||
res = {}
|
||||
lines = self.browse(cr, uid, ids, context)
|
||||
for line in lines:
|
||||
if line.proof_type == 'qualitative':
|
||||
res[line.id] = self.quality_test_qualitative_check(cr, uid,
|
||||
line, context)
|
||||
line,
|
||||
context)
|
||||
else:
|
||||
res[line.id] = self.quality_test_quantitative_check(cr, uid,
|
||||
line, context)
|
||||
line,
|
||||
context)
|
||||
return res
|
||||
|
||||
# qc.test.line
|
||||
|
@ -698,8 +734,9 @@ class qc_test_line(osv.osv):
|
|||
# qc.test.line
|
||||
def quality_test_quantitative_check(self, cr, uid, test_line, context):
|
||||
amount = self.pool.get('product.uom')._compute_qty(cr, uid,
|
||||
test_line.uom_id.id, test_line.actual_value_qt,
|
||||
test_line.test_uom_id.id)
|
||||
test_line.uom_id.id,
|
||||
test_line.actual_value_qt,
|
||||
test_line.test_uom_id.id)
|
||||
|
||||
try:
|
||||
damount = Decimal(str(amount))
|
||||
|
@ -717,39 +754,46 @@ class qc_test_line(osv.osv):
|
|||
'name': fields.char('Name', size=64),
|
||||
'test_id': fields.many2one('qc.test', 'Test'),
|
||||
'test_template_line_id': fields.many2one('qc.test.template.line',
|
||||
'Test Template Line', readonly=True),
|
||||
'Test Template Line',
|
||||
readonly=True),
|
||||
'proof_id': fields.many2one('qc.proof', 'Proof', readonly=True),
|
||||
'method_id': fields.many2one('qc.proof.method', 'Method',
|
||||
readonly=True),
|
||||
readonly=True),
|
||||
'valid_value_ids': fields.many2many('qc.posible.value',
|
||||
'qc_test_value_rel', 'test_line_id', 'value_id', 'Values'),
|
||||
'qc_test_value_rel', 'test_line_id',
|
||||
'value_id', 'Values'),
|
||||
'actual_value_qt': fields.float('Qt.Value',
|
||||
digits_compute=dp.get_precision('Quality Control'),
|
||||
help="Value of the result if it is a quantitative proof."),
|
||||
digits_compute=dp.get_precision(
|
||||
'Quality Control'),
|
||||
help="Value of the result if it is a quantitative proof."),
|
||||
'actual_value_ql': fields.many2one('qc.posible.value', 'Ql.Value',
|
||||
help="Value of the result if it is a qualitative proof."),
|
||||
help="Value of the result if it is a qualitative proof."),
|
||||
'notes': fields.text('Notes', readonly=True),
|
||||
'min_value': fields.float('Min', readonly=True,
|
||||
digits_compute=dp.get_precision('Quality Control'),
|
||||
help="Minimum valid value if it is a quantitative proof."),
|
||||
digits_compute=dp.get_precision(
|
||||
'Quality Control'),
|
||||
help="Minimum valid value if it is a quantitative proof."),
|
||||
'max_value': fields.float('Max', readonly=True,
|
||||
digits_compute=dp.get_precision('Quality Control'),
|
||||
help="Maximum valid value if it is a quantitative proof."),
|
||||
digits_compute=dp.get_precision(
|
||||
'Quality Control'),
|
||||
help="Maximum valid value if it is a quantitative proof."),
|
||||
'uom_id': fields.many2one('product.uom', 'UoM', readonly=True,
|
||||
help="UoM for minimum and maximum values if it is a "
|
||||
"quantitative proof."),
|
||||
'test_uom_id': fields.many2one('product.uom', 'Uom Test', help="UoM "
|
||||
"of the value of the result if it is a quantitative proof."),
|
||||
help="UoM for minimum and maximum values if it is a quantitative proof."),
|
||||
'test_uom_id': fields.many2one('product.uom', 'Uom Test',
|
||||
help="UoM of the value of the result if it is a quantitative proof."),
|
||||
'proof_type': fields.selection([
|
||||
('qualitative', 'Qualitative'),
|
||||
('quantitative', 'Quantitative'),
|
||||
], 'Proof Type', readonly=True),
|
||||
('qualitative', 'Qualitative'),
|
||||
('quantitative', 'Quantitative'),
|
||||
], 'Proof Type', readonly=True),
|
||||
'success': fields.function(quality_test_check, type='boolean',
|
||||
method=True, string="Success?", select=True),
|
||||
method=True, string="Success?", select=True),
|
||||
'company_id': fields.related('test_id', 'company_id', type='many2one',
|
||||
relation='res.company', string='Company', store=True,
|
||||
readonly=True),
|
||||
relation='res.company', string='Company',
|
||||
store=True,
|
||||
readonly=True),
|
||||
}
|
||||
|
||||
|
||||
qc_test_line()
|
||||
|
||||
|
||||
|
@ -765,8 +809,8 @@ class qc_test_wizard(osv.osv_memory):
|
|||
test_id = context.get('active_id')
|
||||
test = self.pool.get('qc.test').browse(cr, uid, test_id, context)
|
||||
ids = self.pool.get('qc.test.template').search(cr, uid, [
|
||||
('object_id', '=', test.object_id),
|
||||
], context=context)
|
||||
('object_id', '=', test.object_id),
|
||||
], context=context)
|
||||
return ids and ids[0] or False
|
||||
|
||||
_columns = {
|
||||
|
@ -781,8 +825,9 @@ class qc_test_wizard(osv.osv_memory):
|
|||
def action_create_test(self, cr, uid, ids, context):
|
||||
wizard = self.browse(cr, uid, ids[0], context)
|
||||
self.pool.get('qc.test').set_test_template(cr, uid,
|
||||
[context['active_id']], wizard.test_template_id.id,
|
||||
context=context)
|
||||
[context['active_id']],
|
||||
wizard.test_template_id.id,
|
||||
context=context)
|
||||
return {
|
||||
'type': 'ir.actions.act_window_close',
|
||||
}
|
||||
|
@ -792,6 +837,8 @@ class qc_test_wizard(osv.osv_memory):
|
|||
return {
|
||||
'type': 'ir.actions.act_window_close',
|
||||
}
|
||||
|
||||
|
||||
qc_test_wizard()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
</record>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_qc_proof_method">
|
||||
<field name="name">Methods</field>
|
||||
<field name="name">Proof Methods</field>
|
||||
<field name="res_model">qc.proof.method</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
|
@ -69,7 +69,7 @@
|
|||
</record>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_qc_posible_value">
|
||||
<field name="name">Posible Values</field>
|
||||
<field name="name">Proof Posible Values</field>
|
||||
<field name="res_model">qc.posible.value</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
|
@ -105,7 +105,7 @@
|
|||
</record>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_proof_synonym">
|
||||
<field name="name">Synonym</field>
|
||||
<field name="name">Proof Synonym</field>
|
||||
<field name="res_model">qc.proof.synonym</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
|
@ -128,9 +128,15 @@
|
|||
</group>
|
||||
<newline/>
|
||||
<group>
|
||||
<field name="value_ids" nolabel="0" colspan="1"
|
||||
attrs="{'required':[('type','=','qualitative')],'readonly':[('type','!=','qualitative')] }"/>
|
||||
<field name="synonym_ids" nolabel="0" colspan="1"/>
|
||||
<group>
|
||||
<separator string="Synonyms" colspan="4"/>
|
||||
<field name="synonym_ids" nolabel="1"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
<separator string="Values" colspan="4"/>
|
||||
<field name="value_ids" nolabel="1"
|
||||
attrs="{'required':[('type','=','qualitative')],'readonly':[('type','!=','qualitative')]}"/>
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
|
@ -165,13 +171,11 @@
|
|||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Test Reference Type" version="7.0">
|
||||
<sheet>
|
||||
<group col="4" colspan="2">
|
||||
<field name="name"/>
|
||||
<field name="object"/>
|
||||
<field name="priority"/>
|
||||
</group>
|
||||
</sheet>
|
||||
<group col="4" colspan="2">
|
||||
<field name="name"/>
|
||||
<field name="object"/>
|
||||
<field name="priority"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
@ -274,23 +278,27 @@
|
|||
<group col="4" colspan="2">
|
||||
<field name="name"/>
|
||||
<field name="company_id"/>
|
||||
<field name="proof_id" on_change="onchange_proof_id(proof_id,context)"/>
|
||||
<field name="proof_id"
|
||||
on_change="onchange_proof_id(proof_id,context)"/>
|
||||
<field name="method_id"/>
|
||||
<field name="type"/>
|
||||
<field name="sequence"/>
|
||||
</group>
|
||||
<notebook>
|
||||
<page string="Values">
|
||||
<group attrs="{'invisible':[('type','!=','qualitative')]}" colspan="1">
|
||||
<separator string="Values"/>
|
||||
<group attrs="{'invisible':[('type','!=','qualitative')]}">
|
||||
<separator string="Values" colspan="4"/>
|
||||
<field name="valid_value_ids"
|
||||
attrs="{'invisible':[('type','!=','qualitative')],'required':[('type','=','qualitative')]}"
|
||||
context="{'proof_id':proof_id}" nolabel="1" colspan="1"/>
|
||||
</group>
|
||||
<group attrs="{'invisible':[('type','=','qualitative')]}" colspan="2">
|
||||
<field name="min_value" attrs="{'required':[('type','!=','qualitative')]}"/>
|
||||
<field name="max_value" attrs="{'required':[('type','!=','qualitative')]}"/>
|
||||
<field name="uom_id" attrs="{'required':[('type','!=','qualitative')]}"/>
|
||||
<group attrs="{'invisible':[('type','=','qualitative')]}">
|
||||
<field name="min_value"
|
||||
attrs="{'required':[('type','!=','qualitative')]}"/>
|
||||
<field name="max_value"
|
||||
attrs="{'required':[('type','!=','qualitative')]}"/>
|
||||
<field name="uom_id"
|
||||
attrs="{'required':[('type','!=','qualitative')]}"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Notes">
|
||||
|
@ -341,15 +349,18 @@
|
|||
<field name="test_template_id"/>
|
||||
</group>
|
||||
<footer>
|
||||
<button icon="gtk-cancel" special="cancel" string="Cancel" name="action_cancel"
|
||||
<button icon="gtk-cancel" special="cancel" string="Cancel"
|
||||
name="action_cancel"
|
||||
type="object"/>
|
||||
<button icon="gtk-ok" name="action_create_test" string="Accept"
|
||||
type="object"/>
|
||||
<button icon="gtk-ok" name="action_create_test" string="Accept" type="object"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_qc_test_set_template_wizard_form" model="ir.actions.act_window">
|
||||
<record id="action_qc_test_set_template_wizard_form"
|
||||
model="ir.actions.act_window">
|
||||
<field name="name">qc.test.set.template.wizard</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">qc.test.set.template.wizard</field>
|
||||
|
@ -366,12 +377,17 @@
|
|||
<field name="arch" type="xml">
|
||||
<form string="QC Test" version="7.0">
|
||||
<header>
|
||||
<button name="confirm" states="draft" string="Confirm" icon="gtk-ok"/>
|
||||
<button name="confirm" states="draft" string="Confirm"
|
||||
icon="gtk-ok"/>
|
||||
<button name="approve" states="waiting" string="Approve"
|
||||
groups="nan_quality_control.group_quality_control_supervisor" icon="gtk-ok"/>
|
||||
<button name="cancel" states="waiting,failed,success" string="Cancel"
|
||||
groups="nan_quality_control.group_quality_control_supervisor"
|
||||
icon="gtk-ok"/>
|
||||
<button name="cancel" states="waiting,failed,success"
|
||||
string="Cancel"
|
||||
icon="gtk-cancel"/>
|
||||
<field name="state" widget="statusbar"/>
|
||||
<field name="state" widget="statusbar"
|
||||
statusbar_visable="draft,waiting,success,failed"
|
||||
statusbar_colors='{"failed":"red","waiting":"blue"}'/>
|
||||
</header>
|
||||
<sheet>
|
||||
<group>
|
||||
|
@ -388,8 +404,10 @@
|
|||
<field name="uom_id"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="test_template_id" readonly="True" select="2" colspan="2"/>
|
||||
<button string="Select template" name="%(action_qc_test_set_template_wizard_form)d"
|
||||
<field name="test_template_id" readonly="True" select="2"
|
||||
colspan="2"/>
|
||||
<button string="Select template"
|
||||
name="%(action_qc_test_set_template_wizard_form)d"
|
||||
type="action" states="draft"/>
|
||||
</group>
|
||||
</group>
|
||||
|
@ -406,11 +424,13 @@
|
|||
<group>
|
||||
<group>
|
||||
<separator string="Internal Note"/>
|
||||
<field name="test_internal_note" nolabel="1" select="2" colspan="4"/>
|
||||
<field name="test_internal_note" nolabel="1" select="2"
|
||||
colspan="4"/>
|
||||
</group>
|
||||
<group>
|
||||
<separator string="External Note"/>
|
||||
<field name="test_external_note" nolabel="1" select="2" colspan="4"/>
|
||||
<field name="test_external_note" nolabel="1" select="2"
|
||||
colspan="4"/>
|
||||
</group>
|
||||
</group>
|
||||
</page>
|
||||
|
@ -451,7 +471,8 @@
|
|||
<separator orientation="vertical"/>
|
||||
<filter icon="terp-camera_test" name="success" string="Success"
|
||||
domain="[('success', '=', True)]"/>
|
||||
<filter icon="terp-dialog-close" name="no-success" string="Not success"
|
||||
<filter icon="terp-dialog-close" name="no-success"
|
||||
string="Not success"
|
||||
domain="[('success', '=', False)]"/>
|
||||
<separator orientation="vertical"/>
|
||||
<field name="name"/>
|
||||
|
@ -460,7 +481,8 @@
|
|||
</group>
|
||||
<newline/>
|
||||
<group expand="0" string="Group By...">
|
||||
<filter string="State" icon="terp-stock_effects-object-colorize" domain="[]"
|
||||
<filter string="State" icon="terp-stock_effects-object-colorize"
|
||||
domain="[]"
|
||||
context="{'group_by':'state'}"/>
|
||||
</group>
|
||||
</search>
|
||||
|
@ -505,10 +527,12 @@
|
|||
<field name="method_id"/>
|
||||
<field name="proof_type"/>
|
||||
</group>
|
||||
<group attrs="{'invisible':[('proof_type','!=','qualitative')]}">
|
||||
<group
|
||||
attrs="{'invisible':[('proof_type','!=','qualitative')]}">
|
||||
<separator string="Values"/>
|
||||
</group>
|
||||
<field name="valid_value_ids" attrs="{'invisible':[('proof_type','!=','qualitative')]}"
|
||||
<field name="valid_value_ids"
|
||||
attrs="{'invisible':[('proof_type','!=','qualitative')]}"
|
||||
nolabel="1"/>
|
||||
<group attrs="{'invisible':[('proof_type','=','qualitative')]}">
|
||||
<field name="min_value"/>
|
||||
|
|
Loading…
Reference in New Issue