I upload the image when i uploading i need to resize the uploaded image and save it into the backend
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Księgowość
- Zapasy
- PoS
- Project
- MRP
To pytanie dostało ostrzeżenie
Hi Gokul,
Thks for ur rply but im getting 404 error
my code in model.
image_variant = fields.Binary(
"Variant Image", attachment=True,
help="This field holds the image used as image for the product variant, limited to 1024x1024px.")
image_variant2 = fields.Binary(
"Variant Image", attachment=True,
help="This field holds the image used as image for the product variant, limited to 1024x1024px.")
image_variant3 = fields.Binary(
"Variant Image", attachment=True,
help="This field holds the image used as image for the product variant, limited to 1024x1024px.")
image = fields.Binary(
"Big-sized image", compute='_compute_images', inverse='_set_image',
help="Image of the product variant (Big-sized image of product template if false). It is automatically "
"resized as a 1024x1024px image, with aspect ratio preserved.")
image_small = fields.Binary(
"Small-sized image", compute='_compute_images',
help="Image of the product variant (Small-sized image of product template if false).")
image_medium = fields.Binary(
"Medium-sized image", compute='_compute_images', inverse='_set_image_medium',
help="Image of the product variant (Medium-sized image of product template if false).")
image_variant_raw = fields.Binary()@api.one
@api.depends('image_variant')
def _compute_images(self):
if self._context.get('bin_size'):
self.image_medium = self.image_variant
self.image_small = self.image_variant
self.image = self.image_variant
else:
resized_images = tools.image_get_resized_images(self.image_variant, return_big=True, avoid_resize_medium=True)
self.image_medium = resized_images['image_medium']
self.image_small = resized_images['image_small']
self.image = resized_images['image']
@api.one
def _set_image(self):
self.image_variant = self.image_mediumself.image_variant2 = self.image_small
self.image_variant3 = self.image
@api.one
def _set_image_medium(self):
self.image_variant = self.image_medium
self.image_variant2 = self.image_small
self.image_variant3 = self.image
@api.one
def _set_image_small(self):
self._set_image_value(self.image_small)
@api.one
def _set_image_value(self, value):
self.image_variant = value
In view<field name="image" widget="image" class="oe_avatar"/>
<field name="image_medium" widget="image" class="oe_avatar"/>
<field name="image_small" widget="image" class="oe_avatar"/>
Do you saw the server log ?
if getting any error just post it.
Its Working but i dont want to customize the preview image i need to optimize the image as thumbnail......thks i fixed the issue
Hi sujitha !
Refer this link https://www.odoo.com/forum/help-1/question/how-do-i-control-the-size-of-an-image-being-shown-on-the-form-view-by-the-image-widget-107387. I think it may be helps you.
Podoba Ci się ta dyskusja? Dołącz do niej!
Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!
Zarejestruj sięPowiązane posty | Odpowiedzi | Widoki | Czynność | |
---|---|---|---|---|
|
0
mar 15
|
4126 | ||
|
1
lip 20
|
4775 | ||
Help on understanding this code!
Rozwiązane
|
|
2
lut 19
|
4328 | |
|
0
lut 16
|
3994 | ||
|
2
lut 20
|
3933 |
Get an idea how to resize image: https://learnopenerp.blogspot.com/2021/09/dynamically-image-resizing-save-write-odoo14.html