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
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    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

API xmlrpc - upload pdf bills to account

Abonare

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

Această întrebare a fost marcată
api
3 Răspunsuri
1914 Vizualizări
Imagine profil
Rolemberg Filho

Hi,


I'm new here ant testing external API to create account bills.


I've created with success an account_move record, and account_movelines records 


But, when I upload a pdf file to ir_attachment, this file not appear in odoo site. I got an "file can't be loaded" error in site. I converted file binary in base64 string.


My odoo version is 18, and it onsite (instead local installation). I noted that odoo 18 default configuration is save files on local store, instead sabe in database.


So, what can I do to upload files and see them in site?



Thank you!

0
Imagine profil
Abandonează
Imagine profil
Rolemberg Filho
Autor Cel mai bun răspuns

Got it, and discovered my problem.


i'm using the column "db_datas" instead of "datas".


"db_datas" stores all the base64 into database, and "datas" stores base64 in filestore

Thanks a lot!

0
Imagine profil
Abandonează
Imagine profil
Adil Akbar
Cel mai bun răspuns

Hi, please check this: https://youtu.be/Cmbo2iGuTBY 
Hope it helps.

0
Imagine profil
Abandonează
Imagine profil
Cybrosys Techno Solutions Pvt.Ltd
Cel mai bun răspuns

Hi,


Please try it like this.


import xmlrpc.client

import base64


common = xmlrpc.client.ServerProxy('http://localhost:9016/xmlrpc/2/common')

uid = common.authenticate('dbname', 'username', 'key', {})

models = xmlrpc.client.ServerProxy('http://localhost:9016/xmlrpc/2/object')



with open("test.pdf", "rb") as f:

    encoded_file = base64.b64encode(f.read()).decode("utf-8")


attachment_id = models.execute_kw(

    'dbname', 'username', 'key',

    'ir.attachment', 'create',

    [{

        'name': 'Sample Attachment',

        'type': 'binary',

        'datas': encoded_file,

        'res_model': 'sale.order', <--- your model

        'res_id': 324324,  # <--- your line ID

        'mimetype': 'application/pdf',

        'store_fname': 'test.pdf',

        'public': True, # <----- optional for public access

    }]

)

print("Attachment created with ID:", attachment_id)



Now to ensure this attachment is created you can check by going to url '/web/content/{attachment_id}.


Hope it helps

-2
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
How do I get Product Prices with json API? Rezolvat
api
Imagine profil
Imagine profil
1
nov. 25
2969
Has anyone integrated Helpdesk with Zoom for meeting scheduling?
api
Imagine profil
Imagine profil
1
aug. 25
1446
Using API check if Odoo is using Odoo sh or on-premises hosting. Rezolvat
api
Imagine profil
Imagine profil
1
aug. 25
1810
External API XMLRPC Authentication Keeps Replying with false
api
Imagine profil
Imagine profil
Imagine profil
2
iul. 25
4756
Odoo API connection credential - How to get these credentials?
api
Imagine profil
Imagine profil
1
iun. 25
3802
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