Pular para o conteúdo
Menu
Esta pergunta foi sinalizada
1 Responder
4012 Visualizações

hello, I just start coding with odoo13, and I have a comput field in the module and I want to show it on the tree view but ValueError: Expected singleton appear

In odoo 9, I used @api.one decorator, but for odoo 13 I make same reaserch  to resolve this error but I cannot resolve it.

This is the fonction of the comput field:

@api.depends('num_cour', 'num_b','num_da', 'abr_sect')
def _get_name(self):

    self.num_cour = ' N° '+ (self.num_b or '') + '/' + (self.num_da or '') + '/' + (self.abr_sect or '')

num_cour = fields.Char(string='N cr', compute='_get_name', readonly=True)


 

Avatar
Cancelar
Melhor resposta

this happens when you get more than 1 record in a variable that expects 1 record

try this:


@api.depends('num_cour', 'num_b', 'num_da', 'abr_sect')
def _get_name(self):
for rec in self:
rec.num_cour = ' N° ' + (rec.num_b or '') + '/' + (rec.num_da or '') + '/' + (rec.abr_sect or '')

num_cour = fields.Char(string='N cr', compute='_get_name', readonly=True)


Avatar
Cancelar
Autor

Thank's Gerson it's work

Publicações relacionadas Respostas Visualizações Atividade
2
set. 20
3571
0
fev. 20
58
1
ago. 23
3083
0
ago. 23
2529
1
ago. 23
1694