Odoo Help

0

0
2 Відповіді
1
Lyubomir Petkov Болгарія
24.06.19, 09:06

Hello Paulo,

You don't need to recreate the image.py file. You can use its methods by importing it from odoo.tools:

`from odoo.tools import image_resize_images`

You should use the method image_resize_images with a specified parameter size , like is in the following example:

image_resize_images(vals, big_name='cover', medium_name='cover_medium', small_name='cover_small',
size={'cover': (1550, None), 'cover_medium': (1000, None), 'cover_small': (420, None)})
The Odoo way of using that technique for storing 3 types of image sizes is by defining 3 fields
 for images in your model, that represents big_image, medium_image and small_image.

Use this method by calling it in create and write methods in the model, like this:
@api.model
def create(self, vals):
image_resize_images(vals)
return super(PaymentAcquirer, self).create(vals)

@api.multi
def write(self, vals):
image_resize_images(vals)
return super(PaymentAcquirer, self).write(vals)

The example is from payment_acquirer.py in the payment module. You can see it for more information.
Regards,
Lyubo.
1 Коментар
EuroGold, Paulo Matos Ангола
26.06.19, 18:30

Dear @Lyubomir,

Thank you very very much for your update.

This is exactly what I need.

Best regards

Paulo

0
Paulo Matos Ангола
23.02.19, 05:35

Hello,

I have found that the best option, is to recreate the image.py under tools and import this new file to our own new module calling the new defs under this new module instead of the pre-defined Odoo tools module.

Thank you very much

Regards

Paulo



Задайте запитання
Автор
Мітки
Продовжити інформувати
1 підписник(и)
Про цю спільноту

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now