lims: notebook: add wizards to annull lines and revert annulment

This commit is contained in:
Adrián Bernardi 2021-06-03 21:22:24 -03:00
parent a4c27c73dc
commit c108ee498e
10 changed files with 270 additions and 42 deletions

View File

@ -147,6 +147,7 @@ def register():
notebook.NotebookLoadResultsManualSit2,
notebook.NotebookAddInternalRelationsStart,
notebook.NotebookAcceptLinesStart,
notebook.NotebookAnnulLinesStart,
notebook.NotebookLineRepeatAnalysisStart,
sample.FractionsByLocationsStart,
notebook.NotebookResultsVerificationStart,
@ -302,6 +303,9 @@ def register():
notebook.NotebookAcceptLines,
notebook.NotebookLineAcceptLines,
notebook.NotebookLineUnacceptLines,
notebook.NotebookAnnulLines,
notebook.NotebookLineAnnulLines,
notebook.NotebookLineUnannulLines,
notebook.NotebookLineRepeatAnalysis,
sample.FractionsByLocations,
notebook.NotebookResultsVerification,

View File

@ -2679,6 +2679,10 @@ msgctxt "field:lims.notebook.add_internal_relations.start,analysis_domain:"
msgid "Internal relations domain"
msgstr "Dominio para Relaciones internas"
msgctxt "field:lims.notebook.annul_lines.start,annulment_reason:"
msgid "Annulment reason"
msgstr "Motivo de anulación"
msgctxt "field:lims.notebook.generate_results_report.start,append_samples:"
msgid "Append samples to existing reports"
msgstr "Anexar muestras a informes existentes"
@ -2887,6 +2891,10 @@ msgctxt "field:lims.notebook.line,annulment_date:"
msgid "Annulment date"
msgstr "Fecha de anulación"
msgctxt "field:lims.notebook.line,annulment_reason:"
msgid "Annulment reason"
msgstr "Motivo de anulación"
msgctxt "field:lims.notebook.line,backup:"
msgid "Backup"
msgstr "Resguardo"
@ -3195,6 +3203,10 @@ msgctxt "field:lims.notebook.line.all_fields,annulment_date:"
msgid "Annulment date"
msgstr "Fecha de anulación"
msgctxt "field:lims.notebook.line.all_fields,annulment_reason:"
msgid "Annulment reason"
msgstr "Motivo de anulación"
msgctxt "field:lims.notebook.line.all_fields,backup:"
msgid "Backup"
msgstr "Resguardo"
@ -7144,12 +7156,16 @@ msgstr "Gestionar servicios"
msgctxt "model:ir.action,name:wiz_lims_notebook_accept_lines"
msgid "Accept Lines"
msgstr "11) Aceptar Resultados a todas las líneas"
msgstr "11) Aceptar resultados a todas las líneas"
msgctxt "model:ir.action,name:wiz_lims_notebook_add_internal_relations"
msgid "Add Internal Relations"
msgstr "02) Agregar relaciones internas"
msgctxt "model:ir.action,name:wiz_lims_notebook_annul_lines"
msgid "Annul Lines"
msgstr "12) Anular resultados a todas las líneas"
msgctxt "model:ir.action,name:wiz_lims_notebook_initial_concentration_calc"
msgid "Initial Concentration Calculation"
msgstr "03) Cálculo de concentración inicial"
@ -7168,7 +7184,11 @@ msgstr "09) Validación de límites"
msgctxt "model:ir.action,name:wiz_lims_notebook_line_accept_lines"
msgid "Accept Lines"
msgstr "11) Aceptar Resultados a las líneas"
msgstr "11) Aceptar resultados a las líneas"
msgctxt "model:ir.action,name:wiz_lims_notebook_line_annul_lines"
msgid "Annul Lines"
msgstr "13) Anular resultados a las líneas"
msgctxt ""
"model:ir.action,name:wiz_lims_notebook_line_initial_concentration_calc"
@ -7206,8 +7226,12 @@ msgid "Results Verification"
msgstr "08) Verificación de resultados"
msgctxt "model:ir.action,name:wiz_lims_notebook_line_unaccept_lines"
msgid "Unaccept Lines"
msgstr "12) Revertir Aceptación de Resultados a las líneas"
msgid "Revert Lines Acceptance"
msgstr "12) Revertir Aceptación de resultados a las líneas"
msgctxt "model:ir.action,name:wiz_lims_notebook_line_unannul_lines"
msgid "Revert Lines Annulment"
msgstr "14) Revertir Anulación de resultados a las líneas"
msgctxt "model:ir.action,name:wiz_lims_notebook_line_uncertainty_calc"
msgid "Uncertainty Calculation"
@ -9158,6 +9182,10 @@ msgctxt "model:lims.notebook.add_internal_relations.start,name:"
msgid "Add Internal Relations"
msgstr "Agregar relaciones internas"
msgctxt "model:lims.notebook.annul_lines.start,name:"
msgid "Annul Lines"
msgstr "Anular líneas"
msgctxt "model:lims.notebook.evaluate_rules.start,name:"
msgid "Evaluate Rules"
msgstr "Evaluar Reglas de cuaderno"
@ -12882,6 +12910,10 @@ msgctxt "selection:lims.rule.condition,condition:"
msgid ">="
msgstr ">="
msgctxt "selection:lims.sample,state:"
msgid "Annulled"
msgstr "Anulada"
msgctxt "selection:lims.sample,state:"
msgid "Draft"
msgstr "Borrador"
@ -13574,6 +13606,10 @@ msgctxt "view:lims.notebook.add_internal_relations.start:"
msgid "Add Internal Relations"
msgstr "Agregar relaciones internas"
msgctxt "view:lims.notebook.annul_lines.start:"
msgid "Annul all lines?"
msgstr "¿Anular todas las líneas?"
msgctxt "view:lims.notebook.evaluate_rules.start:"
msgid "Evaluate rules?"
msgstr "¿Evaluar reglas de cuaderno?"
@ -14603,6 +14639,14 @@ msgctxt "wizard_button:lims.notebook.add_internal_relations,start,end:"
msgid "Cancel"
msgstr "Cancelar"
msgctxt "wizard_button:lims.notebook.annul_lines,start,end:"
msgid "Cancel"
msgstr "Cancelar"
msgctxt "wizard_button:lims.notebook.annul_lines,start,ok:"
msgid "Ok"
msgstr "Aceptar"
msgctxt "wizard_button:lims.notebook.evaluate_rules,start,end:"
msgid "Cancel"
msgstr "Cancelar"
@ -14802,6 +14846,14 @@ msgctxt "wizard_button:lims.notebook_line.accept_lines,start,ok:"
msgid "Ok"
msgstr "Aceptar"
msgctxt "wizard_button:lims.notebook_line.annul_lines,start,end:"
msgid "Cancel"
msgstr "Cancelar"
msgctxt "wizard_button:lims.notebook_line.annul_lines,start,ok:"
msgid "Ok"
msgstr "Aceptar"
msgctxt "wizard_button:lims.notebook_line.evaluate_rules,start,end:"
msgid "Cancel"
msgstr "Cancelar"

View File

@ -912,6 +912,9 @@ class NotebookLine(ModelSQL, ModelView):
select=True)
annulment_date = fields.DateTime('Annulment date',
states={'readonly': True})
annulment_reason = fields.Text('Annulment reason',
states={'readonly': True, 'invisible': ~Eval('annulled')},
depends=['annulled'])
results_report = fields.Many2One('lims.results_report', 'Results Report',
readonly=True, select=True)
planification = fields.Many2One('lims.planification', 'Planification',
@ -1723,6 +1726,9 @@ class NotebookLineAllFields(ModelSQL, ModelView):
acceptance_date = fields.DateTime('Acceptance date', readonly=True)
annulled = fields.Boolean('Annulled', readonly=True)
annulment_date = fields.DateTime('Annulment date', readonly=True)
annulment_reason = fields.Text('Annulment reason', readonly=True,
states={'invisible': ~Eval('annulled')},
depends=['annulled'])
results_report = fields.Many2One('lims.results_report', 'Results Report',
readonly=True)
planification = fields.Many2One('lims.planification', 'Planification',
@ -1827,6 +1833,7 @@ class NotebookLineAllFields(ModelSQL, ModelView):
line.acceptance_date,
line.annulled,
line.annulment_date,
line.annulment_reason,
line.results_report,
line.planification,
detail.confirmation_date,
@ -4856,7 +4863,7 @@ class NotebookLineAcceptLines(NotebookAcceptLines):
class NotebookLineUnacceptLines(Wizard):
'Unaccept Lines'
'Revert Lines Acceptance'
__name__ = 'lims.notebook_line.unaccept_lines'
start_state = 'ok'
@ -4901,6 +4908,101 @@ class NotebookLineUnacceptLines(Wizard):
return 'reload'
class NotebookAnnulLinesStart(ModelView):
'Annul Lines'
__name__ = 'lims.notebook.annul_lines.start'
annulment_reason = fields.Text('Annulment reason')
class NotebookAnnulLines(Wizard):
'Annul Lines'
__name__ = 'lims.notebook.annul_lines'
start = StateView('lims.notebook.annul_lines.start',
'lims.lims_notebook_annul_lines_start_view_form', [
Button('Cancel', 'end', 'tryton-cancel'),
Button('Ok', 'ok', 'tryton-ok', default=True),
])
ok = StateTransition()
def transition_ok(self):
NotebookLine = Pool().get('lims.notebook.line')
notebook_lines = NotebookLine.search([
('notebook', 'in', Transaction().context['active_ids']),
('accepted', '=', False),
('annulled', '=', False),
])
if notebook_lines:
self.lines_annul(notebook_lines)
return 'end'
def lines_annul(self, notebook_lines):
NotebookLine = Pool().get('lims.notebook.line')
NotebookLine.write(notebook_lines, {
'result_modifier': 'na',
'annulled': True,
'annulment_date': datetime.now(),
'annulment_reason': self.start.annulment_reason,
'report': False,
})
def end(self):
return 'reload'
class NotebookLineAnnulLines(NotebookAnnulLines):
'Annul Lines'
__name__ = 'lims.notebook_line.annul_lines'
def transition_ok(self):
NotebookLine = Pool().get('lims.notebook.line')
notebook_lines = NotebookLine.search([
('id', 'in', Transaction().context['active_ids']),
('accepted', '=', False),
('annulled', '=', False),
])
if notebook_lines:
self.lines_annul(notebook_lines)
return 'end'
class NotebookLineUnannulLines(Wizard):
'Revert Lines Annulment'
__name__ = 'lims.notebook_line.unannul_lines'
start_state = 'ok'
ok = StateTransition()
def transition_ok(self):
NotebookLine = Pool().get('lims.notebook.line')
notebook_lines = NotebookLine.search([
('id', 'in', Transaction().context['active_ids']),
('annulled', '=', True),
])
if notebook_lines:
self.lines_unannul(notebook_lines)
return 'end'
def lines_unannul(self, notebook_lines):
NotebookLine = Pool().get('lims.notebook.line')
NotebookLine.write(notebook_lines, {
'result_modifier': 'eq',
'annulled': False,
'annulment_date': None,
'annulment_reason': None,
'report': True,
})
def end(self):
return 'reload'
class NotebookResultsVerificationStart(ModelView):
'Results Verification'
__name__ = 'lims.notebook.results_verification.start'

View File

@ -620,10 +620,10 @@
<field name="group" ref="group_lims_laboratory_results_acceptance"/>
</record>
<!-- Wizard Unaccept Lines -->
<!-- Wizard Revert Lines Acceptance -->
<record model="ir.action.wizard" id="wiz_lims_notebook_line_unaccept_lines">
<field name="name">Unaccept Lines</field>
<field name="name">Revert Lines Acceptance</field>
<field name="wiz_name">lims.notebook_line.unaccept_lines</field>
</record>
@ -639,6 +639,47 @@
<field name="group" ref="group_lims_laboratory_results_acceptance"/>
</record>
<!-- Wizard Annul Lines -->
<record model="ir.ui.view" id="lims_notebook_annul_lines_start_view_form">
<field name="model">lims.notebook.annul_lines.start</field>
<field name="type">form</field>
<field name="name">notebook_annul_lines_form</field>
</record>
<record model="ir.action.wizard" id="wiz_lims_notebook_annul_lines">
<field name="name">Annul Lines</field>
<field name="wiz_name">lims.notebook.annul_lines</field>
</record>
<record model="ir.action.keyword" id="lims_notebook_annul_lines_keyword">
<field name="keyword">form_action</field>
<field name="model">lims.notebook,-1</field>
<field name="action" ref="wiz_lims_notebook_annul_lines"/>
</record>
<record model="ir.action.wizard" id="wiz_lims_notebook_line_annul_lines">
<field name="name">Annul Lines</field>
<field name="wiz_name">lims.notebook_line.annul_lines</field>
</record>
<record model="ir.action.keyword" id="lims_notebook_line_annul_lines_keyword">
<field name="keyword">form_action</field>
<field name="model">lims.notebook.line,-1</field>
<field name="action" ref="wiz_lims_notebook_line_annul_lines"/>
</record>
<!-- Wizard Revert Lines Annulment -->
<record model="ir.action.wizard" id="wiz_lims_notebook_line_unannul_lines">
<field name="name">Revert Lines Annulment</field>
<field name="wiz_name">lims.notebook_line.unannul_lines</field>
</record>
<record model="ir.action.keyword" id="lims_notebook_line_unannul_lines_keyword">
<field name="keyword">form_action</field>
<field name="model">lims.notebook.line,-1</field>
<field name="action" ref="wiz_lims_notebook_line_unannul_lines"/>
</record>
<!-- Wizard Results Verification -->
<record model="ir.ui.view" id="lims_notebook_results_verification_view_form">

View File

@ -2502,6 +2502,7 @@ class Sample(ModelSQL, ModelView):
'get_results_reports_list', searcher='search_results_reports_list')
state = fields.Selection([
('draft', 'Draft'),
('annulled', 'Annulled'),
('pending_planning', 'Pending Planification'),
('planned', 'Planned'),
('in_lab', 'In Laboratory'),
@ -2918,14 +2919,15 @@ class Sample(ModelSQL, ModelView):
def order_state(tables):
table, _ = tables[None]
order = [Case((table.state == 'draft', 1),
else_=Case((table.state == 'pending_planning', 2),
else_=Case((table.state == 'planned', 3),
else_=Case((table.state == 'in_lab', 4),
else_=Case((table.state == 'lab_pending_acceptance', 5),
else_=Case((table.state == 'pending_report', 6),
else_=Case((table.state == 'in_report', 7),
else_=Case((table.state == 'report_released', 8),
else_=0))))))))]
else_=Case((table.state == 'annulled', 2),
else_=Case((table.state == 'pending_planning', 3),
else_=Case((table.state == 'planned', 4),
else_=Case((table.state == 'in_lab', 5),
else_=Case((table.state == 'lab_pending_acceptance', 6),
else_=Case((table.state == 'pending_report', 7),
else_=Case((table.state == 'in_report', 8),
else_=Case((table.state == 'report_released', 9),
else_=0)))))))))]
return order
def get_confirmed(self, name=None):
@ -3348,6 +3350,17 @@ class Sample(ModelSQL, ModelView):
return 'in_lab'
return 'planned'
if self.confirmation_date:
cursor.execute('SELECT COUNT(*) '
'FROM "' + NotebookLine._table + '" nl '
'INNER JOIN "' + Service._table + '" s '
'ON s.id = nl.service '
'INNER JOIN "' + Fraction._table + '" f '
'ON f.id = s.fraction '
'WHERE f.sample = %s '
'AND nl.annulled = FALSE',
(self.id,))
if cursor.fetchone()[0] == 0:
return 'annulled'
return 'pending_planning'
return 'draft'

View File

@ -2,5 +2,5 @@
<form col="2">
<image name="tryton-info" xexpand="0" xfill="0"/>
<label string="Accept all lines?" id="ask"
yalign="0.0" xalign="0.0" xexpand="1"/>
yalign="0.0" xalign="0.0"/>
</form>

View File

@ -0,0 +1,8 @@
<?xml version="1.0"?>
<form>
<image name="tryton-info" xexpand="0" xfill="0"/>
<label string="Annul all lines?"
id="ask" yalign="0.5" xalign="0.0" colspan="3"/>
<separator name="annulment_reason" colspan="4"/>
<field name="annulment_reason" colspan="4"/>
</form>

View File

@ -32,6 +32,7 @@
<field name="initial_concentration"/>
<label name="final_concentration"/>
<field name="final_concentration"/>
<newline/>
<field name="laboratory_professionals" colspan="4"/>
<label name="initial_unit"/>
<field name="initial_unit"/>
@ -84,26 +85,25 @@
<field name="literal_result"/>
<label name="rm_correction_formula"/>
<field name="rm_correction_formula"/>
<label name="report"/>
<field name="report"/>
<label name="uncertainty"/>
<field name="uncertainty"/>
<label name="verification"/>
<field name="verification"/>
<label name="accepted"/>
<field name="accepted"/>
<label name="acceptance_date"/>
<field name="acceptance_date"/>
<label name="annulled"/>
<field name="annulled"/>
<label name="annulment_date"/>
<field name="annulment_date"/>
<group id="acceptance_annulment" colspan="4" col="8">
<label name="accepted"/>
<field name="accepted"/>
<label name="acceptance_date"/>
<field name="acceptance_date"/>
<label name="annulled"/>
<field name="annulled"/>
<label name="annulment_date"/>
<field name="annulment_date"/>
</group>
<field name="annulment_reason" colspan="4" yexpand="0"/>
<label name="planification"/>
<field name="planification"/>
<label name="referral"/>
<field name="referral"/>
<label name="results_report"/>
<field name="results_report"/>
<group id="results_estimated_waiting" colspan="2" col="2">
<label name="results_estimated_waiting"/>
<field name="results_estimated_waiting"/>
@ -112,6 +112,10 @@
<label name="results_estimated_date"/>
<field name="results_estimated_date"/>
</group>
<label name="report"/>
<field name="report"/>
<label name="results_report"/>
<field name="results_report"/>
<label name="department"/>
<field name="department"/>
</form>

View File

@ -51,6 +51,7 @@
<field name="acceptance_date" widget="date"/>
<field name="annulled"/>
<field name="annulment_date" widget="date"/>
<field name="annulment_reason"/>
<field name="results_report"/>
<field name="planification"/>
<field name="referral"/>

View File

@ -32,8 +32,6 @@
<field name="initial_concentration"/>
<label name="final_concentration"/>
<field name="final_concentration"/>
<label name="planification"/>
<field name="planification"/>
<newline/>
<field name="laboratory_professionals" colspan="2"/>
<field name="controls" colspan="2"/>
@ -93,25 +91,26 @@
<field name="literal_result"/>
<label name="rm_correction_formula"/>
<field name="rm_correction_formula"/>
<label name="report"/>
<field name="report"/>
<label name="uncertainty"/>
<field name="uncertainty"/>
<label name="verification"/>
<field name="verification"/>
<label name="accepted"/>
<field name="accepted"/>
<label name="acceptance_date"/>
<field name="acceptance_date"/>
<group id="acceptance_annulment" colspan="4" col="8">
<label name="accepted"/>
<field name="accepted"/>
<label name="acceptance_date"/>
<field name="acceptance_date"/>
<label name="annulled"/>
<field name="annulled"/>
<label name="annulment_date"/>
<field name="annulment_date"/>
</group>
<field name="not_accepted_message" colspan="4" yexpand="0"/>
<label name="annulled"/>
<field name="annulled"/>
<label name="annulment_date"/>
<field name="annulment_date"/>
<field name="annulment_reason" colspan="4" yexpand="0"/>
<label name="planification"/>
<field name="planification"/>
<label name="referral"/>
<field name="referral"/>
<label name="results_report"/>
<field name="results_report"/>
<group id="results_estimated_waiting" colspan="2" col="2">
<label name="results_estimated_waiting"/>
<field name="results_estimated_waiting"/>
@ -120,6 +119,10 @@
<label name="results_estimated_date"/>
<field name="results_estimated_date"/>
</group>
<label name="report"/>
<field name="report"/>
<label name="results_report"/>
<field name="results_report"/>
<label name="department"/>
<field name="department"/>
</form>