mirror of
https://github.com/Kalenis/kalenislims.git
synced 2023-12-14 07:13:04 +01:00
lims: typification: set which laboratory to use in services
This commit is contained in:
parent
6c9f300bdc
commit
c681d8ace4
5 changed files with 51 additions and 8 deletions
|
@ -100,6 +100,7 @@ class Typification(ModelSQL, ModelView):
|
||||||
valid_readonly = fields.Function(fields.Boolean(
|
valid_readonly = fields.Function(fields.Boolean(
|
||||||
'Field active readonly'),
|
'Field active readonly'),
|
||||||
'on_change_with_valid_readonly')
|
'on_change_with_valid_readonly')
|
||||||
|
laboratory = fields.Many2One('lims.laboratory', 'Laboratory')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def __setup__(cls):
|
def __setup__(cls):
|
||||||
|
|
|
@ -5926,6 +5926,10 @@ msgctxt "field:lims.typification,initial_concentration:"
|
||||||
msgid "Initial concentration"
|
msgid "Initial concentration"
|
||||||
msgstr "Concentración inicial"
|
msgstr "Concentración inicial"
|
||||||
|
|
||||||
|
msgctxt "field:lims.typification,laboratory:"
|
||||||
|
msgid "Laboratory"
|
||||||
|
msgstr "Laboratorio"
|
||||||
|
|
||||||
msgctxt "field:lims.typification,limit_digits:"
|
msgctxt "field:lims.typification,limit_digits:"
|
||||||
msgid "Limit digits"
|
msgid "Limit digits"
|
||||||
msgstr "Dígitos de límite"
|
msgstr "Dígitos de límite"
|
||||||
|
|
|
@ -1064,10 +1064,13 @@ class Service(ModelSQL, ModelView):
|
||||||
device = devices[0]
|
device = devices[0]
|
||||||
self.device = device
|
self.device = device
|
||||||
|
|
||||||
@fields.depends('analysis')
|
@fields.depends('analysis', '_parent_fraction.product_type',
|
||||||
|
'_parent_fraction.matrix')
|
||||||
def on_change_with_laboratory_domain(self, name=None):
|
def on_change_with_laboratory_domain(self, name=None):
|
||||||
cursor = Transaction().connection.cursor()
|
cursor = Transaction().connection.cursor()
|
||||||
AnalysisLaboratory = Pool().get('lims.analysis-laboratory')
|
pool = Pool()
|
||||||
|
AnalysisLaboratory = pool.get('lims.analysis-laboratory')
|
||||||
|
Typification = pool.get('lims.typification')
|
||||||
|
|
||||||
if not self.analysis:
|
if not self.analysis:
|
||||||
return []
|
return []
|
||||||
|
@ -1079,7 +1082,22 @@ class Service(ModelSQL, ModelView):
|
||||||
res = cursor.fetchall()
|
res = cursor.fetchall()
|
||||||
if not res:
|
if not res:
|
||||||
return []
|
return []
|
||||||
return [x[0] for x in res]
|
|
||||||
|
laboratories = [x[0] for x in res]
|
||||||
|
if len(laboratories) > 1:
|
||||||
|
cursor.execute('SELECT laboratory '
|
||||||
|
'FROM "' + Typification._table + '" '
|
||||||
|
'WHERE product_type = %s '
|
||||||
|
'AND matrix = %s '
|
||||||
|
'AND analysis = %s '
|
||||||
|
'AND valid IS TRUE '
|
||||||
|
'AND by_default IS TRUE',
|
||||||
|
(self.fraction.product_type.id, self.fraction.matrix.id,
|
||||||
|
self.analysis.id))
|
||||||
|
res = cursor.fetchone()
|
||||||
|
if res and res[0] in laboratories:
|
||||||
|
return [res[0]]
|
||||||
|
return laboratories
|
||||||
|
|
||||||
@fields.depends('analysis', 'typification_domain')
|
@fields.depends('analysis', 'typification_domain')
|
||||||
def on_change_with_method_domain(self, name=None):
|
def on_change_with_method_domain(self, name=None):
|
||||||
|
@ -3556,7 +3574,7 @@ class DuplicateSampleFromEntryStart(ModelView):
|
||||||
def on_change_with_date(self, name=None):
|
def on_change_with_date(self, name=None):
|
||||||
if self.sample:
|
if self.sample:
|
||||||
return self.sample.date
|
return self.sample.date
|
||||||
return False
|
return None
|
||||||
|
|
||||||
|
|
||||||
class DuplicateSampleFromEntry(Wizard):
|
class DuplicateSampleFromEntry(Wizard):
|
||||||
|
@ -5849,7 +5867,8 @@ class CreateSampleService(ModelView):
|
||||||
device_id = None
|
device_id = None
|
||||||
device_domain = []
|
device_domain = []
|
||||||
if analysis_id:
|
if analysis_id:
|
||||||
laboratory_domain = self._get_laboratory_domain(analysis_id)
|
laboratory_domain = self._get_laboratory_domain(analysis_id,
|
||||||
|
product_type_id, matrix_id)
|
||||||
if len(laboratory_domain) == 1:
|
if len(laboratory_domain) == 1:
|
||||||
laboratory_id = laboratory_domain[0]
|
laboratory_id = laboratory_domain[0]
|
||||||
method_domain = self._get_method_domain(analysis_id,
|
method_domain = self._get_method_domain(analysis_id,
|
||||||
|
@ -5894,9 +5913,11 @@ class CreateSampleService(ModelView):
|
||||||
self.laboratory_locked = False
|
self.laboratory_locked = False
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_laboratory_domain(analysis_id):
|
def _get_laboratory_domain(analysis_id, product_type_id, matrix_id):
|
||||||
cursor = Transaction().connection.cursor()
|
cursor = Transaction().connection.cursor()
|
||||||
AnalysisLaboratory = Pool().get('lims.analysis-laboratory')
|
pool = Pool()
|
||||||
|
AnalysisLaboratory = pool.get('lims.analysis-laboratory')
|
||||||
|
Typification = pool.get('lims.typification')
|
||||||
|
|
||||||
cursor.execute('SELECT DISTINCT(laboratory) '
|
cursor.execute('SELECT DISTINCT(laboratory) '
|
||||||
'FROM "' + AnalysisLaboratory._table + '" '
|
'FROM "' + AnalysisLaboratory._table + '" '
|
||||||
|
@ -5905,7 +5926,21 @@ class CreateSampleService(ModelView):
|
||||||
res = cursor.fetchall()
|
res = cursor.fetchall()
|
||||||
if not res:
|
if not res:
|
||||||
return []
|
return []
|
||||||
return [x[0] for x in res]
|
|
||||||
|
laboratories = [x[0] for x in res]
|
||||||
|
if len(laboratories) > 1:
|
||||||
|
cursor.execute('SELECT laboratory '
|
||||||
|
'FROM "' + Typification._table + '" '
|
||||||
|
'WHERE product_type = %s '
|
||||||
|
'AND matrix = %s '
|
||||||
|
'AND analysis = %s '
|
||||||
|
'AND valid IS TRUE '
|
||||||
|
'AND by_default IS TRUE',
|
||||||
|
(product_type_id, matrix_id, analysis_id))
|
||||||
|
res = cursor.fetchone()
|
||||||
|
if res and res[0] in laboratories:
|
||||||
|
return [res[0]]
|
||||||
|
return laboratories
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_method_domain(analysis_id, product_type_id, matrix_id):
|
def _get_method_domain(analysis_id, product_type_id, matrix_id):
|
||||||
|
|
|
@ -67,4 +67,6 @@
|
||||||
<field name="report_type"/>
|
<field name="report_type"/>
|
||||||
<label name="report_result_type"/>
|
<label name="report_result_type"/>
|
||||||
<field name="report_result_type"/>
|
<field name="report_result_type"/>
|
||||||
|
<label name="laboratory"/>
|
||||||
|
<field name="laboratory"/>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -24,4 +24,5 @@
|
||||||
<field name="referable"/>
|
<field name="referable"/>
|
||||||
<field name="by_default"/>
|
<field name="by_default"/>
|
||||||
<field name="valid_view"/>
|
<field name="valid_view"/>
|
||||||
|
<field name="laboratory"/>
|
||||||
</tree>
|
</tree>
|
||||||
|
|
Loading…
Reference in a new issue