Skip to Content
Menu
This question has been flagged
1 Reply
6341 Views

helo

i want to use (0, 0, { values }) in for loop like this: 

class btp_etatcaution(models.Model):  

def _getfiltered(self): 

values  = ''

for record in self.env['btp.caution'].search([('banque_id', '=', self.banque_id.id),]):           

values += "(0, 0, { 'name':'"+record.name+"', }) ,"  

self.ligne_caution_etat =  [values]

...

ligne_caution_etat = fields.One2many('btp.caution', 'etat_caution', 'etat_caution')

--------------------------------------------------

but i get this error, 

psycopg2.DataError: ERREUR:  syntaxe en entrée invalide pour l'entier : « (0, 0, { 'name':'caution3', }) ,(0, 0, { 'name':'caution4', }) , »
LINE 1: ...ro" FROM "btp_caution" WHERE "btp_caution".id IN ('(0, 0, { ...
                                                             ^
how can i ccorrect it?

Avatar
Discard
Best Answer

Hello,

Please try this code,

class btp_etatcaution(models.Model):

    def _getfiltered(self):
        values  = [ ]
        for record in self.env['btp.caution'].search([('banque_id', '=', self.banque_id.id),]):
            values.append((0, 0, {'name':record.name}))
        self.ligne_caution_etat = values

Hope it will work for you,

thanks,

Avatar
Discard

Hi Malay B Khamar,

If you can edit this line, it will be perfect.

values.append((0, 0, {'name': record.name}))