mirror of
https://github.com/Kalenis/kalenislims.git
synced 2023-12-14 07:13:04 +01:00
lims: Notebook Line: store field Urgent
This commit is contained in:
parent
6c2992bf2d
commit
9ad5942aa2
|
@ -7,6 +7,7 @@ from datetime import datetime
|
|||
from email.mime.base import MIMEBase
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.application import MIMEApplication
|
||||
|
||||
from trytond import backend
|
||||
from trytond.model import Workflow, ModelView, ModelSQL, fields, Unique
|
||||
from trytond.wizard import Wizard, StateTransition, StateView, StateReport, \
|
||||
|
@ -920,6 +921,7 @@ class EntryDetailAnalysis(ModelSQL, ModelView):
|
|||
'service': detail.service.id,
|
||||
'analysis': detail.analysis.id,
|
||||
'analysis_origin': detail.analysis_origin,
|
||||
'urgent': detail.service.urgent,
|
||||
'repetition': i,
|
||||
'laboratory': detail.laboratory.id,
|
||||
'method': detail.method.id,
|
||||
|
|
|
@ -672,6 +672,7 @@ class NotebookRule(ModelSQL, ModelView):
|
|||
'service': line.service.id,
|
||||
'analysis': self.target_analysis.id,
|
||||
'analysis_origin': line.analysis_origin,
|
||||
'urgent': True,
|
||||
'repetition': repetition + 1,
|
||||
'laboratory': line.laboratory.id,
|
||||
'method': line.method.id,
|
||||
|
|
|
@ -6,6 +6,8 @@ import operator
|
|||
from datetime import datetime
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from sql import Literal, Join
|
||||
|
||||
from trytond import backend
|
||||
from trytond.model import ModelView, ModelSQL, fields
|
||||
from trytond.wizard import Wizard, StateTransition, StateView, StateAction, \
|
||||
StateReport, Button
|
||||
|
@ -363,8 +365,7 @@ class NotebookLine(ModelSQL, ModelView):
|
|||
readonly=True)
|
||||
planification = fields.Many2One('lims.planification', 'Planification',
|
||||
readonly=True)
|
||||
urgent = fields.Function(fields.Boolean('Urgent'), 'get_service_field',
|
||||
searcher='search_service_field')
|
||||
urgent = fields.Boolean('Urgent')
|
||||
priority = fields.Function(fields.Integer('Priority'),
|
||||
'get_service_field', searcher='search_service_field')
|
||||
report_date = fields.Function(fields.Date('Date agreed for result'),
|
||||
|
@ -402,6 +403,23 @@ class NotebookLine(ModelSQL, ModelView):
|
|||
controls = fields.Many2Many('lims.notebook.line-fraction',
|
||||
'notebook_line', 'fraction', 'Controls')
|
||||
|
||||
@classmethod
|
||||
def __register__(cls, module_name):
|
||||
TableHandler = backend.get('TableHandler')
|
||||
tablehandler = TableHandler(cls, module_name)
|
||||
|
||||
urgent_exist = tablehandler.column_exist('urgent')
|
||||
|
||||
super(NotebookLine, cls).__register__(module_name)
|
||||
|
||||
if not urgent_exist:
|
||||
cursor = Transaction().connection.cursor()
|
||||
Service = Pool().get('lims.service')
|
||||
cursor.execute('UPDATE "' + cls._table + '" nl '
|
||||
'SET urgent = srv.urgent FROM '
|
||||
'"' + Service._table + '" srv '
|
||||
'WHERE srv.id = nl.service')
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(NotebookLine, cls).__setup__()
|
||||
|
@ -1057,7 +1075,7 @@ class NotebookLineAllFields(ModelSQL, ModelView):
|
|||
line.device,
|
||||
line.service,
|
||||
line.analysis_origin,
|
||||
service.urgent,
|
||||
line.urgent,
|
||||
service.priority,
|
||||
service.report_date,
|
||||
line.initial_concentration,
|
||||
|
@ -3858,6 +3876,7 @@ class NotebookLineRepeatAnalysis(Wizard):
|
|||
'service': nline_to_repeat.service.id,
|
||||
'analysis': analysis_id,
|
||||
'analysis_origin': nline_to_repeat.analysis_origin,
|
||||
'urgent': nline_to_repeat.urgent,
|
||||
'repetition': nline_to_repeat.repetition + 1,
|
||||
'laboratory': nline_to_repeat.laboratory.id,
|
||||
'method': nline_to_repeat.method.id,
|
||||
|
|
|
@ -711,12 +711,24 @@ class PlanificationDetail(ModelSQL, ModelView):
|
|||
|
||||
@classmethod
|
||||
def set_urgent(cls, details, name, value):
|
||||
Service = Pool().get('lims.service')
|
||||
pool = Pool()
|
||||
Service = pool.get('lims.service')
|
||||
NotebookLine = pool.get('lims.notebook.line')
|
||||
|
||||
services_to_write = []
|
||||
notebook_lines_to_write = []
|
||||
for d in details:
|
||||
if d.fraction and d.service_analysis:
|
||||
for service in d.fraction.services:
|
||||
if service.analysis == d.service_analysis:
|
||||
Service.write([service], {'urgent': value})
|
||||
services_to_write.append(service)
|
||||
for sd in d.details:
|
||||
notebook_lines_to_write.append(sd.notebook_line)
|
||||
|
||||
if services_to_write:
|
||||
Service.write(services_to_write, {'urgent': value})
|
||||
if notebook_lines_to_write and value:
|
||||
NotebookLine.write(notebook_lines_to_write, {'urgent': value})
|
||||
|
||||
def get_icon(self, name):
|
||||
if self.comments:
|
||||
|
@ -1968,6 +1980,7 @@ class AddFractionControl(Wizard):
|
|||
'service': nline.service.id,
|
||||
'analysis': analysis_id,
|
||||
'analysis_origin': nline.analysis_origin,
|
||||
'urgent': nline.urgent,
|
||||
'repetition': nline.repetition + 1,
|
||||
'laboratory': nline.laboratory.id,
|
||||
'method': nline.method.id,
|
||||
|
@ -2636,6 +2649,7 @@ class AddFractionRMBMZ(Wizard):
|
|||
'service': nline.service.id,
|
||||
'analysis': nline.analysis.id,
|
||||
'analysis_origin': nline.analysis_origin,
|
||||
'urgent': nline.urgent,
|
||||
'repetition': nline.repetition + i,
|
||||
'laboratory': nline.laboratory.id,
|
||||
'method': nline.method.id,
|
||||
|
@ -3427,6 +3441,7 @@ class AddFractionMRT(Wizard):
|
|||
'service': nline.service.id,
|
||||
'analysis': nline.analysis.id,
|
||||
'analysis_origin': nline.analysis_origin,
|
||||
'urgent': nline.urgent,
|
||||
'repetition': nline.repetition + i,
|
||||
'laboratory': nline.laboratory.id,
|
||||
'method': nline.method.id,
|
||||
|
@ -5576,8 +5591,8 @@ class PlanificationSequenceReport(Report):
|
|||
'matrix': matrix,
|
||||
'fraction_type': fraction_type,
|
||||
'analysis_origin': analysis_origin,
|
||||
'priority': priority,
|
||||
'urgent': urgent,
|
||||
'priority': priority,
|
||||
'report_date': report_date,
|
||||
'trace_report': trace_report,
|
||||
'comments': comments,
|
||||
|
|
Loading…
Reference in a new issue