parent
210fcd0353
commit
3775242f84
40
quality.py
40
quality.py
|
@ -9,7 +9,8 @@ from trytond.pyson import Bool, Equal, Eval, If, Not
|
|||
from trytond.transaction import Transaction
|
||||
from trytond.pool import Pool
|
||||
|
||||
__all__ = ['Proof', 'ProofMethod', 'QualitativeValue', 'Template',
|
||||
__all__ = ['Proof', 'ProofMethod',
|
||||
'QualitativeValue', 'Template',
|
||||
'QualitativeTemplateLine', 'QuantitativeTemplateLine', 'TemplateLine',
|
||||
'QualityTest', 'QuantitativeTestLine', 'QualitativeTestLine', 'TestLine',
|
||||
'QualityTestQualityTemplate']
|
||||
|
@ -34,26 +35,24 @@ _DEPENDS = ['state']
|
|||
class Proof(ModelSQL, ModelView):
|
||||
'Quality Proof'
|
||||
__name__ = 'quality.proof'
|
||||
|
||||
name = fields.Char('Name', required=True, translate=True,
|
||||
select=True)
|
||||
name = fields.Char('Name', required=True, select=True, translate=True)
|
||||
active = fields.Boolean('Active', select=True)
|
||||
company = fields.Many2One('company.company', 'Company', required=True,
|
||||
select=True)
|
||||
type = fields.Selection(_PROOF_TYPES, 'Type', required=True)
|
||||
methods = fields.One2Many('quality.proof.method', 'proof', 'Methods',
|
||||
required=True)
|
||||
methods = fields.One2Many('quality.proof.method', 'proof', 'Methods')
|
||||
|
||||
@classmethod
|
||||
def __register__(cls, module_name):
|
||||
table = cls.__table_handler__(module_name)
|
||||
|
||||
super(Proof, cls).__register__(module_name)
|
||||
# Migration from 5.4: Drop company
|
||||
if table.column_exist('company'):
|
||||
table.drop_column('company')
|
||||
|
||||
@staticmethod
|
||||
def default_active():
|
||||
""" Return default value 'True' for active field """
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def default_company():
|
||||
""" Return default company value, context setted for company field """
|
||||
return Transaction().context.get('company')
|
||||
|
||||
|
||||
class ProofMethod(ModelSQL, ModelView):
|
||||
'Quality Proof Method'
|
||||
|
@ -415,6 +414,8 @@ class QualityTest(Workflow, ModelSQL, ModelView):
|
|||
ConfigLine = pool.get('quality.configuration.line')
|
||||
Model = pool.get('ir.model')
|
||||
for test in tests:
|
||||
if test.number:
|
||||
continue
|
||||
doc = str(test.document).split(',')[0]
|
||||
model, = Model.search([('model', '=', doc)])
|
||||
config = ConfigLine.search([('document', '=', model.id)])[0]
|
||||
|
@ -468,6 +469,7 @@ class QualityTest(Workflow, ModelSQL, ModelView):
|
|||
def copy(cls, tests, default=None):
|
||||
if default is None:
|
||||
default = {}
|
||||
default.setdefault('number', None)
|
||||
if 'templates' not in default:
|
||||
default['templates'] = None
|
||||
return super(QualityTest, cls).copy(tests, default)
|
||||
|
@ -515,6 +517,11 @@ class QualitativeTestLine(sequence_ordered(), ModelSQL, ModelView):
|
|||
], depends=['method'])
|
||||
success = fields.Function(fields.Boolean('Success'), 'get_success')
|
||||
|
||||
@fields.depends('proof')
|
||||
def on_change_proof(self):
|
||||
if not self.proof:
|
||||
self.method = None
|
||||
|
||||
def get_success(self, name=None):
|
||||
if self.value == self.test_value:
|
||||
return True
|
||||
|
@ -605,6 +612,11 @@ class QuantitativeTestLine(sequence_ordered(), ModelSQL, ModelView):
|
|||
res[line.id] = line.test.state
|
||||
return res
|
||||
|
||||
@fields.depends('proof')
|
||||
def on_change_proof(self):
|
||||
if not self.proof:
|
||||
self.method = None
|
||||
|
||||
@fields.depends('unit_range')
|
||||
def on_change_with_unit_range_digits(self, name=None):
|
||||
if not self.unit_range:
|
||||
|
|
22
quality.xml
22
quality.xml
|
@ -392,6 +392,28 @@
|
|||
<field name="perm_delete" eval="True"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.action.act_window" id="act_quantitative_lines">
|
||||
<field name="name">Quantitative Lines</field>
|
||||
<field name="res_model">quality.quantitative.test.line</field>
|
||||
<field name="domain" eval="[If(Eval('active_ids', []) == [Eval('active_id')], ('test', '=', Eval('active_id')), ('test', 'in', Eval('active_ids')))]" pyson="1"/>
|
||||
</record>
|
||||
<record model="ir.action.keyword" id="act_quantitative_lines_keyword">
|
||||
<field name="keyword">form_relate</field>
|
||||
<field name="model">quality.test,-1</field>
|
||||
<field name="action" ref="act_quantitative_lines"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.action.act_window" id="act_qualitative_lines">
|
||||
<field name="name">Qualitative Lines</field>
|
||||
<field name="res_model">quality.qualitative.test.line</field>
|
||||
<field name="domain" eval="[If(Eval('active_ids', []) == [Eval('active_id')], ('test', '=', Eval('active_id')), ('test', 'in', Eval('active_ids')))]" pyson="1"/>
|
||||
</record>
|
||||
<record model="ir.action.keyword" id="act_qualitative_lines_keyword">
|
||||
<field name="keyword">form_relate</field>
|
||||
<field name="model">quality.test,-1</field>
|
||||
<field name="action" ref="act_qualitative_lines"/>
|
||||
</record>
|
||||
|
||||
<!-- quality.qualitative.test.line -->
|
||||
<record model="ir.ui.view" id="quality_qualitative_test_line_form_view">
|
||||
<field name="model">quality.qualitative.test.line</field>
|
||||
|
|
|
@ -6,8 +6,6 @@ contains the full copyright notices and license terms. -->
|
|||
<field name="name"/>
|
||||
<label name="type"/>
|
||||
<field name="type"/>
|
||||
<label name="company"/>
|
||||
<field name="company"/>
|
||||
<label name="active"/>
|
||||
<field name="active"/>
|
||||
<field name="methods" colspan="4"/>
|
||||
|
|
|
@ -4,5 +4,4 @@ contains the full copyright notices and license terms. -->
|
|||
<tree>
|
||||
<field name="name"/>
|
||||
<field name="proof"/>
|
||||
<field name="active" tree_invisible="1"/>
|
||||
</tree>
|
||||
|
|
|
@ -4,6 +4,4 @@ contains the full copyright notices and license terms. -->
|
|||
<tree>
|
||||
<field name="name"/>
|
||||
<field name="type"/>
|
||||
<field name="company"/>
|
||||
<field name="active" tree_invisible="1"/>
|
||||
</tree>
|
||||
|
|
|
@ -7,5 +7,4 @@ contains the full copyright notices and license terms. -->
|
|||
<field name="proof"/>
|
||||
<field name="method"/>
|
||||
<field name="valid_value"/>
|
||||
<field name="active" tree_invisible="1"/>
|
||||
</tree>
|
||||
|
|
|
@ -4,5 +4,4 @@ contains the full copyright notices and license terms. -->
|
|||
<tree editable="1">
|
||||
<field name="method"/>
|
||||
<field name="name"/>
|
||||
<field name="active" tree_invisible="1"/>
|
||||
</tree>
|
||||
|
|
|
@ -9,5 +9,4 @@ contains the full copyright notices and license terms. -->
|
|||
<field name="min_value"/>
|
||||
<field name="max_value"/>
|
||||
<field name="unit"/>
|
||||
<field name="active" tree_invisible="1"/>
|
||||
</tree>
|
||||
|
|
|
@ -7,5 +7,4 @@
|
|||
<field name="name"/>
|
||||
<field name="proof"/>
|
||||
<field name="method"/>
|
||||
<field name="active" tree_invisible="1"/>
|
||||
</tree>
|
||||
|
|
|
@ -4,5 +4,4 @@ contains the full copyright notices and license terms. -->
|
|||
<tree>
|
||||
<field name="name"/>
|
||||
<field name="company"/>
|
||||
<field name="active" tree_invisible="1"/>
|
||||
</tree>
|
||||
|
|
|
@ -8,5 +8,4 @@ contains the full copyright notices and license terms. -->
|
|||
<field name="state"/>
|
||||
<field name="test_date" widget="date"/>
|
||||
<field name="test_date" widget="time" string="Test Time"/>
|
||||
<field name="active" tree_invisible="1"/>
|
||||
</tree>
|
||||
|
|
Loading…
Reference in New Issue