mirror of
https://github.com/Kalenis/kalenislims.git
synced 2023-12-14 07:13:04 +01:00
lims_analysis_sheet: use default field notebook_line in compilation data
This commit is contained in:
parent
c0f3afa631
commit
4a1448e91b
|
@ -292,15 +292,11 @@ class AnalysisSheet(Workflow, ModelSQL, ModelView):
|
|||
result = {}
|
||||
for s in sheets:
|
||||
result[s.id] = False
|
||||
nl_field = (s.template.interface.notebook_line_field and
|
||||
s.template.interface.notebook_line_field.alias or None)
|
||||
if not nl_field:
|
||||
continue
|
||||
with Transaction().set_context(
|
||||
lims_interface_table=s.compilation.table.id):
|
||||
lines = Data.search([('compilation', '=', s.compilation.id)])
|
||||
for line in lines:
|
||||
nl = getattr(line, nl_field)
|
||||
nl = line.notebook_line
|
||||
if nl and nl.service.urgent:
|
||||
result[s.id] = True
|
||||
break
|
||||
|
@ -314,16 +310,12 @@ class AnalysisSheet(Workflow, ModelSQL, ModelView):
|
|||
result = {}
|
||||
for s in sheets:
|
||||
result[s.id] = 0
|
||||
nl_field = (s.template.interface.notebook_line_field and
|
||||
s.template.interface.notebook_line_field.alias or None)
|
||||
if not nl_field:
|
||||
continue
|
||||
with Transaction().set_context(
|
||||
lims_interface_table=s.compilation.table.id):
|
||||
samples = []
|
||||
lines = Data.search([('compilation', '=', s.compilation.id)])
|
||||
for line in lines:
|
||||
nl = getattr(line, nl_field)
|
||||
nl = line.notebook_line
|
||||
if nl:
|
||||
samples.append(nl.fraction.id)
|
||||
result[s.id] = len(list(set(samples)))
|
||||
|
@ -337,16 +329,12 @@ class AnalysisSheet(Workflow, ModelSQL, ModelView):
|
|||
result = {}
|
||||
for s in sheets:
|
||||
result[s.id] = False
|
||||
nl_field = (s.template.interface.notebook_line_field and
|
||||
s.template.interface.notebook_line_field.alias or None)
|
||||
if not nl_field:
|
||||
continue
|
||||
with Transaction().set_context(
|
||||
lims_interface_table=s.compilation.table.id):
|
||||
samples = {}
|
||||
lines = Data.search([('compilation', '=', s.compilation.id)])
|
||||
for line in lines:
|
||||
nl = getattr(line, nl_field)
|
||||
nl = line.notebook_line
|
||||
if not nl:
|
||||
continue
|
||||
if nl.fraction.id not in samples:
|
||||
|
@ -449,11 +437,6 @@ class AnalysisSheet(Workflow, ModelSQL, ModelView):
|
|||
Compilation = pool.get('lims.interface.compilation')
|
||||
|
||||
for s in sheets:
|
||||
nl_field = (s.template.interface.notebook_line_field and
|
||||
s.template.interface.notebook_line_field.alias or None)
|
||||
if not nl_field:
|
||||
continue
|
||||
|
||||
t_analysis_ids = []
|
||||
for t_analysis in s.template.analysis:
|
||||
if t_analysis.analysis.type == 'analysis':
|
||||
|
@ -468,7 +451,7 @@ class AnalysisSheet(Workflow, ModelSQL, ModelView):
|
|||
lims_interface_table=s.compilation.table.id):
|
||||
lines = Data.search([('compilation', '=', s.compilation.id)])
|
||||
for line in lines:
|
||||
nl = getattr(line, nl_field)
|
||||
nl = line.notebook_line
|
||||
if nl:
|
||||
notebooks_ids.append(nl.notebook.id)
|
||||
if notebooks_ids:
|
||||
|
@ -578,16 +561,12 @@ class AnalysisSheet(Workflow, ModelSQL, ModelView):
|
|||
continue
|
||||
controls_allowed = s.template.controls_allowed
|
||||
|
||||
nl_field = (s.template.interface.notebook_line_field and
|
||||
s.template.interface.notebook_line_field.alias or None)
|
||||
if not nl_field:
|
||||
continue
|
||||
with Transaction().set_context(
|
||||
lims_interface_table=s.compilation.table.id):
|
||||
ok = False
|
||||
lines = Data.search([('compilation', '=', s.compilation.id)])
|
||||
for line in lines:
|
||||
nl = getattr(line, nl_field)
|
||||
nl = line.notebook_line
|
||||
if nl and nl.fraction.special_type in controls_allowed:
|
||||
ok = True
|
||||
break
|
||||
|
@ -608,8 +587,6 @@ class AnalysisSheet(Workflow, ModelSQL, ModelView):
|
|||
Data = Pool().get('lims.interface.data')
|
||||
|
||||
interface = self.template.interface
|
||||
if not interface.notebook_line_field:
|
||||
return
|
||||
|
||||
fixed_values = {}
|
||||
schema, _ = self.compilation._get_schema()
|
||||
|
@ -633,7 +610,7 @@ class AnalysisSheet(Workflow, ModelSQL, ModelView):
|
|||
for nl in lines:
|
||||
line = {'compilation': self.compilation.id}
|
||||
line.update(fixed_values)
|
||||
line[interface.notebook_line_field.alias] = nl.id
|
||||
line['notebook_line'] = nl.id
|
||||
if interface.analysis_field:
|
||||
if interface.analysis_field.type_ == 'many2one':
|
||||
line[interface.analysis_field.alias] = nl.analysis.id
|
||||
|
|
|
@ -238,17 +238,12 @@ class RepeatAnalysis(Wizard):
|
|||
sheet_id = Transaction().context['active_id']
|
||||
sheet = AnalysisSheet(sheet_id)
|
||||
|
||||
nl_field = (sheet.template.interface.notebook_line_field and
|
||||
sheet.template.interface.notebook_line_field.alias or None)
|
||||
if not nl_field:
|
||||
return defaults
|
||||
|
||||
to_create = []
|
||||
with Transaction().set_context(
|
||||
lims_interface_table=sheet.compilation.table.id):
|
||||
lines = Data.search([('compilation', '=', sheet.compilation.id)])
|
||||
for line in lines:
|
||||
nl = getattr(line, nl_field)
|
||||
nl = line.notebook_line
|
||||
if not nl:
|
||||
continue
|
||||
to_create.append({
|
||||
|
@ -348,11 +343,6 @@ class InternalRelationsCalc(Wizard):
|
|||
sheet_id = Transaction().context['active_id']
|
||||
sheet = AnalysisSheet(sheet_id)
|
||||
|
||||
nl_field = (sheet.template.interface.notebook_line_field and
|
||||
sheet.template.interface.notebook_line_field.alias or None)
|
||||
if not nl_field:
|
||||
return 'end'
|
||||
|
||||
nl_result_field, = ModelField.search([
|
||||
('model.model', '=', 'lims.notebook.line'),
|
||||
('name', '=', 'result'),
|
||||
|
@ -372,15 +362,15 @@ class InternalRelationsCalc(Wizard):
|
|||
lims_interface_table=sheet.compilation.table.id):
|
||||
lines = Data.search([('compilation', '=', sheet.compilation.id)])
|
||||
for line in lines:
|
||||
notebook_line = getattr(line, nl_field)
|
||||
if not notebook_line:
|
||||
nl = line.notebook_line
|
||||
if not nl:
|
||||
continue
|
||||
if notebook_line.notebook.id not in notebooks:
|
||||
notebooks[notebook_line.notebook.id] = {}
|
||||
notebooks[notebook_line.notebook.id][
|
||||
notebook_line.analysis.code] = getattr(line, result_field)
|
||||
if notebook_line.analysis.behavior == 'internal_relation':
|
||||
relations[line] = notebook_line
|
||||
if nl.notebook.id not in notebooks:
|
||||
notebooks[nl.notebook.id] = {}
|
||||
notebooks[nl.notebook.id][
|
||||
nl.analysis.code] = getattr(line, result_field)
|
||||
if nl.analysis.behavior == 'internal_relation':
|
||||
relations[line] = nl
|
||||
if not relations:
|
||||
return 'end'
|
||||
|
||||
|
@ -545,11 +535,6 @@ class ResultsVerification(Wizard):
|
|||
sheet_id = Transaction().context['active_id']
|
||||
sheet = AnalysisSheet(sheet_id)
|
||||
|
||||
nl_field = (sheet.template.interface.notebook_line_field and
|
||||
sheet.template.interface.notebook_line_field.alias or None)
|
||||
if not nl_field:
|
||||
return 'end'
|
||||
|
||||
nl_result_field, = ModelField.search([
|
||||
('model.model', '=', 'lims.notebook.line'),
|
||||
('name', '=', 'result'),
|
||||
|
@ -581,10 +566,10 @@ class ResultsVerification(Wizard):
|
|||
lims_interface_table=sheet.compilation.table.id):
|
||||
lines = Data.search([('compilation', '=', sheet.compilation.id)])
|
||||
for line in lines:
|
||||
notebook_line = getattr(line, nl_field)
|
||||
if not notebook_line:
|
||||
nl = line.notebook_line
|
||||
if not nl:
|
||||
continue
|
||||
notebook_lines[line] = notebook_line
|
||||
notebook_lines[line] = nl
|
||||
if not notebook_lines:
|
||||
return 'end'
|
||||
|
||||
|
|
Loading…
Reference in a new issue