Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
1 Відповісти
8604 Переглядів

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


Аватар
Відмінити
Автор Найкраща відповідь

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" />


Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
1
лист. 24
1701
1
вер. 21
9488
1
січ. 24
17077
0
бер. 15
3345
1
бер. 15
10010