Skip to Content
Menú
This question has been flagged
6 Respostes
5905 Vistes

Hi Guys,

I need to remove the currency symbol for a specific monetary field.

Is this possible?


Please note that this is for a form view and not for a QWEB view.


Thank you

Eshan Harshana


Avatar
Descartar

@ESHANG Harshana is asked for form view but this link is for QWEB!

Best Answer

Hi,
Try this  code
Edit the XML View:
Find the field you want to modify.
It should look something like this in the XML view: 

<field name="amount_total" />

Add the options attribute to the field definition, specifying the 'currency_no_symbol' option:

<field name="amount_total" options="{'currency_no_symbol': True}" />

 

By adding this attribute with the 'currency_no_symbol' option, you are instructing Odoo to display the monetary value without the currency symbol.

Hope it helps

Avatar
Descartar
Best Answer
<span t-field="line.price_subtotal" t-options='{"widget": "float", "precision": 2}'/>


I think form should support the same options


odoo 17

Avatar
Descartar
Best Answer

I have found another solution. Add below code to your model:

    def formatted_amount(self):

        return self.env['ir.qweb.field.monetary'].value_to_html(

            self.amount,

            {

                'currency': self.currency_id,

                'display_currency': self.currency_id

            }

        ).replace(self.currency_id.symbol, '').strip()

 And then use it like this:

<td class="text-end font-monospace" >

      <t t-esc="record.formatted_amount()" />

</td>​​

A bit tricky but couldn't get other suggestions work.

Avatar
Descartar
Best Answer

Hi, to remove currency symbols from models, try this solution, it worked.

example for a qweb field model in xml:   

"line.price.replace('€', '')" /> 

( replace  '€' with the currency symbol you use)

Avatar
Descartar
Best Answer

In the xml use widget="float" in the specific monetary field

example:

       field name="your_field" widget="float"/>

Avatar
Descartar
Best Answer

I have tried the solution from Cybrosys, but it does not work:

span t-field="line.price_total" groups="account.group_show_line_subtotals_tax_included" t-field-options="{'widget': False}"/

Have you ever managed to find a way how to hide the symbol?


Apologies for the weird formatting - Odoo strips all tags in the answer, even when it's formatted as code.

Avatar
Descartar

I have seen that there is a `no_symbol` Option: https://github.com/odoo/odoo/blob/c00baa010e7981f16bf3047cee6aaee1fc0f7495/addons/web/static/tests/views/fields/monetary_field_tests.js#L930

However, I haven't found a way to use this in a QWeb view. Does anybody have a working solution?

Related Posts Respostes Vistes Activitat
1
de març 15
5913
1
de set. 17
6340
1
d’ag. 17
13447
1
de maig 17
4447
1
de juny 16
10440