Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Managament
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Producție
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

How to add product image from xmlrpc call

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
productimage
4 Răspunsuri
18172 Vizualizări
Imagine profil
jagdish

Hi,

I want insert image in product using xmlrpc, so how to pass data in php call to insert product image?? i have try to pass data like in point_of_sale_data.xml but it give me error cannot identify image file

Thanks jagdish

1
Imagine profil
Abandonează
Imagine profil
Alain Ivars
Cel mai bun răspuns
  • rename the image files according to your products (<product-code>.jpg or <id>.jpg)
  • Write a short python script which loops over the image files, encode with base64 and write to OpenERP with XMLRPC

# get file
yourImage = request.files.get('product1.jpg')
# read it
image = yourImage.file.read()
# encode it base64
imageBase64 = base64.b64encode(image)
# now pass it to your XMLRPC call

I hope that will help you :)

3
Imagine profil
Abandonează
Vimal Rughani

Thank Alain, for great answer. Can you please tell how to read image from xml rpc. I have created custom module in openerp v7 and I want to fetch value of that module in my website using django. I am able to fetch all text field, but not able to get image. While fetching image (binary field) it gives value probably b64encoded. I don't know to make that image visible without storing image data. Is there any direct way to access image url of openerp module. Can you please guide me ? Thanks for your time and help.

Imagine profil
fudo
Cel mai bun răspuns

Currently, to get the product image as url, we could use:

from odoo.tools.image import image_data_uri

product_image = image_data_uri(product.image_1920)

In my case,  product.image_1920 is the column of saved product image, you can replace it with your column to make it work.

Note: after get  product_image, you can see it still look like base64 encrypted format, but it's not, try to paste it to web browser such as Chrome, and you will see the image appear.


0
Imagine profil
Abandonează
Imagine profil
Mehrdad Bahri
Cel mai bun răspuns

To resolve the 

TypeError: 'Binary' object is not subscriptable

error, use the decode('ascii') method:

with open("image.jpg", "rb") as img:
    b64_image = base64.b64encode(img.read())
data = {'image_1920': b64_image.decode('ascii')}



0
Imagine profil
Abandonează
Imagine profil
Andres Brigard
Cel mai bun răspuns

Thanks Alain. The code I am using to write through the 

execute('res.partner', 'write', [6], {'image': imageBase64})

 Or using OdooRPC

model.browse(6).write({'image': imageBase64)

In both cases I get the following error:

xmlrpc.client.Fault: <Fault 'Binary' object is not subscriptable: 'Traceback (most recent call last):
File "/home/odoo/odoo12/odoo/odoo/addons/base/controllers/rpc.py", line 60, in xmlrpc_1
response = self._xmlrpc(service)
File "/home/odoo/odoo12/odoo/odoo/addons/base/controllers/rpc.py", line 49, in _xmlrpc
result = dispatch_rpc(service, method, params)
File "/home/odoo/odoo12/odoo/odoo/http.py", line 120, in dispatch_rpc
result = dispatch(method, params)
File "/home/odoo/odoo12/odoo/odoo/service/model.py", line 40, in dispatch
res = fn(db, uid, *params)
File "/home/odoo/odoo12/odoo/odoo/service/model.py", line 98, in wrapper
return f(dbname, *args, **kwargs)
File "/home/odoo/odoo12/odoo/odoo/service/model.py", line 185, in execute
res = execute_cr(cr, uid, obj, method, *args, **kw)
File "/home/odoo/odoo12/odoo/odoo/service/model.py", line 169, in execute_cr
result = odoo.api.call_kw(recs, method, args, kw)
File "/home/odoo/odoo12/odoo/odoo/api.py", line 759, in call_kw
return _call_kw_multi(method, model, args, kwargs)
File "/home/odoo/odoo12/odoo/odoo/api.py", line 746, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "/home/odoo/odoo12/odoo/addons/partner_autocomplete/models/res_partner.py", line 183, in write
res = super(ResPartner, self).write(values)
File "/home/odoo/odoo12/odoo/odoo/addons/base/models/res_partner.py", line 563, in write
tools.image_resize_images(vals, sizes={'image': (1024, None)})
File "/home/odoo/odoo12/odoo/odoo/tools/image.py", line 302, in image_resize_images
vals.update(image_get_resized_images(vals[big_name],
File "/home/odoo/odoo12/odoo/odoo/tools/image.py", line 292, in image_get_resized_images
return_dict[big_name] = image_resize_image_big(base64_source, avoid_if_small=avoid_resize_big, size=size_big)
File "/home/odoo/odoo12/odoo/odoo/tools/image.py", line 168, in image_resize_image_big
return image_resize_image(base64_source, size, encoding, filetype, avoid_if_small)
File "/home/odoo/odoo12/odoo/odoo/tools/image.py", line 66, in image_resize_image
if size == (None, None) or base64_source[:1] == b'P':
TypeError: 'Binary' object is not subscriptable

Any advice to overcome this problem please?
Thanks Andres

0
Imagine profil
Abandonează
Enjoying the discussion? Don't just read, join in!

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

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
Make product picture mandatory
product image
Imagine profil
Imagine profil
2
dec. 21
2221
Fastest way to check if product does not have image
product image
Imagine profil
0
oct. 21
3504
How to use urls as product images? Rezolvat
product image
Imagine profil
Imagine profil
Imagine profil
2
dec. 19
24173
How to import product images ? Rezolvat
product import image
Imagine profil
Imagine profil
Imagine profil
3
nov. 24
15195
One image for many products
product image database
Imagine profil
0
iun. 22
2909
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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