El dia 07/04/2015 20.31, "Christophe (net)" <[email protected]> va escriure:
>
>
>
> Le 07/04/2015 20:12, Cédric Krier a écrit :
>>
>> On 07 Apr 19:49, Christophe (net) wrote:
>>>
>>>
>>>
>>> Le 07/04/2015 19:14, Cédric Krier a écrit :
>>>>
>>>> On 07 Apr 17:57, Christophe wrote:
>>>>>
>>>>> Hello,
>>>>>
>>>>> In a new module I defined a selection field whose elements are updated
>>>>> dynamically (by a method that returns tuples). I translate all fields
in the
>>>>> module (including tuple of selection) but at the time of display in a
view
>>>>> the list of items still desperately in English. Yet in the
documentation
>>>>> states that the default selection fields are translatable.
>>>>> I have this problem in v3.0, v3.2, v3.4 (I have not tested on
versions prior
>>>>> to v3.0).
>>>>> Has anyone ever encountered this trouble?
>>>>
>>>>
>>>> If you are using a method to define the selection options, the method
>>>> must manage itself the translation of the options.
>>>>
>>> Ok, is there somewhere a sample to make that ?
>>
>>
>> Usualy such data come from the database so you just have to use a
>> translatable field.
>>
>
> Sorry i don't understand your answer, i have the following code
>
> _PRICE_TYPE = [
> ('t_inc', 'Tax included'),
> ('t_exc', 'Tax excluded'),
> ]
You could translate label with raise_user_error but without raise.
For example:
keyword = cls.raise_user_error('closed', raise_exception=False)
And in setup define error_messages
> class Sale(Workflow, ModelSQL, ModelView):
> __name__ = 'sale.sale'
>
> price_type = fields.Selection('get_price_type', 'Price type',
required=True,
> states={
> 'readonly': (Eval('state') != 'draft') |
(Bool(Eval('lines'))),
> },
> selection_change_with=['party', 'shop', 'shop_price_type',
'state'],
> depends=_DEPENDS,
> help='Type of price of this sale.')
>
> def get_price_type(self):
> return _PRICE_TYPE
>
> In fact the 'get_price_type' method isn't exactly like that but i have
the same issue with this code,
>
> Where i need to put the 'translatable field' to make the items of
price_type translated in the view.
> --
> Christophe
> http://adiczion.com