mirror of
https://github.com/Kalenis/kalenislims.git
synced 2023-12-14 07:13:04 +01:00
lims: Device: be able to deactivate it
This commit is contained in:
parent
4fc75a7d07
commit
1a9be6d5a6
|
@ -7,7 +7,8 @@ import operator
|
|||
from datetime import datetime
|
||||
from decimal import Decimal
|
||||
from sql import Literal
|
||||
from trytond.model import Workflow, ModelView, ModelSQL, fields, Unique
|
||||
from trytond.model import Workflow, ModelView, ModelSQL, DeactivableMixin, \
|
||||
fields, Unique
|
||||
from trytond.wizard import Wizard, StateTransition, StateView, StateAction, \
|
||||
Button
|
||||
from trytond.pool import Pool
|
||||
|
@ -1911,7 +1912,7 @@ class AnalysisLabMethod(ModelSQL):
|
|||
method=method.method.code))
|
||||
|
||||
|
||||
class AnalysisDevice(ModelSQL, ModelView):
|
||||
class AnalysisDevice(DeactivableMixin, ModelSQL, ModelView):
|
||||
'Analysis Device'
|
||||
__name__ = 'lims.analysis.device'
|
||||
_rec_name = 'device'
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# This file is part of lims module for Tryton.
|
||||
# The COPYRIGHT file at the top level of this repository contains
|
||||
# the full copyright notices and license terms.
|
||||
from trytond.model import ModelView, ModelSQL, fields, Unique
|
||||
from trytond.model import ModelView, ModelSQL, DeactivableMixin, fields, Unique
|
||||
from trytond.pool import Pool
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.pyson import Eval, Bool
|
||||
|
@ -265,7 +265,7 @@ class LabMethodWaitingTime(ModelSQL, ModelView):
|
|||
super(LabMethodWaitingTime, cls).delete(waiting_times)
|
||||
|
||||
|
||||
class LabDevice(ModelSQL, ModelView):
|
||||
class LabDevice(DeactivableMixin, ModelSQL, ModelView):
|
||||
'Laboratory Device'
|
||||
__name__ = 'lims.lab.device'
|
||||
_rec_name = 'description'
|
||||
|
@ -304,6 +304,26 @@ class LabDevice(ModelSQL, ModelView):
|
|||
return [(field,) + tuple(clause[1:])]
|
||||
return [(cls._rec_name,) + tuple(clause[1:])]
|
||||
|
||||
@classmethod
|
||||
def write(cls, *args):
|
||||
super(LabDevice, cls).write(*args)
|
||||
actions = iter(args)
|
||||
for devices, vals in zip(actions, actions):
|
||||
if 'active' in vals:
|
||||
cls.update_active_field(devices, vals['active'])
|
||||
|
||||
@classmethod
|
||||
def update_active_field(cls, devices, active):
|
||||
AnalysisDevice = Pool().get('lims.analysis.device')
|
||||
analysis_devices = AnalysisDevice.search([
|
||||
('device', 'in', devices),
|
||||
('active', '!=', active),
|
||||
])
|
||||
fields_to_update = {'active': active}
|
||||
if not active:
|
||||
fields_to_update['by_default'] = False
|
||||
AnalysisDevice.write(analysis_devices, fields_to_update)
|
||||
|
||||
|
||||
class LabDeviceType(ModelSQL, ModelView):
|
||||
'Laboratory Device Type'
|
||||
|
|
|
@ -746,6 +746,10 @@ msgctxt "field:lims.analysis-laboratory,write_uid:"
|
|||
msgid "Write User"
|
||||
msgstr "Usuario modificación"
|
||||
|
||||
msgctxt "field:lims.analysis.device,active:"
|
||||
msgid "Active"
|
||||
msgstr "Activo"
|
||||
|
||||
msgctxt "field:lims.analysis.device,analysis:"
|
||||
msgid "Analysis"
|
||||
msgstr "Análisis"
|
||||
|
@ -3224,6 +3228,10 @@ msgctxt "field:lims.generate_results_report.start,party:"
|
|||
msgid "Party"
|
||||
msgstr "Entidad"
|
||||
|
||||
msgctxt "field:lims.lab.device,active:"
|
||||
msgid "Active"
|
||||
msgstr "Activo"
|
||||
|
||||
msgctxt "field:lims.lab.device,code:"
|
||||
msgid "Code"
|
||||
msgstr "Código"
|
||||
|
@ -7496,10 +7504,18 @@ msgctxt "field:user.department,write_uid:"
|
|||
msgid "Write User"
|
||||
msgstr "Usuario modificación"
|
||||
|
||||
msgctxt "help:lims.analysis.device,active:"
|
||||
msgid "Uncheck to exclude from future use."
|
||||
msgstr "Desmarcar para excluir de uso en el futuro."
|
||||
|
||||
msgctxt "help:lims.configuration,mail_ack_subject:"
|
||||
msgid "In the text will be added suffix with the entry report number"
|
||||
msgstr "En el texto se añadirá sufijo con el número de ingreso del informe"
|
||||
|
||||
msgctxt "help:lims.lab.device,active:"
|
||||
msgid "Uncheck to exclude from future use."
|
||||
msgstr "Desmarcar para excluir de uso en el futuro."
|
||||
|
||||
msgctxt "help:lims.laboratory,cv_corrections:"
|
||||
msgid "Corrections for Coefficients of Variation (Control Charts)"
|
||||
msgstr "Correcciones para Coeficientes de Variación (Cartas de control)"
|
||||
|
|
|
@ -881,7 +881,8 @@ class NotebookLine(ModelSQL, ModelView):
|
|||
|
||||
cursor.execute('SELECT DISTINCT(device) '
|
||||
'FROM "' + AnalysisDevice._table + '" '
|
||||
'WHERE analysis = %s '
|
||||
'WHERE active IS TRUE '
|
||||
'AND analysis = %s '
|
||||
'AND laboratory = %s',
|
||||
(self.analysis.id, self.laboratory.id))
|
||||
res = cursor.fetchall()
|
||||
|
|
|
@ -335,7 +335,8 @@ class Service(ModelSQL, ModelView):
|
|||
method_domain = fields.Function(fields.Many2Many('lims.lab.method',
|
||||
None, None, 'Method domain'), 'on_change_with_method_domain')
|
||||
device = fields.Many2One('lims.lab.device', 'Device',
|
||||
domain=[('id', 'in', Eval('device_domain'))],
|
||||
domain=['OR', ('id', '=', Eval('device')),
|
||||
('id', 'in', Eval('device_domain'))],
|
||||
states={
|
||||
'required': Bool(Eval('device_domain')),
|
||||
'readonly': Bool(Eval('context', {}).get('readonly', True)),
|
||||
|
@ -656,7 +657,8 @@ class Service(ModelSQL, ModelView):
|
|||
|
||||
cursor.execute('SELECT device '
|
||||
'FROM "' + AnalysisDevice._table + '" '
|
||||
'WHERE analysis = %s '
|
||||
'WHERE active IS TRUE '
|
||||
'AND analysis = %s '
|
||||
'AND laboratory = %s '
|
||||
'AND by_default IS TRUE',
|
||||
(additional.id, laboratory_id))
|
||||
|
@ -967,12 +969,13 @@ class Service(ModelSQL, ModelView):
|
|||
return []
|
||||
|
||||
if by_default:
|
||||
by_default_clause = 'AND by_default = TRUE'
|
||||
by_default_clause = 'AND by_default IS TRUE'
|
||||
else:
|
||||
by_default_clause = ''
|
||||
cursor.execute('SELECT DISTINCT(device) '
|
||||
'FROM "' + AnalysisDevice._table + '" '
|
||||
'WHERE analysis = %s '
|
||||
'WHERE active IS TRUE '
|
||||
'AND analysis = %s '
|
||||
'AND laboratory = %s ' +
|
||||
by_default_clause,
|
||||
(analysis.id, laboratory.id))
|
||||
|
@ -4792,9 +4795,10 @@ class CreateSampleService(ModelView):
|
|||
|
||||
cursor.execute('SELECT DISTINCT(device) '
|
||||
'FROM "' + AnalysisDevice._table + '" '
|
||||
'WHERE analysis = %s '
|
||||
'WHERE active IS TRUE '
|
||||
'AND analysis = %s '
|
||||
'AND laboratory = %s '
|
||||
'AND by_default = TRUE',
|
||||
'AND by_default IS TRUE',
|
||||
(analysis_id, laboratory_id))
|
||||
res = cursor.fetchall()
|
||||
if not res:
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
<?xml version="1.0"?>
|
||||
<form>
|
||||
<label name="code"/>
|
||||
<field name="code"/>
|
||||
<label name="description"/>
|
||||
<field name="description"/>
|
||||
<group colspan="4" col="-1" id="description">
|
||||
<label name="code"/>
|
||||
<field name="code" xexpand="0"/>
|
||||
<label name="description"/>
|
||||
<field name="description" xexpand="1"/>
|
||||
<label name="active"/>
|
||||
<field name="active" xexpand="0" width="100"/>
|
||||
</group>
|
||||
<label name="device_type"/>
|
||||
<field name="device_type"/>
|
||||
<label name="serial_number"/>
|
||||
|
|
Loading…
Reference in a new issue