Skip to Content
Odoo Menu
  • Zaloguj się
  • Wypróbuj za darmo
  • Aplikacje
    Finanse
    • Księgowość
    • Fakturowanie
    • Wydatki
    • Arkusz kalkulacyjny (BI)
    • Dokumenty
    • Podpisy
    Sprzedaż
    • CRM
    • Sprzedaż
    • PoS Sklep
    • PoS Restauracja
    • Subskrypcje
    • Wypożyczalnia
    Strony Internetowe
    • Kreator Stron Internetowych
    • eCommerce
    • Blog
    • Forum
    • Czat na Żywo
    • eLearning
    Łańcuch dostaw
    • Magazyn
    • Produkcja
    • PLM
    • Zakupy
    • Konserwacja
    • Jakość
    Zasoby Ludzkie
    • Pracownicy
    • Rekrutacja
    • Urlopy
    • Ocena pracy
    • Polecenia Pracownicze
    • Flota
    Marketing
    • Marketing Społecznościowy
    • E-mail Marketing
    • SMS Marketing
    • Wydarzenia
    • Automatyzacja Marketingu
    • Ankiety
    Usługi
    • Projekt
    • Ewidencja czasu pracy
    • Usługi Terenowe
    • Helpdesk
    • Planowanie
    • Spotkania
    Produktywność
    • Dyskusje
    • Zatwierdzenia
    • IoT
    • VoIP
    • Baza wiedzy
    • WhatsApp
    Aplikacje trzecich stron Studio Odoo Odoo Cloud Platform
  • Branże
    Sprzedaż detaliczna
    • Księgarnia
    • Sklep odzieżowy
    • Sklep meblowy
    • Sklep spożywczy
    • Sklep z narzędziami
    • Sklep z zabawkami
    Żywienie i hotelarstwo
    • Bar i Pub
    • Restauracja
    • Fast Food
    • Pensjonat
    • Dystrybutor napojów
    • Hotel
    Agencja nieruchomości
    • Agencja nieruchomości
    • Biuro architektoniczne
    • Budowa
    • Zarządzanie nieruchomościami
    • Ogrodnictwo
    • Stowarzyszenie właścicieli nieruchomości
    Doradztwo
    • Biuro księgowe
    • Partner Odoo
    • Agencja marketingowa
    • Kancelaria prawna
    • Agencja rekrutacyjna
    • Audyt i certyfikacja
    Produkcja
    • Tekstylia
    • Metal
    • Meble
    • Jedzenie
    • Browar
    • Prezenty firmowe
    Zdrowie & Fitness
    • Klub sportowy
    • Salon optyczny
    • Centrum fitness
    • Praktycy Wellness
    • Apteka
    • Salon fryzjerski
    Transakcje
    • Złota rączka
    • Wsparcie Sprzętu IT
    • Systemy energii słonecznej
    • Szewc
    • Firma sprzątająca
    • Usługi HVAC
    Inne
    • Organizacja non-profit
    • Agencja Środowiskowa
    • Wynajem billboardów
    • Fotografia
    • Leasing rowerów
    • Sprzedawca oprogramowania
    Przeglądaj wszystkie branże
  • Community
    Ucz się
    • Samouczki
    • Dokumentacja
    • Certyfikacje
    • Szkolenie
    • Blog
    • Podcast
    Pomóż w nauce innym
    • Program Edukacyjny
    • Scale Up! Gra biznesowa
    • Odwiedź Odoo
    Skorzystaj z oprogramowania
    • Pobierz
    • Porównaj edycje
    • Wydania
    Współpracuj
    • Github
    • Forum
    • Wydarzenia
    • Tłumaczenia
    • Zostań partnerem
    • Usługi dla partnerów
    • Zarejestruj swoją firmę rachunkową
    Skorzystaj z usług
    • Znajdź partnera
    • Znajdź księgowego
    • Spotkaj się z doradcą
    • Usługi wdrożenia
    • Opinie klientów
    • Wsparcie
    • Aktualizacje
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Zaplanuj demo
  • Cennik
  • Pomoc

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Księgowość
  • Zapasy
  • PoS
  • Projekt
  • MRP
All apps
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Pomoc

How to set a specific dynamic image size in Odoo?

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
imageResizeodoo12.0
4 Odpowiedzi
16991 Widoki
Awatar
Paulo Matos

Hello everyone,

I am working with Odoo 12.

I have been searching the forum and on web, for information about working with image sizes in Odoo.

I have found lots of information about that but all of them does not fit on my actual requirements.

In fact, most of them only refers to pre-defined image sizes like image big (1024x1024px), image medium and image small. All of them with fixed image sizes. I could not find any information on how to actually define a size for the final image.

What I need to do is:

- Allow user to attach an image to the form;

- Resize this image to a specific image size (let's say: 500x500px), thus reduce it's size;

- Have the image saved on the database;

 I am using the standard Odoo image type field (binary) declared like this:

    fields.Binary("Image", attachment=True, default:lambda, self:self.SOME_DEFINITION_HERE_WHICH_I_DO_NOT_KNOW);

Can anyone help me achieving that?

Thank you all in advance

Best regards

Paulo


0
Awatar
Odrzuć
Sehrish

Hope this will helps: http://learnopenerp.blogspot.com/2020/07/how-to-resize-image-on-saving-records-in-odoo.html

Sehrish

To resize image in Odoo14: https://learnopenerp.blogspot.com/2021/09/dynamically-image-resizing-save-write-odoo14.html

Awatar
Lyubomir Petkov
Najlepsza odpowiedź

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.
2
Awatar
Odrzuć
Paulo Matos
Autor

Dear @Lyubomir,

Thank you very very much for your update.

This is exactly what I need.

Best regards

Paulo

Awatar
Paulo Matos
Autor Najlepsza odpowiedź

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



0
Awatar
Odrzuć
Faris Fathurrahman

can you please write the actual codes of how you achieved it? thanks in advance!

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ść
Help on understanding this code! Rozwiązane
resizing imageResize odoo12.0
Awatar
Awatar
2
lut 19
5028
Expected singleton: hr.emp.travel.location(62, 63)
odoo12.0
Awatar
Awatar
Awatar
2
paź 25
1945
How to write Record Rule with domain based on the company_dependent Fields Rozwiązane
odoo12.0
Awatar
Awatar
Awatar
3
paź 23
10636
loan request
odoo12.0
Awatar
Awatar
1
wrz 23
3981
sum Colum of based on id
odoo12.0
Awatar
Awatar
1
maj 23
2938
Społeczność
  • Samouczki
  • Dokumentacja
  • Forum
Open Source
  • Pobierz
  • Github
  • Runbot
  • Tłumaczenia
Usługi
  • Hosting Odoo.sh
  • Wsparcie
  • Aktualizacja
  • Indywidualne rozwiązania
  • Edukacja
  • Znajdź księgowego
  • Znajdź partnera
  • Zostań partnerem
O nas
  • Nasza firma
  • Zasoby marki
  • Skontaktuj się z nami
  • Oferty pracy
  • Wydarzenia
  • Podcast
  • Blog
  • Klienci
  • Informacje prawne • Prywatność
  • Bezpieczeństwo Odoo
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo to pakiet aplikacji biznesowych typu open source, które zaspokoją wszystkie potrzeby Twojej firmy: CRM, eCommerce, księgowość, inwentaryzacja, punkt sprzedaży, zarządzanie projektami itp.

Unikalną wartością Odoo jest to, że jest jednocześnie bardzo łatwe w użyciu i w pełni zintegrowane.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now