Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Jídlo a pohostinství
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Penzion
    • Distributor nápojů
    • Hotel
    Nemovitost
    • Realitní kancelář
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Poradenství
    • Účetní firma
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textil
    • Kov
    • Nábytek
    • Jídlo
    • Pivovar
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Transakce
    • Údržbář
    • Podpora IT & hardware
    • Systémy solární energie
    • Výrobce obuvi
    • Úklidové služby
    • Služby HVAC
    Ostatní
    • Nezisková organizace
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Procházet všechna odvětví
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Služby pro partnery
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

Link attachments with wanted record and model

Odebírat

Get notified when there's activity on this post

This question has been flagged
quickstart
1 Odpovědět
10000 Zobrazení
Avatar
Adrien Konopek (adko)

Prerequisite

I made all the test in v15 so it should work for all sub versions (15.0, 15.1 and 15.2). 

Be in debug mode.

Have an import compatible file of some attachments.

Studio.


Use case

It often happens that we want to make a mass import of attachments in Odoo (in the ir.attachment model) directly but we are stuck very fast by the fact that the Resource Model (res_model) or Resource ID (res_id) is a read only field and that it cannot be altered in a standard version. 

0
Avatar
Zrušit
faOtools

You may also use this third-party app - https://apps.odoo.com/apps/modules/15.0/cloud_base - to move attachments between folders and, hence, between linked objects. It is as simple as a mere drag and drop or choosing a field in the popup wizard.

Avatar
Adrien Konopek (adko)
Autor Nejlepší odpověď

Solution


What I propose here is to find a workaround by linking the attachments to a comment in the chatter (mail.message) where the Related Document Model (model) and Related Document ID (res_id) are editable. 

So, imagine that you have a file that is import compatible with many attachments (base64, direct link, ...) and that you want to import it and link it to a given record on a given model. This is all possible through the mail.message model and a hidden many2many field on the mail.message model. To do so, we are going to proceed in 4-5 steps (depending on how you want to divide your work flow): 

  1. Import all your attachments with the following fields: 
    1. External ID: The external ID of my attachment.
    2. Name ("name"): Name of the attachment.
    3. Type ("type"): Type of the attachment, URL or a file. Here I am going to import the attachment in a base64 format so I will select the "File" type. 
    4. File Content (base64) ("datas"): This is the content of your attachment directly. If the type is URL, we will have the "Url" field. I will focus on the former here.
  2. Export the models and record's database ID on which you will want to link the attachment to. This will be helpful to get the database ID for the following step. You can also retrieve the ID of the record from the URL, you just need to find "id=112" for instance.

  3. Import the messages on which you want to link the attachments with the following fields.
    1. External ID: The external ID of the chatter message. 
    2. Type ("type"): Here, I believe it is better to import on the "Comment" type so that your message stays internal to Odoo. It does not really matter at this point of the process but as the field is mandatory, we need to tell which type we need. 
    3. Related Document Model ("model"): This is the model on which you want to link the attachment
    4. Related Document ID ("res_id"): This is the ID (Database ID not the external ID) of the record on which you want to make the import. Just a reminder that the Database ID is unique per model and that the External ID is unique on the whole database). Note also that you will need to make an export of this as you cannot create/edit the ID. 
    5. You can add a subject (on "subject") and a body (on "body") so that the message looks cleaner.

  4. Add the many2many field pointing to ir.attachments (in the existing fields) to the mail.message model. You can do it as follow: https://watch.screencastify.com/v/0wNIkBbRsxtTEcrVItbO


  5. Import a mapping file on mail.message with the following fields: 
    1. External ID ("id"): This enables you to update the message record. 
    2. Attachments/External ID ("attachment_ids/id"): This will make the link between the ir.attachment model being the attachment and the message on which you want to make the import. 



Please find here a video on how I managed to do it. Note that I made step 1 in 2 steps as imported my content in a second step: https://watch.screencastify.com/v/xBFBq2v1SVpExbUMdnAv  


Note: Be aware that the order in which the messages (from mail.message) will be displayed is not based on the date field but on the order of the ID of the message. This means that if I have 2 messages A & B with respectively a date in 2021 and 2022 and that A has ID 5 and B ID 4, B will be displayed on the bottom and A on top. 


Please do not hesitate to reach out if you have any questions!

2
Avatar
Zrušit
Niswatus Syuyukhoh

I cant open your video link. I want to view the pdf without download it.

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

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

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
How it works: Product Costing, accounting for the value of products in real-time Vyřešeno
quickstart
Avatar
1
zář 25
5360
✅Change the Account on Payments in Odoo
quickstart
Avatar
0
bře 25
2155
✅Change the Account on Payments in Odoo
quickstart
Avatar
1
bře 25
30
✅ Change the order date to the Old date
quickstart
Avatar
0
bře 25
1860
Plugin ALMA
quickstart
Avatar
Avatar
Avatar
Avatar
3
zář 24
11078
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 je balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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