Issue 10334

Title
Duplicated code in languages administration
Priority
bug
Status
testing
Nosy list
ced, mrichez, pokoli, reviewbot, tbruyere
Assigned to
mrichez
Keywords
review

Created on 2021-04-23.10:37:15 by tbruyere, last changed 6 days ago by reviewbot.

Messages

Author: [hidden] (mrichez)
Date: 2021-05-02.19:49:49

Should solve the problem.

Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2021-05-02.09:55:55

I guess we should add a unique constraint on the language code.

Author: [hidden] (tbruyere)
Date: 2021-04-23.10:37:15

It is possible to create a new language in Administration / Localization / Languages.
If use a language code already present, there is no duplication control.

Tested with code : en

An error is generated during save, but it is still possible to use this new language for a user.

ERROR:tryton.common.common:Traceback (most recent call last):
File "/trytond/wsgi.py", line 116, in dispatch_request
return endpoint(request, request.view_args)
File "/trytond/protocols/dispatcher.py", line 48, in rpc
request, database_name, request.rpc_params)
File "/trytond/wsgi.py", line 83, in auth_required
return wrapped(args, kwargs)
File "/trytond/protocols/wrappers.py", line 136, in wrapper
return func(request, pool, *args, *kwargs)
File "/trytond/protocols/dispatcher.py", line 181, in _dispatch
result = rpc.result(meth(c_args, **c_kwargs))
File "/trytond/model/modelsql.py", line 868, in read
sub_ids, cls, field_list, values=sub_results)
File "/trytond/model/fields/function.py", line 105, in get
return dict((name, call(name)) for name in names)
File "/trytond/model/fields/function.py", line 105, in <genexpr>
return dict((name, call(name)) for name in names)
File "/trytond/model/fields/function.py", line 100, in call
return dict((r.id, method(r, name)) for r in records)
File "/trytond/model/fields/function.py", line 100, in <genexpr>
return dict((r.id, method(r, name)) for r in records)
File "/trytond/modules/purchase/purchase.py", line 1692, in get_rec_name
lang = Lang.get()
File "/trytond/ir/lang.py", line 362, in get
('code', '=', code),
ValueError: too many values to unpack (expected 1)

Fault: too many values to unpack (expected 1)

If a user chooses this language in this preferences, the GTK client crashes (no longer responds)

History
Date User Action Args
2021-05-03 22:15:05reviewbotsetmessages: + msg67348
2021-05-02 21:18:20reviewbotsetmessages: + msg67329
nosy: + reviewbot
2021-05-02 21:07:57mrichezsetkeyword: + review
reviews: 334301004
status: in-progress -> testing
2021-05-02 21:03:02mrichezsetassignedto: mrichez
2021-05-02 21:02:47mrichezsetstatus: chatting -> in-progress
2021-05-02 19:49:49mrichezsetmessages: + msg67328
2021-05-02 09:55:55cedsetmessages: + msg67147
nosy: + ced
status: unread -> chatting
2021-04-23 11:17:48pokolisetnosy: + pokoli
2021-04-23 10:37:15tbruyerecreate