Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
8414 Visualizzazioni

i need to make a computed method to calculate the range of years on fire while importing excel sheet if it onChange without dependence api it work well when i but manually records into fields but also not work while importing data

i trired this code but when i'am importing data or inter record into fields i get an error as a title and below


class relate(models.Model):
_name = 'relate'
_rec_name = 'car'

@api.multi
@api.depends('start', 'end', 'ignore')
def years_rang(self):
    for rec in self:
        if rec.start and rec.end:
            record = [int(x) for x in range(int(rec.start), int(rec.end) + 1)]
            list = []
            if rec.ignore:
                try:
                    record.remove(int(self.ignore))
                    list = []
                except ValueError:
                    return {'warning': {'title': 'Warning!', 'message': "the Ignored year doesn't in range"}}
            for item in record:
                range_id = self.env['yearrange'].create({'name': str(item)})
                list.append(range_id.id)
            rec.rang = [(4, x, None) for x in list]
        pass
start = fields.Char(string="", required=False, )
end = fields.Char(string="", required=False, )
rang = fields.One2many(comodel_name="yearrange", inverse_name="product_id", store=True, string="Years" ,compute="years_rang")
ignore = fields.Char(string="Ignore", required=False, )


class yearrange(models.Model):
_name = 'yearrange'
_rec_name = 'name'

name = fields.Char()
product_id = fields.Many2one(comodel_name="relate")


maximum recursion depth exceeded while calling a Python object


Avatar
Abbandona

look into the model that you're inserting if you have any on.change or depends method that changes any of your depends attributes.

Autore

what do you mean ?

Your method is triggered when something is written the three fields and in this method you write to another model, check if in the other model isn't a method that is triggered when you create/write to the model. And that method changes one of your three fields, so that your method would be executed again.

Post correlati Risposte Visualizzazioni Attività
2
dic 22
24065
3
dic 22
3637
2
nov 22
6265
1
giu 22
8251
1
set 21
3172