Mercurial > hgweb > health
changeset 5012:390333179340
health_services_imaging: migrate raise_user_error methods
| author | Luis Falcon <falcon@gnuhealth.org> |
|---|---|
| date | Mon, 24 Jan 2022 15:53:48 +0000 |
| parents | 207199fdff57 |
| children | 1dfc4388f2bf |
| files | tryton/health_services_imaging/data/messages/messages.xml tryton/health_services_imaging/exceptions.py tryton/health_services_imaging/health_services_imaging.py |
| diffstat | 3 files changed, 33 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
new file mode 100644 --- /dev/null +++ b/tryton/health_services_imaging/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_no_service_associated"> + <field name="text">SM-SERVICES_IMAGING-0001: Need to associate a service</field> + </record> + </data> +</tryton>
new file mode 100644 --- /dev/null +++ b/tryton/health_services_imaging/exceptions.py @@ -0,0 +1,10 @@ +# 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 +from trytond.model.exceptions import ValidationError + + +class NoServiceAssociated(UserError): + pass + +
--- a/tryton/health_services_imaging/health_services_imaging.py +++ b/tryton/health_services_imaging/health_services_imaging.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- ############################################################################## # # GNU Health: The Free Health and Hospital Information System @@ -19,27 +18,26 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## -import datetime -from trytond.model import ModelView, ModelSQL, fields, ModelSingleton, Unique +from trytond.model import ModelView, ModelSQL, fields from trytond.pyson import Eval, Equal from trytond.pool import Pool - +from .exceptions import (NoServiceAssociated) +from trytond.i18n import gettext __all__ = ['ImagingTestRequest'] +""" Add Imaging order charges to service model """ -""" Add Imaging order charges to service model """ class ImagingTestRequest(ModelSQL, ModelView): 'Imaging Order' __name__ = 'gnuhealth.imaging.test.request' - service = fields.Many2One( 'gnuhealth.health_service', 'Service', domain=[('patient', '=', Eval('patient'))], depends=['patient'], - states = {'readonly': Equal(Eval('state'), 'done')}, + states={'readonly': Equal(Eval('state'), 'done')}, help="Service document associated to this Imaging Request") @classmethod @@ -51,7 +49,6 @@ }, }) - @classmethod @ModelView.button def update_service(cls, imaging_orders): @@ -62,7 +59,9 @@ imaging_order = imaging_orders[0] if not imaging_order.service: - cls.raise_user_error("Need to associate a service !") + raise NoServiceAssociated( + gettext('health_service_imaging.msg_no_service_associated') + ) service_data = {} service_lines = [] @@ -75,12 +74,11 @@ 'qty': 1 }])) - hservice.append(imaging_order.service) - + description = "Services and Imaging" - - service_data ['desc'] = description - service_data ['service_line'] = service_lines - + + service_data['desc'] = description + service_data['service_line'] = service_lines + HealthService.write(hservice, service_data)
