Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
4420 Widoki

Good afternoon... In an integer type field I am trying to convert the number into letters in a qweb report, I have this: 

def _amount_response(self): 

      for rec in self: rec.amount_response = str(rec.currency_id.amount_to_text(rec.amount_total)) 

amount_response = fields.Integer(string="Amount") 

In the qweb I am commanding to call the field in this way: 


And currency_id I am sending it to call from the py in this way: 

currency_id = fields.Many2one('res.currency', 'Currency', default=lambda self: self.env.user.company_id.currency_id.id) 

The problem here is that when I try to print the report in the qweb it gives me an error precisely in the qweb

 ValueError: Expected singleton: res.currency()

 Any solution? Odoo 14 community, thanks

Awatar
Odrzuć
Autor

In the qweb I am commanding to call the field in this way: 



Najlepsza odpowiedź

Hi,

First of all you have to correct the data type of the field amount_response, is it expected to hold integer or a string ? As per written function it has to be string, so field type should be Char or Text. Then modify the function as follows and see:

def _amount_response(self):
for rec in self:
amount_response = ''
if rec.currency_id:
amount_response = str(rec.currency_id.amount_to_text(rec.amount_total))
rec.amount_response = amount_response

Thanks

Awatar
Odrzuć
Autor

Thanks!

Najlepsza odpowiedź

You are getting multiple currency in currency_id instead of one currency.


Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
3
gru 24
4590
0
mar 22
2390
0
sie 21
5042
0
kwi 18
8521
1
gru 17
7957