İçereği Atla
Menü
Bu soru işaretlendi
3 Cevaplar
9447 Görünümler

Hello,


I have 1 custom class which have minimum 30000 record which have images are stored.

Now, I want to resize all the images which is stored and also creating new record with image.


First image field is like as below

variants_image_medium = fields.Binary('Product Image', store=True, attachment=True)


Now, I converted image field as shown below

variants_image_medium = fields.Binary('Product Image', inverse='_compute_images', store=True, attachment=True, readonly=False)


@api.multi
def _compute_images(self):
        for rec in self:
            if rec.variants_image_medium:
                image = tools.image_resize_image_small(rec.variants_image_medium)
                rec.variants_image_medium = image
                return rec


 It gives me error,

RuntimeError: maximum recursion depth exceeded


How to Solve that error ?

Thanks in Advance,


Avatar
Vazgeç
En İyi Yanıt

For a computed function returning arguments should keep the format

{'value':
     { 'field_name':field_value}
}

So please check the  rec satisfies this.



Avatar
Vazgeç
En İyi Yanıt

In your inverse you are changing current field, what invokes this inverse recursively:

Field value x > Field value x1 > Field value x2 > .... > 


You should

1) either store resized image in a separated field

2) or add a condition in inverse not to make recursion, e.g.:

already_resized = fields.Boolean()

@api.multi
def _compute_images(self):
        for rec in self:
            if not 
already_resized and rec.variants_image_medium:

                image = tools.image_resize_image_small(rec.variants_image_medium)
                rec.variants_image_medium = image
                rec.
already_resized = True

Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
1
Kas 24
39625
1
Ağu 16
5693
3
Ağu 24
13629
2
Şub 24
3365
2
Nis 23
3273