Issue 10413

Title
Setting a translatable Char field with an SQL expression mess with its translation
Priority
bug
Status
unread
Nosy list
nicoe
Assigned to
Keywords

Created on 2021-05-12.11:39:35 by nicoe, last changed 1 month ago by nicoe.

Messages

Author: [hidden] (nicoe) Tryton committer
Date: 2021-05-12.11:39:34

Here is the traceback (it only happens with the patch I made for issue7914 because it overrides __set__ but the issue is there anyway):

Traceback (most recent call last):
  File "/home/nicoe/projets/tryton/tryton-env/TrimCharField-[issue7914](issue7914)/trytond/trytond/tests/test_tryton.py", line 203, in wrapper
    result = func(*args, **kwargs)
  File "/home/nicoe/projets/tryton/tryton-env/TrimCharField-[issue7914](issue7914)/trytond/trytond/tests/test_field_char.py", line 49, in test_create_with_sql_value
    char, = Char.create([{'char': Literal('Foo')}])
  File "/home/nicoe/projets/tryton/tryton-env/TrimCharField-[issue7914](issue7914)/trytond/trytond/model/modelsql.py", line 159, in wrapper
    return func(cls, *args, **kwargs)
  File "/home/nicoe/projets/tryton/tryton-env/TrimCharField-[issue7914](issue7914)/trytond/trytond/model/modelsql.py", line 662, in create
    Translation.set_ids(name, 'model', Transaction().language,
  File "/home/nicoe/projets/tryton/tryton-env/TrimCharField-[issue7914](issue7914)/trytond/trytond/ir/translation.py", line 513, in set_ids
    translation.value = value
  File "/home/nicoe/projets/tryton/tryton-env/TrimCharField-[issue7914](issue7914)/trytond/trytond/model/fields/char.py", line 66, in __set__
    value = value.strip()
AttributeError: 'Literal' object has no attribute 'strip'

As a consequence it will also set an Expression value in the _values dictionary of the translation instance.
I think we should raise an Error when doing this.

History
Date User Action Args
2021-05-12 11:39:35nicoecreate

Showing 10 items. Show all history (warning: this could be VERY long)