So I am creating offers for different customers, and based on the language in the party settings the offer should be in English or German. This works 99%, however, when creating an offer to a non-German client, for some reason the unit in each of the lines in the sale report always says “Stück”, i.e. the German translation for “Units”.
In the original report, the placeholder in question is format_number_symbol(line.quantity, sale.party.lang, line.unit, digits=line.unit.digits). I have played around a bit and tried to “break it up” by using line.product_uom_category.rec_name, just to see what happens. It still produces “Stück” instead of “Units”. Everything else is in English though.
Yes, I even confirmed it by looking in the Database. And if I don’t set any language, the reports are usually in German, as this is the primary language for our Tryton installation.
I’m thinking that we’re talking about the unit symbol, since that’s what format_number_symbol is for. If anything, you should be getting ‘u’ in English, or whatever symbol is used for German. Is the translation for the symbol done as well? (Sorry if you’ve already checked this too, but I really can’t think of anything else, as format_number_symbol(line.quantity, sale.party.lang, line.unit, digits=line.unit.digits) works perfectly fine in our reports).
For the time being, I decided to implement a workaround that looks like this:
<format_number(line.quantity, sale.party.lang, digits=line.unit.digits)> <choose test=""><when test="sale.party.lang.rec_name=='Englisch' and line.product_uom_category.rec_name=='Stück'">Units</when><otherwise test=""><line.product_uom_category.rec_name></otherwise></choose>
This hardcodes “Units” and will stop to work if we ever sell products that are quantified not in “Units”, but e.g. “grams”; however, this does not seem to be the case for the forseeable future.
If I figure out the original reason for the issue, I will update it here. I am 100% sure that I misconfigured something, but I just can’t find it right now.
For me this means that line.unit does not have the right language context.
Normally it should inherit the context from the record which should have it set by set_lang call.
Also, to include all details: I was wrong when I answered @yangoon before. More experimentation showed that the names of the products used the wrong language, too. Thanks to @ced this is now resolved as well!