İçereği Atla
Odoo Menü
  • Portal
  • Ücretsiz deneyin
  • Uygulamalar
    Finans
    • Muhasebe
    • Faturalama
    • Masraf Yönetimi
    • Elektronik Çizelge (BI)
    • Belgeler
    • İmza
    Satış
    • Müşteri İlişkileri Yönetimi (CRM)
    • Satış
    • Satış Noktası Mağaza
    • Satış Noktası Restoran
    • Abonelikler
    • Kiralama
    Web Sitesi
    • Web Sitesi Oluşturucu
    • eTicaret
    • Blog
    • Forum
    • Canlı Sohbet
    • eÖğrenme
    Tedarik Zinciri
    • Envanter
    • Üretim
    • Ürün Yaşam Döngüsü Yönetimi
    • Satın Alma
    • Bakım
    • Kalite
    İnsan Kaynakları
    • Çalışanlar
    • İşe Alım
    • İzin
    • Değerlendirme
    • Referans
    • Filo Yönetimi
    Pazarlama
    • Sosyal Medyada Pazarlama
    • E-posta ile Pazarlama
    • SMS ile Pazarlama
    • Etkinlikler
    • Pazarlama Otomasyonu
    • Anket
    Hizmetler
    • Proje Yönetimi
    • Çalışma Çizelgeleri
    • Saha Hizmeti
    • Yardım Masası
    • Planlama
    • Randevular
    Verimlilik
    • Sohbet
    • Onay
    • Nesnelerin İnterneti
    • VoIP
    • Bilgi Bankası
    • WhatsApp
    Üçüncü taraf uygulamalar Odoo Stüdyo Odoo Bulut Platformu
  • Sektörler
    Perakende satış
    • Kitapçı
    • Giyim Mağazası
    • Mobilya Mağazası
    • Gıda Marketi
    • Hırdavat Dükkanı
    • Oyuncak Dükkanı
    Gıda ve Konaklama
    • Bar ve Pub
    • Restoran
    • Fast Food Restoranı
    • Konuk Evi
    • İçecek Distribütörü
    • Otel
    Gayrimenkul
    • Emlak Acentesi
    • Mimarlık Firması
    • İnşaat
    • Emlak Yönetimi
    • Bahçe Tasarımı
    • Mülk Sahipleri Derneği
    Uzmanlık
    • Muhasebe Firması
    • Odoo Partner
    • Pazarlama Ajansı
    • Hukuk Firması
    • Yetenek Kazanımı
    • Denetim ve Belgelendirme
    Üretim
    • Tekstil
    • Metal
    • Mobilyalar
    • Gıda
    • Bira fabrikası
    • Kurumsal Hediye
    Sağlık ve Spor
    • Spor Kulübü
    • Optik Mağazası
    • Fitness Merkezi
    • Sağlıklı Yaşam Merkezi
    • Eczane
    • Kuaför Salonu
    Ticaret
    • Tamirci
    • BT Donanım & Destek
    • Güneş Enerjisi Sistemleri
    • Ayakkabı İmalatçısı
    • Temizlik Hizmetleri
    • HVAC Hizmetleri
    Diğerleri
    • Kar Amacı Gütmeyen Kuruluş
    • Çevre Ajansı
    • Reklam Panosu Kiralama
    • Fotoğrafçılık
    • Bisiklet Kiralama
    • Yazılım Bayisi
    Tüm Sektörlere Göz Atın
  • Topluluk
    Öğrenim
    • Eğitim Araçları
    • Dokümantasyon
    • Sertifikasyonlar
    • Eğitim Etkinlikleri
    • Blog
    • Podcast
    Eğitim ve Gelişim
    • Eğitim Programı
    • Scale Up! İşletme Oyunu
    • Odoo'yu Ziyaret Edin
    Yazılım
    • İndirin
    • Sürümleri Kıyaslayın
    • Sürümler
    İş Birliği
    • Github
    • Forum
    • Etkinlikler
    • Çeviriler
    • Partner Olun
    • Partnerler için Hizmetler
    • Muhasebe Firmanızı Kaydettirin
    Hizmetler
    • Partner Bulun
    • Muhasebeci Bulun
    • Bir danışmanla görüşün
    • Kurulum Hizmetleri
    • Müşteri Referansları
    • Destek
    • Sürüm Yükseltme
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Demo randevusu alın
  • Fiyatlandırma
  • Yardım

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

  • Müşteri İlişkileri Yönetimi
  • e-Commerce
  • Muhasebe
  • Envanter
  • PoS
  • Proje Yönetimi
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiketler (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiketler (View all)
odoo accounting v14 pos v15
About this forum
Yardım

How to create small and medium images in product.product?

Abone Ol

Get notified when there's activity on this post

Bu soru işaretlendi
productimagevariantsize
1 Cevapla
9980 Görünümler
Avatar
Pascal Tremblay

Hello there,

My post will be long. Don't have the choice. I don't manage to do this.

I have installed the example code of my friend Yenthe :

https://github.com/Yenthe666/Odoo_Samples/tree/master/upload_imagesNow, I'm trying to use this code in product.product and it doesn't work.


In the file openerp/addons/product/product.py :

I have added this code in the product.product class.

class product_product(osv.osv):

        _name = "product.product"

        _description = "Product"

        _inherits = {'product.template': 'product_tmpl_id'}

        _inherit = ['mail.thread']

        _order = 'default_code,name_template'

        def _get_image_variant2(self, cr, uid, ids, name, args, context=None):

                _logger.error("_get_image_variant2")

                result = dict.fromkeys(ids, False)

                for obj in self.browse(cr, uid, ids, context=context):

                        result[obj.id] = tools.image_get_resized_images(obj.image_variant)

                return result

        def _set_image_variant2(self, cr, uid, id, name, value, args, context=None):

                _logger.error("_set_image_variant2")

                return self.write(cr, uid, [id], {'image_variant': tools.image_resize_image_big(value)}, context=context)

        

        'image_variant': fields.binary("Variant Image",

                help="This field holds the image used as image for the product variant, limited to 1024x1024px."),

        'image_variant_medium': fields.function(_get_image_variant2, fnct_inv=_set_image_variant2,

                string="Image variant medium (auto-resized to 128x128):", type="binary", multi="_get_image_variant2",

                store={

                        'product.product': (lambda self, cr, uid, ids, c={}: ids, ['image_variant'], 10),

                },help="Medium-sized image of the category. It is automatically "\

                        "resized as a 128x128px image, with aspect ratio preserved. "\

                        "Use this field in form views or some kanban views."),

        'image_variant_small': fields.function(_get_image_variant2, fnct_inv=_set_image_variant2,

                string="Image variant small (auto-resized to 64x64):", type="binary", multi="_get_image_variant2",

                store={

                        'product.product': (lambda self, cr, uid, ids, c={}: ids, ['image_variant'], 10),

                },

                help="Small-sized image of the category. It is automatically "\

                        "resized as a 64x64px image, with aspect ratio preserved. "\

                        "Use this field anywhere a small image is required.")


In the view product.product_normal_form_view :

I added two new fields.

        <field name="image_variant_small" widget="image" class="oe_avatar oe_left"/>

        <field name="image_variant_medium" widget="image" class="oe_avatar oe_left"/>

See result at the bottom right of this screenshot.


The problem :

When I edit this product.product record, I select a new image in one of these two new fields (image variant small or image variant medium), the image appears. Then, I click on save button. My two new fields stay blank... Like the preview above! Grrr!

Only the original image_medium field changes. The new image only appears there at the top left!

What I do wrong?

Thanks everybody to help! If it miss something in this post, I can add it quickly. Thanks!




Update #1 (january 1, 2016)

See the name of each one of the image fields. I think that each fields have a different name. Is it what it should be?



Update #2 (january 1, 2016)

In the module of Yenthe, upload_images, i have printed the context in the _set_images method when I save a new image :

    context :: {'lang': 'en_US', 'params': {'action': 1827}, 'tz': 'America/Montreal', 'uid': 1}

In the file odoo-8.0-20151003/openerp/addons/product/product.py, I have also printed the context in the _set_image_variant2 method

(see above for this method) when I save a new image in within one of my two new fields of the product.product view above  :

context :: {'lang': 'en_US', 'tz': 'America/Montreal', 'uid': 1, 'active_model': 'product.template', 'params': {'action': 348}, 'search_disable_custom_filters': True, 'search_default_product_tmpl_id': [491], 'active_ids': [491], 'active_id': 491}

What I see special there????  In the context of my new _set_image_variant method, there is an 'active_model' : 'product.template'... Should it not be setted at product.product rather?

May be this is the problem?





1
Avatar
Vazgeç
Avatar
Dr Obx
En İyi Yanıt

Is it not as with the fields ? Only one field can have a value if there is more than one with the same name in one view. Every image must have a  unique field name.


0
Avatar
Vazgeç
Pascal Tremblay
Üretici

My post now has an update #1. Thanks for your answer.

Dr Obx

So top two images works fine, only those in right bottom corner won't ?

Pascal Tremblay
Üretici

exactly like you say. I saw something in the log. I update #2 now.

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Üye Ol
İlgili Gönderiler Cevaplar Görünümler Aktivite
How to put different image on each variant of a product? Çözüldü
product image variant different
Avatar
Avatar
5
Oca 16
16556
Is it possible to easily assign one image to multiple product variants?
product variant
Avatar
Avatar
Avatar
Avatar
3
May 25
2445
Pros and Cons of creating product variants Instantly or Dynamically or Never Çözüldü
product variant
Avatar
Avatar
Avatar
Avatar
3
Kas 24
9497
Incorrect Variant Count after importing Newly added Size/color on odoo 17??
sales product variant size colors
Avatar
Avatar
1
Eyl 24
1588
Allow selection of multiple values from a single attribute of a product's variant
product variant
Avatar
Avatar
Avatar
3
Eyl 24
6758
Topluluk
  • Eğitim Araçları
  • Dokümantasyon
  • Forum
Açık Kaynak
  • İndirin
  • Github
  • Runbot
  • Çeviriler
Hizmetler
  • Odoo.sh Hosting
  • Destek
  • Sürüm Yükseltme
  • Özel Geliştirmeler
  • Eğitim
  • Muhasebeci Bulun
  • Partner Bulun
  • Partner Olun
Hakkında
  • Şirketimiz
  • Pazarlama Gereçleri
  • İletişim
  • Kariyer
  • Etkinlikler
  • Podcast
  • Blog
  • Müşteriler
  • Hukuki • Gizlilik
  • Güvenlik
الْعَرَبيّة 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, müşteri ilişkileri yönetimi, eTicaret, muhasebe, envanter, satış noktası, proje yönetimi gibi şirketinizin tüm ihtiyaçlarını karşılayan bir açık kaynak işletme uygulamaları paketidir.

Odoo’nun eşsiz değer önermesi, aynı anda hem kullanımının çok kolay olup hem de tamamen entegre olmasıdır.

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