Mercurial > hgweb > health
changeset 5019:a6c8a690debd
health_services: Lint. Fix bug #61906: Origin name is incorrect in Created_invoice
| author | Luis Falcon <falcon@gnuhealth.org> |
|---|---|
| date | Mon, 24 Jan 2022 20:08:12 +0000 |
| parents | 16fdaa03b02b |
| children | fac8b97e841f |
| files | tryton/health_services/health_services.py |
| diffstat | 1 files changed, 34 insertions(+), 47 deletions(-) [+] |
line wrap: on
line diff
--- a/tryton/health_services/health_services.py +++ b/tryton/health_services/health_services.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- ############################################################################## # # GNU Health: The Free Health and Hospital Information System @@ -22,27 +21,21 @@ # ############################################################################## import datetime -from trytond.model import ModelView, ModelSQL, fields, ModelSingleton, \ - Unique, ValueMixin +from trytond.model import ModelView, ModelSQL, fields, Unique from trytond.transaction import Transaction from trytond.pyson import Eval, Equal from trytond.pool import Pool -from trytond import backend -from trytond.tools.multivalue import migrate_property from trytond.i18n import gettext -from trytond.pyson import Id from trytond.modules.health.core import get_institution from .exceptions import ( ServiceAlreadyInvoiced, NoServiceAssociated, NoProductAssociated, - NoInvoiceAddress, NoPaymentTerm ) __all__ = ['HealthService', 'HealthServiceLine', 'PatientPrescriptionOrder'] - class HealthService(ModelSQL, ModelView): 'Health Service' __name__ = 'gnuhealth.health_service' @@ -51,14 +44,16 @@ name = fields.Char('ID', readonly=True) desc = fields.Char('Description') - patient = fields.Many2One('gnuhealth.patient', - 'Patient', required=True, - states=STATES) + patient = fields.Many2One( + 'gnuhealth.patient', + 'Patient', required=True, + states=STATES) institution = fields.Many2One('gnuhealth.institution', 'Institution') company = fields.Many2One('company.company', 'Company') service_date = fields.Date('Date') - service_line = fields.One2Many('gnuhealth.health_service.line', + service_line = fields.One2Many( + 'gnuhealth.health_service.line', 'name', 'Service Line', help="Service Line") state = fields.Selection([ ('draft', 'Draft'), @@ -72,12 +67,12 @@ t = cls.__table__() cls._sql_constraints = [ - ('name_unique', Unique(t,t.name), + ('name_unique', Unique(t, t.name), 'The Service ID must be unique'), ] cls._buttons.update({ - 'button_set_to_draft': {'invisible': Equal(Eval('state'), - 'draft')} + 'button_set_to_draft': { + 'invisible': Equal(Eval('state'), 'draft')} }) cls._order.insert(0, ('state', 'ASC')) @@ -104,7 +99,6 @@ def button_set_to_draft(cls, services): cls.write(services, {'state': 'draft'}) - @classmethod def generate_code(cls, **pattern): Config = Pool().get('gnuhealth.sequences') @@ -127,10 +121,12 @@ 'Health Service' __name__ = 'gnuhealth.health_service.line' - name = fields.Many2One('gnuhealth.health_service', 'Service', + name = fields.Many2One( + 'gnuhealth.health_service', 'Service', readonly=True) desc = fields.Char('Description', required=True) - appointment = fields.Many2One('gnuhealth.appointment', 'Appointment', + appointment = fields.Many2One( + 'gnuhealth.appointment', 'Appointment', help='Enter or select the date / ID of the appointment related to' ' this evaluation') to_invoice = fields.Boolean('Invoice') @@ -138,11 +134,12 @@ qty = fields.Integer('Qty') from_date = fields.Date('From') to_date = fields.Date('To') - action_required = fields.Boolean('Action required', help='This optional field' - ' is used in the context of validation' - ' on the service line. Mark it if there' - ' is any administrative or other type' - ' that needs action') + action_required = fields.Boolean( + 'Action required', help='This optional field' + ' is used in the context of validation' + ' on the service line. Mark it if there' + ' is any administrative or other type' + ' that needs action') remarks = fields.Char('Remarks') @@ -159,7 +156,6 @@ if self.product: self.desc = self.product.name - @classmethod def validate(cls, services): super(HealthServiceLine, cls).validate(services) @@ -172,9 +168,11 @@ raise ServiceAlreadyInvoiced( gettext('health_service.msg_service_already_invoiced')) + def get_rec_name(self, name): + if self.name: + return f'{self.desc} ({self.name.name})' -""" Add Prescription order charges to service model """ - +# Add Prescription order charges to service model class PatientPrescriptionOrder(ModelSQL, ModelView): 'Prescription Order' __name__ = 'gnuhealth.prescription.order' @@ -182,7 +180,7 @@ 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 prescription") @classmethod @@ -194,7 +192,6 @@ }, }) - @classmethod @ModelView.button def update_service(cls, prescriptions): @@ -208,7 +205,6 @@ raise NoServiceAssociated( gettext('health_service.msg_no_service_associated')) - service_data = {} service_lines = [] @@ -221,20 +217,18 @@ 'qty': line.quantity }])) - hservice.append(prescription.service) - + description = "Services including " + \ prescription.prescription_id - - 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) -""" Include Patient Evaluation service""" - +# Include Patient Evaluation service class PatientEvaluation(ModelSQL, ModelView): 'Patient Evaluation' __name__ = 'gnuhealth.patient.evaluation' @@ -242,12 +236,11 @@ 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 evaluation") product = fields.Many2One('product.product', 'Product') - @classmethod def __setup__(cls): super(PatientEvaluation, cls).__setup__() @@ -257,7 +250,6 @@ }, }) - @classmethod @ModelView.button def update_service(cls, evaluations): @@ -275,7 +267,6 @@ raise NoProductAssociated( gettext('health_service.msg_no_product_associated')) - service_data = {} service_lines = [] @@ -287,14 +278,10 @@ 'qty': 1 }])) - hservice.append(evaluation.service) description = "Medical evaluation services" - 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) - - -
