mirror of
https://github.com/Kalenis/kalenislims.git
synced 2023-12-14 07:13:04 +01:00
lims: typification: set which department to use by default
This commit is contained in:
parent
cd5f133c08
commit
68f7a4b27c
|
@ -107,6 +107,11 @@ class Typification(ModelSQL, ModelView):
|
|||
depends=['laboratory_domain'])
|
||||
laboratory_domain = fields.Function(fields.Many2Many('lims.laboratory',
|
||||
None, None, 'Laboratory domain'), 'on_change_with_laboratory_domain')
|
||||
department = fields.Many2One('company.department', 'Department',
|
||||
domain=[('id', 'in', Eval('department_domain'))],
|
||||
depends=['department_domain'])
|
||||
department_domain = fields.Function(fields.Many2Many('company.department',
|
||||
None, None, 'Department domain'), 'on_change_with_department_domain')
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
|
@ -215,6 +220,24 @@ class Typification(ModelSQL, ModelView):
|
|||
return [l.laboratory.id for l in self.analysis.laboratories]
|
||||
return []
|
||||
|
||||
@fields.depends('analysis', 'laboratory')
|
||||
def on_change_with_department_domain(self, name=None):
|
||||
cursor = Transaction().connection.cursor()
|
||||
AnalysisLaboratory = Pool().get('lims.analysis-laboratory')
|
||||
|
||||
if not self.analysis or not self.laboratory:
|
||||
return []
|
||||
|
||||
cursor.execute('SELECT DISTINCT(department) '
|
||||
'FROM "' + AnalysisLaboratory._table + '" '
|
||||
'WHERE analysis = %s '
|
||||
'AND laboratory = %s',
|
||||
(self.analysis.id, self.laboratory.id))
|
||||
res = cursor.fetchall()
|
||||
if not res:
|
||||
return []
|
||||
return [x[0] for x in res]
|
||||
|
||||
@fields.depends('analysis')
|
||||
def on_change_analysis(self):
|
||||
method = None
|
||||
|
|
|
@ -1311,6 +1311,7 @@ class EntryDetailAnalysis(ModelSQL, ModelView):
|
|||
significant_digits = t.significant_digits
|
||||
scientific_notation = t.scientific_notation
|
||||
report = t.report
|
||||
department = t.department and t.department.id or None
|
||||
else:
|
||||
repetitions = 0
|
||||
initial_concentration = None
|
||||
|
@ -1326,6 +1327,7 @@ class EntryDetailAnalysis(ModelSQL, ModelView):
|
|||
significant_digits = None
|
||||
scientific_notation = False
|
||||
report = False
|
||||
department = None
|
||||
|
||||
results_estimated_waiting = None
|
||||
cursor.execute('SELECT results_estimated_waiting '
|
||||
|
@ -1344,23 +1346,23 @@ class EntryDetailAnalysis(ModelSQL, ModelView):
|
|||
if res:
|
||||
results_estimated_waiting = res[0]
|
||||
|
||||
department = None
|
||||
cursor.execute('SELECT department '
|
||||
'FROM "' + AnalysisLaboratory._table + '" '
|
||||
'WHERE analysis = %s '
|
||||
'AND laboratory = %s '
|
||||
'ORDER BY by_default DESC',
|
||||
(detail.analysis.id, detail.laboratory.id))
|
||||
res = cursor.fetchone()
|
||||
if res and res[0]:
|
||||
department = res[0]
|
||||
else:
|
||||
if not department:
|
||||
cursor.execute('SELECT department '
|
||||
'FROM "' + ProductType._table + '" '
|
||||
'WHERE id = %s', (fraction.product_type.id,))
|
||||
'FROM "' + AnalysisLaboratory._table + '" '
|
||||
'WHERE analysis = %s '
|
||||
'AND laboratory = %s '
|
||||
'ORDER BY by_default DESC',
|
||||
(detail.analysis.id, detail.laboratory.id))
|
||||
res = cursor.fetchone()
|
||||
if res and res[0]:
|
||||
department = res[0]
|
||||
else:
|
||||
cursor.execute('SELECT department '
|
||||
'FROM "' + ProductType._table + '" '
|
||||
'WHERE id = %s', (fraction.product_type.id,))
|
||||
res = cursor.fetchone()
|
||||
if res and res[0]:
|
||||
department = res[0]
|
||||
|
||||
for i in range(0, repetitions + 1):
|
||||
notebook_line = {
|
||||
|
|
|
@ -6356,6 +6356,14 @@ msgctxt "field:lims.typification,default_repetitions:"
|
|||
msgid "Default repetitions"
|
||||
msgstr "Repeticiones por defecto"
|
||||
|
||||
msgctxt "field:lims.typification,department:"
|
||||
msgid "Department"
|
||||
msgstr "Departamento"
|
||||
|
||||
msgctxt "field:lims.typification,department_domain:"
|
||||
msgid "Department domain"
|
||||
msgstr "Dominio para Departamento"
|
||||
|
||||
msgctxt "field:lims.typification,detection_limit:"
|
||||
msgid "Detection limit"
|
||||
msgstr "Límite de detección"
|
||||
|
|
|
@ -71,4 +71,6 @@
|
|||
<field name="report_result_type"/>
|
||||
<label name="laboratory"/>
|
||||
<field name="laboratory"/>
|
||||
<label name="department"/>
|
||||
<field name="department"/>
|
||||
</form>
|
||||
|
|
Loading…
Reference in a new issue