跳至內容
選單
此問題已被標幟
1 回覆
8582 瀏覽次數

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


頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
1
11月 24
1680
1
9月 21
9459
1
1月 24
17064
0
3月 15
3337
1
3月 15
9987