콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다

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


아바타
취소

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

작성자

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.

관련 게시물 답글 화면 활동
2
12월 22
24068
3
12월 22
3638
2
11월 22
6267
1
6월 22
8255
1
9월 21
3175