Mercurial > hgweb > health
changeset 5015:f1112c9943c6
health_lab: migrate raise_user_error methods
| author | Luis Falcon <falcon@gnuhealth.org> |
|---|---|
| date | Mon, 24 Jan 2022 16:32:40 +0000 |
| parents | dd38f2b3301b |
| children | e41ff2ee6026 |
| files | tryton/health_lab/data/messages/messages.xml tryton/health_lab/exceptions.py tryton/health_lab/wizard/wizard_create_lab_test.py |
| diffstat | 3 files changed, 24 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
new file mode 100644 --- /dev/null +++ b/tryton/health_lab/data/messages/messages.xml @@ -0,0 +1,10 @@ +<?xml version="1.0"?> +<!-- This file is part of GNU Health. The COPYRIGHT file at the top level of +this repository contains the full copyright notices and license terms. --> +<tryton> + <data grouped="1"> + <record model="ir.message" id="msg_lab_order_exists"> + <field name="text">SM-LAB-0001: The Lab test order is already created</field> + </record> + </data> +</tryton>
new file mode 100644 --- /dev/null +++ b/tryton/health_lab/exceptions.py @@ -0,0 +1,9 @@ +# This file is part of GNU Health. The COPYRIGHT file at the top level of +# this repository contains the full copyright notices and license terms. +from trytond.exceptions import UserError + + +class LabOrderExists(UserError): + pass + +
--- a/tryton/health_lab/wizard/wizard_create_lab_test.py +++ b/tryton/health_lab/wizard/wizard_create_lab_test.py @@ -24,7 +24,8 @@ from trytond.wizard import Wizard, StateTransition, StateView, Button from trytond.transaction import Transaction from trytond.pool import Pool - +from trytond.i18n import gettext +from ..exceptions import LabOrderExists __all__ = [ 'CreateLabTestOrderInit', 'CreateLabTestOrder', 'RequestTest', @@ -66,8 +67,9 @@ test_report_data = {} if lab_test_order.state == 'ordered': - self.raise_user_error( - "The Lab test order is already created") + raise LabOrderExists( + gettext('health_lab.msg_lab_order_exists') + ) test_report_data['test'] = lab_test_order.name.id test_report_data['patient'] = lab_test_order.patient_id.id
