Mercurial > hgweb > health
changeset 5017:d6b0bef9be39
health_insurance: migrate raise_user_error methods
| author | Luis Falcon <falcon@gnuhealth.org> |
|---|---|
| date | Mon, 24 Jan 2022 17:40:14 +0000 |
| parents | e41ff2ee6026 |
| children | 16fdaa03b02b |
| files | tryton/health_insurance/data/messages/messages.xml tryton/health_insurance/exceptions.py tryton/health_insurance/wizard/wizard_health_insurance.py |
| diffstat | 3 files changed, 34 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/tryton/health_insurance/data/messages/messages.xml +++ b/tryton/health_insurance/data/messages/messages.xml @@ -4,10 +4,19 @@ <tryton> <data grouped="1"> <record model="ir.message" id="msg_pct_out_of_range"> - <field name="text">Percentage out of range [0-100]</field> + <field name="text">SM-INSURANCE-0001: Percentage out of range [0-100]</field> </record> <record model="ir.message" id="msg_discount_without_element"> - <field name="text">You need to associate a product or category to the discount</field> + <field name="text">SM-INSURANCE-0002: You need to associate a product or category to the discount</field> + </record> + <record model="ir.message" id="msg_service_invoiced"> + <field name="text">SM-INSURANCE-0003: The service has been invoiced</field> + </record> + <record model="ir.message" id="msg_no_invoice_address"> + <field name="text">SM-INSURANCE-0004: No address associated to the invoice</field> + </record> + <record model="ir.message" id="msg_no_payment_term"> + <field name="text">SM-INSURANCE-0005: No payment term</field> </record> </data> </tryton>
--- a/tryton/health_insurance/exceptions.py +++ b/tryton/health_insurance/exceptions.py @@ -1,6 +1,6 @@ # 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, UserWarning +from trytond.exceptions import UserError from trytond.model.exceptions import ValidationError @@ -12,3 +12,13 @@ pass +class ServiceInvoiced(UserError): + pass + + +class NoInvoiceAddress(UserError): + pass + + +class NoPaymentTerm(UserError): + pass
--- a/tryton/health_insurance/wizard/wizard_health_insurance.py +++ b/tryton/health_insurance/wizard/wizard_health_insurance.py @@ -25,7 +25,8 @@ from trytond.wizard import Wizard from trytond.transaction import Transaction from trytond.pool import Pool - +from trytond.i18n import gettext +from ..exceptions import (ServiceInvoiced, NoInvoiceAddress, NoPaymentTerm) __all__ = ['CreateServiceInvoice'] @@ -80,7 +81,9 @@ # Invoice Header for service in services: if service.state == 'invoiced': - self.raise_user_error('duplicate_invoice') + raise ServiceInvoiced( + gettext('health_insurance.msg_service_invoiced') + ) if service.invoice_to: party = service.invoice_to else: @@ -117,12 +120,17 @@ party_address = Party.address_get(party, type='invoice') if not party_address: - self.raise_user_error('no_invoice_address') + raise NoInvoiceAddress( + gettext('health_insurance.msg_no_invoice_address') + ) + invoice_data['invoice_address'] = party_address.id invoice_data['reference'] = service.name if not party.customer_payment_term: - self.raise_user_error('no_payment_term') + raise NoPaymentTerm( + gettext('health_insurance.msg_no_payment_term') + ) invoice_data['payment_term'] = party.customer_payment_term.id
