bugGNU Health - Bugs: bug #63959, AttributeError:...


You are not allowed to post comments on this tracker with your current authentication level.

bug #63959: AttributeError: 'gnuhealth.patient' Model has no attribute 'age'

Submitter:  Mathias Behrle <yangoon>
Submitted:  Fri 24 Mar 2023 09:59:06 AM UTC
Category:  Functionality Severity:  1 - Wish
Item Group:  None Status:  Postponed
Privacy:  Public Assigned to:  None
Open/Closed:  Open Release:  None
Module:  health Component:  Hospital Management

Thu 06 Apr 2023 09:19:58 AM UTC, comment #1: 

Hi, Mathias!

We can study this for the upcoming version, and probably create a task.

As you said, currently related actions on patients need to count with the id.


Luis Falcon <meanmicio>
Group administrator
Fri 24 Mar 2023 09:59:06 AM UTC, original submission:  

This error raises when creating an evaluation with an unsaved patient:

Traceback (most recent call last):
  File "/.local/lib/python3.7/site-packages/trytond/model/model.py", line 368, in _getitem
    return getattr(self, field)
AttributeError: age

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/.local/lib/python3.7/site-packages/trytond/model/model.py", line 291, in _getattr_
    return self._values[name]
  File "/.local/lib/python3.7/site-packages/trytond/model/model.py", line 370, in _getitem
    raise KeyError(field)
KeyError: 'age'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/.local/lib/python3.7/site-packages/trytond/wsgi.py", line 117, in dispatch_request
    return endpoint(request, **request.view_args)
  File "/.local/lib/python3.7/site-packages/trytond/protocols/dispatcher.py", line 47, in rpc
    request, database_name, *request.rpc_params)
  File "/.local/lib/python3.7/site-packages/trytond/wsgi.py", line 84, in auth_required
    return wrapped(args, *kwargs)
  File "/.local/lib/python3.7/site-packages/trytond/protocols/wrappers.py", line 159, in wrapper
    return func(request, pool, args, *kwargs)
  File "/.local/lib/python3.7/site-packages/trytond/protocols/dispatcher.py", line 185, in _dispatch
    result = rpc.result(meth(inst, c_args, *c_kwargs))
  File "/.local/lib/python3.7/site-packages/trytond/model/modelview.py", line 88, in wrapper
    result = func(self, args, *kwargs)
  File "/.local/lib/python3.7/site-packages/trytond/model/fields/field.py", line 123, in wrapper
    return func(self, args, *kwargs)
  File "/.local/lib/python3.7/site-packages/trytond/modules/health/health.py", line 5019, in on_change_patient
    self.computed_age = self.patient.age
  File "/.local/lib/python3.7/site-packages/trytond/model/modelstorage.py", line 1485, in _getattr_
    return super(ModelStorage, self).__getattr__(name)
  File "/.local/lib/python3.7/site-packages/trytond/model/model.py", line 294, in _getattr_
    % (self.__name__, name, self._values))
AttributeError: 'gnuhealth.patient' Model has no attribute 'age': <trytond.model.model.gnuhealth.patient._record object at 0x7fb4e6f1d208>

While it is in currently not possible to create evaluations outside of a patient domain in Standard GNU Health (thus always requiring to save the patient beforehand) the model should nevertheless work in different contexts.

A quick fix is to skip the evaluation of unavailable properties with

    def on_change_patient(self):
        if self.patient.id > 0:

Mathias Behrle <yangoon>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by meanmicio (Posted a comment)
  • -email is unavailable- added by yangoon (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.


    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-04-06 meanmicio Severity3 - Normal 1 - Wish
        StatusNone Postponed
        ComponentNone Hospital Management

    Back to the top

    Powered by Savane 3.12.
    Corresponding source code