bugGNU Health - Bugs: bug #43048, Assertion Error with datetime, it...

 
 

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

bug #43048: Assertion Error with datetime, it does not possible install health module

Submitter:  oscar alvarez <oscar_alv>
Submitted:  Fri 22 Aug 2014 04:08:11 AM UTC
   
 
Category:  Installation Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  meanmicio
Open/Closed:  Closed Release:  2.7.0
Module:  health Component:  None

Sun 24 Aug 2014 06:12:26 PM UTC, comment #5: 

Just to double check. This is a newly created party, with the default activation date on the current GNU Health.

health26=# select name, activation_date from party_party;
          name          | activation_date
------------------------+-----------------
 Rejon                  | 2014-08-24

No issues found when creating a new party and assigning it a default activation date.

But you are right, the type should be datetime.date, so no need for type casting . I just commit the changes to the default branch

Thanks Oscar !

Luis Falcon <meanmicio>
Group administrator
Sun 24 Aug 2014 04:47:04 PM UTC, comment #4: 

I know is a fields.Date, and we'll use datetime.date.today() in 2.8.

What I'm saying is that is type casting it correctly, from datetime to date. Otherwise nobody would be able to use GNU Health today :)

Thanks

Luis Falcon <meanmicio>
Group administrator
Sun 24 Aug 2014 03:26:22 PM UTC, comment #3: 

The field activation_date, require date type in this model:

    activation_date = fields.Date(
        'Activation date', help='Date of activation of the party')


But with this simple test, you can see that fail, default method.

line 24 health.py file:

>>> from datetime import datetime, timedelta


line 300 health.py file:

>>> datetime.today()

datetime.datetime(2014, 8, 24, 10, 18, 28, 424916)


    @staticmethod
    def default_activation_date():
        return datetime.today()

The problem is that datetime.today() return datetime not date as the field expect.

oscar alvarez <oscar_alv>
Sun 24 Aug 2014 10:39:54 AM UTC, comment #2: 

Is type casting correctly to date - datetime.date.today() - .

Please check on the community server health.gnusolidario.org:8000 and let me know if you can reproduce the error.

For 2.8, we will your dateime.date.today anyways.

Thanks !

Luis Falcon <meanmicio>
Group administrator
Fri 22 Aug 2014 09:49:35 PM UTC, comment #1: 

I attached a patch that fix the value returned my default method, the right value type is Date, not Datetime.

oscar alvarez <oscar_alv>
Fri 22 Aug 2014 04:08:11 AM UTC, original submission:  

I installed tryton 3.2 and several basic official modules, so next I try install  only the health module, with

$trytond -d DATABASENAME -u health

I get this:

[Fri Aug 22 03:34:59 2014] INFO:modules:health
[Fri Aug 22 03:34:59 2014] INFO:modules:health:register gnuhealth.operational_area
[Fri Aug 22 03:35:01 2014] INFO:modules:health:register gnuhealth.operational_sector
[Fri Aug 22 03:35:01 2014] INFO:modules:health:register gnuhealth.du
[Fri Aug 22 03:35:02 2014] INFO:modules:health:register gnuhealth.occupation
[Fri Aug 22 03:35:02 2014] INFO:modules:health:register gnuhealth.ethnicity
[Fri Aug 22 03:35:02 2014] INFO:modules:health:register party.party
Traceback (most recent call last):
  File "/home/oscar/.virtualenvs/gnu_tryton32/bin/trytond", line 113, in <module>
    trytond.server.TrytonServer(options).run()
  File "/home/oscar/.virtualenvs/gnu_tryton32/local/lib/python2.7/site-packages/trytond/server.py", line 123, in run
    Pool(db_name).init(update=update, lang=lang)
  File "/home/oscar/.virtualenvs/gnu_tryton32/local/lib/python2.7/site-packages/trytond/pool.py", line 151, in init
    lang=lang)
  File "/home/oscar/.virtualenvs/gnu_tryton32/local/lib/python2.7/site-packages/trytond/modules/__init__.py", line 429, in load_modules
    _load_modules()
  File "/home/oscar/.virtualenvs/gnu_tryton32/local/lib/python2.7/site-packages/trytond/modules/__init__.py", line 397, in _load_modules
    load_module_graph(graph, pool, lang)
  File "/home/oscar/.virtualenvs/gnu_tryton32/local/lib/python2.7/site-packages/trytond/modules/__init__.py", line 237, in load_module_graph
    cls.__register__(module)
  File "/home/oscar/.virtualenvs/gnu_tryton32/local/lib/python2.7/site-packages/trytond/modules/health/health.py", line 386, in _register_
    super(PartyPatient, cls).__register__(module_name)
  File "/home/oscar/.virtualenvs/gnu_tryton32/local/lib/python2.7/site-packages/trytond/model/modelsql.py", line 112, in _register_
    default_fun, field_size, string=field.string)
  File "/home/oscar/.virtualenvs/gnu_tryton32/local/lib/python2.7/site-packages/trytond/backend/postgresql/table.py", line 270, in add_raw_column
    (column_format(default),))
  File "/home/oscar/.virtualenvs/gnu_tryton32/local/lib/python2.7/site-packages/trytond/model/fields/date.py", line 31, in sql_format
    or value.time() == datetime.time())
AssertionError

So trying from ui I get the same message.

So all modules was installed with pip, including trytond_health


oscar alvarez <oscar_alv>

 

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

Attached Files
file #31936:  patch_43048.diff added by oscar_alv (400B - text/x-patch - Attached tested patch)

 

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 oscar_alv (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 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-08-24 meanmicio ReleaseNone 2.7.0
    2014-08-24 meanmicio StatusNeed Info Fixed
        Open/ClosedOpen Closed
    2014-08-24 meanmicio StatusNone Need Info
        Assigned toNone meanmicio
    2014-08-22 oscar_alv Attached File- Added patch_43048.diff, #31936

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code