On 07 Apr 20:31, Christophe (net) wrote:
> 
> 
> 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'),
>     ]
> 
> 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.

Nowhere because there is no point to write such code.
If you write such code, you have to manage yourself the translation,
Tryton has no way to know what you are computing in your method.

-- 
Cédric Krier - B2CK SPRL
Email/Jabber: cedric.kr...@b2ck.com
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/

Reply via email to