lims_analysis_sheet: set annulment of notebook lines when confirming compilation
This commit is contained in:
parent
6ea3871b42
commit
1627302fcf
|
@ -2,6 +2,7 @@
|
|||
# The COPYRIGHT file at the top level of this repository contains
|
||||
# the full copyright notices and license terms.
|
||||
import sql
|
||||
from datetime import datetime
|
||||
|
||||
from trytond.model import fields
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
|
@ -44,6 +45,30 @@ class Compilation(metaclass=PoolMeta):
|
|||
#cls._buttons['collect']['invisible'] = Or(Eval('state') != 'active',
|
||||
#Bool(Eval('analysis_sheet')))
|
||||
|
||||
@classmethod
|
||||
def confirm(cls, compilations):
|
||||
pool = Pool()
|
||||
Data = pool.get('lims.interface.data')
|
||||
NotebookLine = pool.get('lims.notebook.line')
|
||||
|
||||
super(Compilation, cls).confirm(compilations)
|
||||
|
||||
lines_to_write = []
|
||||
for c in compilations:
|
||||
with Transaction().set_context(
|
||||
lims_interface_table=c.table.id):
|
||||
lines = Data.search([('compilation', '=', c.id)])
|
||||
for line in lines:
|
||||
if line.annulled and line.notebook_line:
|
||||
lines_to_write.append(line.notebook_line)
|
||||
if lines_to_write:
|
||||
NotebookLine.write(lines_to_write, {
|
||||
'result_modifier': 'na',
|
||||
'annulled': True,
|
||||
'annulment_date': datetime.now(),
|
||||
'report': False,
|
||||
})
|
||||
|
||||
|
||||
class Column(metaclass=PoolMeta):
|
||||
__name__ = 'lims.interface.column'
|
||||
|
|
|
@ -545,7 +545,7 @@ class AnalysisSheet(Workflow, ModelSQL, ModelView):
|
|||
raise UserError(gettext(
|
||||
'lims_analysis_sheet.msg_sheet_not_lines'))
|
||||
for line in lines:
|
||||
if not getattr(line, result_field):
|
||||
if not getattr(line, result_field) and not line.annulled:
|
||||
raise UserError(gettext(
|
||||
'lims_analysis_sheet.msg_sheet_not_results'))
|
||||
|
||||
|
|
|
@ -1090,7 +1090,7 @@ class Compilation(Workflow, ModelSQL, ModelView):
|
|||
value = getattr(l, res)
|
||||
data[result_fields[res]['field_name']] = value
|
||||
if data:
|
||||
NotebookLine.write(nb_line, data)
|
||||
NotebookLine.write([nb_line], data)
|
||||
|
||||
|
||||
class CompilationOrigin(ModelSQL, ModelView):
|
||||
|
|
Loading…
Reference in New Issue