Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
1 Antworten
8639 Ansichten

Hello guys!

We are in Odoo 10.

See this form view. Two prices are displayed with the currency sign ($) at the right :


In a new custom view, I'm trying to display this same currency sign ($). But I'm unable.

My field is defined with :

montant_perte = fields.Float('Montant de la perte', default=1.0)

In my form view (who works well), my field is displayed with :

<field name="montant_perte" widget='monetary' options="{'currency_field': 'currency_id'}" />

No trace of the currency sign $... Grrr.

Could you help.

Thanks


Avatar
Verwerfen
Autor Beste Antwort

Here is our solution!


In the class :

@api.multi
def _compute_currency_id(self):
        try:
            main_company = self.sudo().env.ref('base.main_company')        except ValueError:
            main_company = self.env['res.company'].sudo().search([], limit=1, order="id")        for template in self:
            template.currency_id = template.company_id.sudo().currency_id.id or main_company.currency_id.id
currency_id = fields.Many2one('res.currency', 'Currency', compute='_compute_currency_id')    
montant_perte = fields.Float('Montant de la perte', default=1.0)


In the form view :

<field name="montant_perte" class="oe_inline" widget='monetary' options="{'currency_field': 'currency_id'}" />
<field name="currency_id" invisible="1" />


Avatar
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
1
Nov. 24
1729
1
Sept. 21
9536
1
Jan. 24
17109
0
März 15
3390
1
März 15
10045