Clientside error with my code

Hi,
I trying to finishing developing the association module, but i stumble this roadblock.

Context

tryton==5.2.2
trytond==5.2.2
trytond-account==5.2.2
trytond-association==5.2.0
trytond-company==5.2.0
trytond-country==5.2.0
trytond-currency==5.2.0
trytond-party==5.2.0
Werkzeug==0.15.4

databse: sqlite (setup with trytond-admin --all and trytond-admin -u association --activate-dependencies)
When trying to connect to my sqlite db (and before i can input the password)with the admin user i get this error:

Tryton client:

ERROR:tryton.common.common:Traceback (most recent call last):
  File "/home/wifasoi/.local/lib/python3.7/site-packages/tryton/gui/main.py", line 279, in do_activate
    common.Login()
  File "/home/wifasoi/.local/lib/python3.7/site-packages/tryton/common/common.py", line 899, in __init__
    func(parameters)
  File "/home/wifasoi/.local/lib/python3.7/site-packages/tryton/rpc.py", line 87, in login
    result = connection.common.db.login(username, parameters, language)
  File "/usr/lib/python3.7/xmlrpc/client.py", line 1112, in __call__
    return self.__send(self.__name, args)
  File "/home/wifasoi/.local/lib/python3.7/site-packages/tryton/jsonrpc.py", line 306, in __request
    raise Fault(*response['error'])
tryton.jsonrpc.Fault

Fault: 

Server logs (-vvvv):

8357 140350123853440 [2019-07-13 22:15:45,900] DEBUG passlib.utils.compat loaded lazy attr 'SafeConfigParser': <class 'configparser.ConfigParser'>
8357 140350123853440 [2019-07-13 22:15:45,900] DEBUG passlib.utils.compat loaded lazy attr 'NativeStringIO': <class '_io.StringIO'>
8357 140350123853440 [2019-07-13 22:15:45,900] DEBUG passlib.utils.compat loaded lazy attr 'BytesIO': <class '_io.BytesIO'>
8357 140350123853440 [2019-07-13 22:15:45,904] DEBUG passlib.registry registered 'pbkdf2_sha512' handler: <class 'passlib.handlers.pbkdf2.pbkdf2_sha512'>
8357 140350123853440 [2019-07-13 22:15:45,934] INFO trytond.modules ir:registering classes
8357 140350123853440 [2019-07-13 22:15:45,934] INFO trytond.modules res:registering classes
8357 140350123853440 [2019-07-13 22:15:45,934] INFO trytond.modules country:registering classes
8357 140350123853440 [2019-07-13 22:15:45,935] INFO trytond.modules currency:registering classes
8357 140350123853440 [2019-07-13 22:15:45,936] INFO trytond.modules tests:registering classes
8357 140350123853440 [2019-07-13 22:15:45,936] INFO trytond.modules party:registering classes
8357 140350123853440 [2019-07-13 22:15:45,941] INFO trytond.modules company:registering classes
8357 140350123853440 [2019-07-13 22:15:45,943] INFO trytond.modules account:registering classes
8357 140350123853440 [2019-07-13 22:15:45,960] INFO trytond.modules association:registering classes
8357 140350123853440 [2019-07-13 22:15:45,971] INFO werkzeug  * Running on http://localhost:8000/ (Press CTRL+C to quit)
8357 140350123853440 [2019-07-13 22:15:45,973] INFO werkzeug  * Restarting with stat
8361 140612299183744 [2019-07-13 22:15:46,240] DEBUG passlib.utils.compat loaded lazy attr 'SafeConfigParser': <class 'configparser.ConfigParser'>
8361 140612299183744 [2019-07-13 22:15:46,240] DEBUG passlib.utils.compat loaded lazy attr 'NativeStringIO': <class '_io.StringIO'>
8361 140612299183744 [2019-07-13 22:15:46,240] DEBUG passlib.utils.compat loaded lazy attr 'BytesIO': <class '_io.BytesIO'>
8361 140612299183744 [2019-07-13 22:15:46,244] DEBUG passlib.registry registered 'pbkdf2_sha512' handler: <class 'passlib.handlers.pbkdf2.pbkdf2_sha512'>
8361 140612299183744 [2019-07-13 22:15:46,278] INFO trytond.modules ir:registering classes
8361 140612299183744 [2019-07-13 22:15:46,278] INFO trytond.modules res:registering classes
8361 140612299183744 [2019-07-13 22:15:46,278] INFO trytond.modules country:registering classes
8361 140612299183744 [2019-07-13 22:15:46,279] INFO trytond.modules currency:registering classes
8361 140612299183744 [2019-07-13 22:15:46,280] INFO trytond.modules tests:registering classes
8361 140612299183744 [2019-07-13 22:15:46,280] INFO trytond.modules party:registering classes
8361 140612299183744 [2019-07-13 22:15:46,287] INFO trytond.modules company:registering classes
8361 140612299183744 [2019-07-13 22:15:46,290] INFO trytond.modules account:registering classes
8361 140612299183744 [2019-07-13 22:15:46,306] INFO trytond.modules association:registering classes
8361 140612240463616 [2019-07-13 22:15:49,841] INFO werkzeug 127.0.0.1 - - [13/Jul/2019 22:15:49] "POST / HTTP/1.1" 200 -
8361 140612240463616 [2019-07-13 22:15:50,194] DEBUG trytond.backend.sqlite.database PRAGMA foreign_keys = ON
8361 140612240463616 [2019-07-13 22:15:50,194] DEBUG trytond.backend.sqlite.database PRAGMA foreign_keys = ON
8361 140612240463616 [2019-07-13 22:15:50,194] INFO trytond.pool init pool for "test2"
8361 140612240463616 [2019-07-13 22:15:50,195] DEBUG trytond.backend.sqlite.database PRAGMA foreign_keys = ON
8361 140612240463616 [2019-07-13 22:15:50,196] DEBUG trytond.backend.sqlite.database SELECT sql FROM sqlite_master WHERE type = 'table' AND name = 'ir_module_module'
8361 140612240463616 [2019-07-13 22:15:50,196] DEBUG trytond.backend.sqlite.database SELECT "a"."name" FROM "ir_module" AS "a" WHERE ("a"."state" IN ('installed', 'uninstalled'))
8361 140612240463616 [2019-07-13 22:15:50,196] DEBUG trytond.backend.sqlite.database SELECT "a"."name" FROM "ir_module" AS "a" WHERE ("a"."state" IN ('activated', 'to upgrade', 'to remove'))
8361 140612240463616 [2019-07-13 22:15:50,199] DEBUG trytond.backend.sqlite.database SELECT "a"."code", "a"."parent" FROM "ir_lang" AS "a"
8361 140612240463616 [2019-07-13 22:15:50,199] DEBUG trytond.backend.sqlite.database SELECT "a"."name", "a"."state" FROM "ir_module" AS "a" WHERE ("a"."name" IN ('ir', 'res', 'country', 'currency', 'party', 'company', 'account', 'association'))
8361 140612240463616 [2019-07-13 22:15:50,199] INFO trytond.modules ir
8361 140612240463616 [2019-07-13 22:15:50,200] INFO trytond.modules res
8361 140612240463616 [2019-07-13 22:15:50,200] INFO trytond.modules country
8361 140612240463616 [2019-07-13 22:15:50,200] INFO trytond.modules currency
8361 140612240463616 [2019-07-13 22:15:50,200] INFO trytond.modules party
8361 140612240463616 [2019-07-13 22:15:50,200] INFO trytond.modules company
8361 140612240463616 [2019-07-13 22:15:50,200] INFO trytond.modules account
8361 140612240463616 [2019-07-13 22:15:50,201] INFO trytond.modules association
8361 140612240463616 [2019-07-13 22:15:50,201] INFO trytond.pool setup pool for "test2"
8361 140612240463616 [2019-07-13 22:15:50,393] INFO werkzeug 127.0.0.1 - - [13/Jul/2019 22:15:50] "POST /test2/ HTTP/1.1" 200 -

Notes

The unit test will run just fine, but when the client is involved, it crashes with this error (and I’m clueless to what line of code/xml can be the culprit)

This error presents itself only when I install my module (so I fucked up in some way), but I’m clueless what is causing it (the stack trace is not helpful).

Before the 5.2.2 release the client was happy (5.2.0), now every version of my code it will crash.

sources: https://codereview.tryton.org/277491002/

If you know what are the possible causes of this error please tell me, so I’ll be able to pinpoint the issue.
Thanks in advance.

I can not activate the module with PostgreSQL backend. Some foreign keys are wrong.
I recommend to always test from time to time with PostgreSQL backend because it is more strict and less lazy than SQLite.

Yep the PostgreSQL backed gave me a more verbose error. It was a problem with some ir.action.act_window.view keys. Now I’m working for a fix.
Thank you very much.

After some change in the xml files, I can load the module in PostgreSQL DB…
but the client will still crash with the same error. So maybe this was non correlated (but still a bug)
If you want see the patch, you can download the diff here: https://git.mittelab.org/snippets/26
Unfortunately I don’t have time today to check and send the patch into the code-review site.

Uploaded the fix, but after the same error occur… sometimes the client it give me this instead of the empty one:

ERROR:tryton.common.common:Traceback (most recent call last):
  File "/home/wifasoi/.local/share/virtualenvs/ass-Cb7cpHyS/lib/python3.7/site-packages/tryton/gui/main.py", line 279, in do_activate
    common.Login()
  File "/home/wifasoi/.local/share/virtualenvs/ass-Cb7cpHyS/lib/python3.7/site-packages/tryton/common/common.py", line 900, in __init__
    func(parameters)
  File "/home/wifasoi/.local/share/virtualenvs/ass-Cb7cpHyS/lib/python3.7/site-packages/tryton/rpc.py", line 87, in login
    result = connection.common.db.login(username, parameters, language)
  File "/usr/lib64/python3.7/xmlrpc/client.py", line 1112, in __call__
    return self.__send(self.__name, args)
  File "/home/wifasoi/.local/share/virtualenvs/ass-Cb7cpHyS/lib/python3.7/site-packages/tryton/jsonrpc.py", line 305, in __request
    raise Fault(*response['error'])
tryton.jsonrpc.Fault: type object 'res.user' has no attribute '_fields'

Fault: type object 'res.user' has no attribute '_fields'

What are the logs on the server side (with maximum level)?

sorry for the late reply. <insert random excuse about work and life in general>

Still don’t know what cold be going wrong.

the server side log (-vvvvvv) for thwo login attempt

30534 140125184730752 [2019-07-21 13:59:35,657] DEBUG passlib.utils.compat loaded lazy attr 'SafeConfigParser': <class 'configparser.ConfigParser'>
30534 140125184730752 [2019-07-21 13:59:35,658] DEBUG passlib.utils.compat loaded lazy attr 'NativeStringIO': <class '_io.StringIO'>
30534 140125184730752 [2019-07-21 13:59:35,658] DEBUG passlib.utils.compat loaded lazy attr 'BytesIO': <class '_io.BytesIO'>
30534 140125184730752 [2019-07-21 13:59:35,661] DEBUG passlib.registry registered 'bcrypt' handler: <class 'passlib.handlers.bcrypt.bcrypt'>
30534 140125184730752 [2019-07-21 13:59:35,663] DEBUG passlib.registry registered 'pbkdf2_sha512' handler: <class 'passlib.handlers.pbkdf2.pbkdf2_sha512'>
30534 140125184730752 [2019-07-21 13:59:35,680] INFO trytond.modules ir:registering classes
30534 140125184730752 [2019-07-21 13:59:35,680] INFO trytond.modules res:registering classes
30534 140125184730752 [2019-07-21 13:59:35,680] INFO trytond.modules country:registering classes
30534 140125184730752 [2019-07-21 13:59:35,681] INFO trytond.modules currency:registering classes
30534 140125184730752 [2019-07-21 13:59:35,682] INFO trytond.modules tests:registering classes
30534 140125184730752 [2019-07-21 13:59:35,682] INFO trytond.modules party:registering classes
30534 140125184730752 [2019-07-21 13:59:35,687] INFO trytond.modules company:registering classes
30534 140125184730752 [2019-07-21 13:59:35,689] INFO trytond.modules account:registering classes
30534 140125184730752 [2019-07-21 13:59:35,704] INFO trytond.modules association:registering classes
30534 140125184730752 [2019-07-21 13:59:35,715] INFO werkzeug  * Running on http://localhost:8000/ (Press CTRL+C to quit)
30534 140125095671552 [2019-07-21 13:59:41,987] INFO werkzeug 127.0.0.1 - - [21/Jul/2019 13:59:41] "POST / HTTP/1.1" 200 -
30534 140125095671552 [2019-07-21 13:59:42,735] INFO trytond.backend.postgresql.database connect to "tryton2"
30534 140125095671552 [2019-07-21 13:59:42,737] INFO trytond.pool init pool for "tryton2"
30534 140125095671552 [2019-07-21 13:59:42,741] DEBUG trytond.backend.postgresql.database b'SHOW search_path'
30534 140125095671552 [2019-07-21 13:59:42,743] DEBUG trytond.backend.postgresql.database b'SELECT current_user'
30534 140125095671552 [2019-07-21 13:59:42,743] DEBUG trytond.backend.postgresql.database b"SELECT 1 FROM information_schema.tables WHERE table_name = 'ir_module_module' AND table_schema = 'wifasoi'"
30534 140125095671552 [2019-07-21 13:59:42,745] DEBUG trytond.backend.postgresql.database b"SELECT 1 FROM information_schema.tables WHERE table_name = 'ir_module_module' AND table_schema = 'public'"
30534 140125095671552 [2019-07-21 13:59:42,746] DEBUG trytond.backend.postgresql.database b'SELECT "a"."name" FROM "ir_module" AS "a" WHERE ("a"."state" IN (\'installed\', \'uninstalled\'))'
30534 140125095671552 [2019-07-21 13:59:42,747] DEBUG trytond.backend.postgresql.database b'SELECT "a"."name" FROM "ir_module" AS "a" WHERE ("a"."state" IN (\'activated\', \'to upgrade\', \'to remove\'))'
30534 140125095671552 [2019-07-21 13:59:42,749] DEBUG trytond.backend.postgresql.database b'SELECT "a"."code", "a"."parent" FROM "ir_lang" AS "a"'
30534 140125095671552 [2019-07-21 13:59:42,750] DEBUG trytond.backend.postgresql.database b'SELECT "a"."name", "a"."state" FROM "ir_module" AS "a" WHERE ("a"."name" IN (\'ir\', \'res\', \'country\', \'currency\', \'party\', \'company\', \'account\', \'association\'))'
30534 140125095671552 [2019-07-21 13:59:42,750] INFO trytond.modules ir
30534 140125095671552 [2019-07-21 13:59:42,751] INFO trytond.modules res
30534 140125095671552 [2019-07-21 13:59:42,751] INFO trytond.modules country
30534 140125095671552 [2019-07-21 13:59:42,751] INFO trytond.modules currency
30534 140125095671552 [2019-07-21 13:59:42,751] INFO trytond.modules party
30534 140125095671552 [2019-07-21 13:59:42,751] INFO trytond.modules company
30534 140125095671552 [2019-07-21 13:59:42,752] INFO trytond.modules account
30534 140125095671552 [2019-07-21 13:59:42,752] INFO trytond.modules association
30534 140125095671552 [2019-07-21 13:59:42,752] INFO trytond.pool setup pool for "tryton2"
30534 140125095671552 [2019-07-21 13:59:42,975] INFO werkzeug 127.0.0.1 - - [21/Jul/2019 13:59:42] "POST /tryton2/ HTTP/1.1" 200 -
30534 140125095671552 [2019-07-21 14:00:18,063] INFO werkzeug 127.0.0.1 - - [21/Jul/2019 14:00:18] "POST / HTTP/1.1" 200 -
30534 140125095671552 [2019-07-21 14:00:18,845] DEBUG trytond.backend.postgresql.database b'SELECT COUNT(\'*\') FROM "res_user_login_attempt" AS "a" WHERE (("a"."ip_network" = \'127.0.0.1/32\') AND ("a"."create_date" >= \'2019-07-21T13:55:18.845316\'::timestamp))'
30534 140125095671552 [2019-07-21 14:00:18,846] DEBUG trytond.backend.postgresql.database b'SELECT COUNT(\'*\') FROM "res_user_login_attempt" AS "a" WHERE (("a"."login" = \'admin\') AND ("a"."create_date" >= \'2019-07-21T13:55:18.846696\'::timestamp))'
30534 140125095671552 [2019-07-21 14:00:18,848] INFO werkzeug 127.0.0.1 - - [21/Jul/2019 14:00:18] "POST /tryton2/ HTTP/1.1" 200 -

The first login (client side)

ERROR:tryton.common.common:Traceback (most recent call last):
  File "/home/wifasoi/.local/share/virtualenvs/ass-Cb7cpHyS/lib/python3.7/site-packages/tryton/gui/main.py", line 279, in do_activate
    common.Login()
  File "/home/wifasoi/.local/share/virtualenvs/ass-Cb7cpHyS/lib/python3.7/site-packages/tryton/common/common.py", line 900, in __init__
    func(parameters)
  File "/home/wifasoi/.local/share/virtualenvs/ass-Cb7cpHyS/lib/python3.7/site-packages/tryton/rpc.py", line 87, in login
    result = connection.common.db.login(username, parameters, language)
  File "/usr/lib64/python3.7/xmlrpc/client.py", line 1112, in __call__
    return self.__send(self.__name, args)
  File "/home/wifasoi/.local/share/virtualenvs/ass-Cb7cpHyS/lib/python3.7/site-packages/tryton/jsonrpc.py", line 305, in __request
    raise Fault(*response['error'])
tryton.jsonrpc.Fault

Fault: 

The second login attempt (client side):

ERROR:tryton.common.common:Traceback (most recent call last):
  File "/home/wifasoi/.local/share/virtualenvs/ass-Cb7cpHyS/lib/python3.7/site-packages/tryton/gui/main.py", line 279, in do_activate
    common.Login()
  File "/home/wifasoi/.local/share/virtualenvs/ass-Cb7cpHyS/lib/python3.7/site-packages/tryton/common/common.py", line 900, in __init__
    func(parameters)
  File "/home/wifasoi/.local/share/virtualenvs/ass-Cb7cpHyS/lib/python3.7/site-packages/tryton/rpc.py", line 87, in login
    result = connection.common.db.login(username, parameters, language)
  File "/usr/lib64/python3.7/xmlrpc/client.py", line 1112, in __call__
    return self.__send(self.__name, args)
  File "/home/wifasoi/.local/share/virtualenvs/ass-Cb7cpHyS/lib/python3.7/site-packages/tryton/jsonrpc.py", line 305, in __request
    raise Fault(*response['error'])
tryton.jsonrpc.Fault: type object 'res.user' has no attribute '_fields'

Fault: type object 'res.user' has no attribute '_fields'

I downloaded the code from the review and managed to login to a fresh created database. The only error I found was what I commented here. Fixing it should allow you to access the database.

I confirm, it was that.
I’ll forever grateful for this lifeline. Thank you very much
TL;DR: do not use trytond.i18n.gettext inside _sql_constraints

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.