Setting a translatable Char field with an SQL expression mess with its translation
Here is the traceback (it only happens with the patch I made for #7914 (closed) because it overrides __set__
but the issue is there anyway):
Traceback (most recent call last):
File "/home/nicoe/projets/tryton/tryton-env/TrimCharField-#7914/trytond/trytond/tests/test_tryton.py", line 203, in wrapper
result = func(*args, **kwargs)
File "/home/nicoe/projets/tryton/tryton-env/TrimCharField-#7914/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-#7914/trytond/trytond/model/modelsql.py", line 159, in wrapper
return func(cls, *args, **kwargs)
File "/home/nicoe/projets/tryton/tryton-env/TrimCharField-#7914/trytond/trytond/model/modelsql.py", line 662, in create
Translation.set_ids(name, 'model', Transaction().language,
File "/home/nicoe/projets/tryton/tryton-env/TrimCharField-#7914/trytond/trytond/ir/translation.py", line 513, in set_ids
translation.value = value
File "/home/nicoe/projets/tryton/tryton-env/TrimCharField-#7914/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.