Skip ke Konten
Odoo Menu
  • Login
  • Uji coba gratis
  • Aplikasi
    Keuangan
    • Akuntansi
    • Faktur
    • Pengeluaran
    • Spreadsheet (BI)
    • Dokumen
    • Tanda Tangan
    Sales
    • CRM
    • Sales
    • POS Toko
    • POS Restoran
    • Langganan
    • Rental
    Website
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Rantai Pasokan
    • Inventaris
    • Manufaktur
    • PLM
    • Purchase
    • Maintenance
    • Kualitas
    Sumber Daya Manusia
    • Karyawan
    • Rekrutmen
    • Cuti
    • Appraisal
    • Referensi
    • Armada
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Acara
    • Otomatisasi Marketing
    • Survei
    Layanan
    • Project
    • Timesheet
    • Layanan Lapangan
    • Meja Bantuan
    • Planning
    • Appointment
    Produktivitas
    • Diskusi
    • Approval
    • IoT
    • VoIP
    • Pengetahuan
    • WhatsApp
    Aplikasi pihak ketiga Odoo Studio Platform Odoo Cloud
  • Industri-Industri
    Retail
    • Toko Buku
    • Toko Baju
    • Toko Furnitur
    • Toko Kelontong
    • Toko Hardware
    • Toko Mainan
    Makanan & Hospitality
    • Bar dan Pub
    • Restoran
    • Fast Food
    • Rumah Tamu
    • Distributor Minuman
    • Hotel
    Real Estate
    • Agensi Real Estate
    • Firma Arsitektur
    • Konstruksi
    • Estate Management
    • Perkebunan
    • Asosiasi Pemilik Properti
    Konsultansi
    • Firma Akuntansi
    • Mitra Odoo
    • Agensi Marketing
    • Firma huku
    • Talent Acquisition
    • Audit & Sertifikasi
    Manufaktur
    • Tekstil
    • Logam
    • Perabotan
    • Makanan
    • Brewery
    • Corporate Gift
    Kesehatan & Fitness
    • Sports Club
    • Toko Kacamata
    • Fitness Center
    • Wellness Practitioners
    • Farmasi
    • Salon Rambut
    Perdagangan
    • Handyman
    • IT Hardware & Support
    • Sistem-Sistem Energi Surya
    • Pembuat Sepatu
    • Cleaning Service
    • Layanan HVAC
    Lainnya
    • Organisasi Nirlaba
    • Agen Lingkungan
    • Rental Billboard
    • Fotografi
    • Penyewaan Sepeda
    • Reseller Software
    Browse semua Industri
  • Komunitas
    Belajar
    • Tutorial-tutorial
    • Dokumentasi
    • Sertifikasi
    • Pelatihan
    • Blog
    • Podcast
    Empower Education
    • Program Edukasi
    • Game Bisnis 'Scale Up!'
    • Kunjungi Odoo
    Dapatkan Softwarenya
    • Download
    • Bandingkan Edisi
    • Daftar Rilis
    Kolaborasi
    • Github
    • Forum
    • Acara
    • Terjemahan
    • Menjadi Partner
    • Layanan untuk Partner
    • Daftarkan perusahaan Akuntansi Anda.
    Dapatkan Layanan
    • Temukan Mitra
    • Temukan Akuntan
    • Temui penasihat
    • Layanan Implementasi
    • Referensi Pelanggan
    • Bantuan
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dapatkan demo
  • Harga
  • Bantuan

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

  • CRM
  • e-Commerce
  • Akuntansi
  • Inventaris
  • PoS
  • Project
  • MRP
All apps
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Help

Clean up filestore

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
filestore
5 Replies
14035 Tampilan
Avatar
Michael Schmidt

We're trying to clean up our filestore since its gradually growing and way beyond 100GB right now.
We are removing the avatar from the res.partner record, then observe that the 'image' related records are deleted automatically from the ir_attachment table.

However the files in the filestore related to the ir_attachment that is deleted remain in the filestore.
Do they ever get deleted, or are permanent?


The "Base: Auto-vacuum internal data" doesn't seem to do the job.

5
Avatar
Buang
Avatar
Auto-Matt
Jawaban Terbai

I actually have a interesing case. I currently run v15 on odoo.sh and I'm exporting database to try to import it with filestore to different machine for testing and I get 'virus' warning on some file in the odoo db dump.

I was able to locate the phisical file with it's name from antivirus and tried to search for the file in ir.attachment table using the field "Stored Filename" (technical name of field 'store_fname'). Result is the file name that is physically in database dump is not found in the ir.attachment, but the file is physically in the filestore folder when doing db backup.

This is where it gets interesting... in pararel I'm tring to migrate to v17 and have my staging running with v17 version with the same database backup, and there I can find the file in ir.attachment based on it's "Stored Filename".

I want to remove the file from v15 to continue migration, but I cannot locate it.

any ideas?

0
Avatar
Buang
Avatar
Stefan Wiselka
Jawaban Terbai

The scripts, written below, are missing one very important part.
If you use method search​ on model: ir.attachment​ without defining in domain fields: res_field​ or id​, it will exclude searching files saved in image fields, i.e profile photos of the users/partners

See: https://github.com/odoo/odoo/blob/fa20b5f2fed9e683c420798dce506a86fd5e511d/odoo/addons/base/models/ir_attachment.py#L527
We must change it, and add some workaround: ('id','!=',0)
self.search([('store_fname', '=', folder + '/' + file),('id','!=',0)])

0
Avatar
Buang
Avatar
Karsten Kinateder
Jawaban Terbai

# Working in production >= odoo12


import os

def cleanup_filestore(self):
# Get all attachments in the filestore

# Get the current database filestore
filestore_path = self._filestore()
# Get all folders from filestore_path
filestore_folders = os.listdir(filestore_path)
for folder in filestore_folders:
# Get all files per folder
folder_files = os.listdir(join(filestore_path, folder))
# Iterate over files
for file in folder_files:
attach_exist = self.search([('store_fname', '=', folder + '/' + file)])
print(str(attach_exist))
if len(attach_exist) == 0 and folder in file:
​ ​ ​ # folder in file is to check if it is a file created by odoo and to prvent to delete other
os.unlink(join(filestore_path, folder, file))


0
Avatar
Buang
Avatar
Muhammad Amir Nazir
Jawaban Terbai

In Odoo, the "Base: Auto-vacuum internal data" module is designed to periodically delete old records from the database to free up space and improve performance. However, this module does not delete files from the filestore that are no longer referenced in the database.

To clean up the filestore, you will need to manually delete the files that are no longer needed. One way to do this is to use a script that iterates over the ir_attachment table and checks which files are no longer referenced in the database. You can then delete the corresponding files from the filestore.

Here is an example of how you might implement this in Python:

Copy codeimport os

from odoo import api, models

class IrAttachment(models.Model):
    _inherit = 'ir.attachment'

    @api.model
    def cleanup_filestore(self):
        # Get all attachments in the filestore
        filestore_path = self.env['ir.config_parameter'].get_param('ir_attachment.location')
        filestore_files = os.listdir(filestore_path)

        # Iterate over all attachments in the database
        for attachment in self.search([]):
            # Check if the attachment's file is in the filestore
            if attachment.store_fname in filestore_files:
                # Check if the attachment is referenced in the database
                if not self.search([('store_fname', '=', attachment.store_fname)]):
                    # The attachment is not referenced in the database, so delete the file
                    os.unlink(os.path.join(filestore_path, attachment.store_fname))

You can run this script periodically to clean up the filestore, or you can run it manually as needed.

I hope this information is helpful. If you have any further questions about managing the filestore in Odoo, please don't hesitate to ask.


0
Avatar
Buang
Vincent Baggerman

I suspect this comment to be written by ChatGPT. Do not run the code that is mentioned.

Arsenty Karamurza

the idea is sensible but it should iterate through files NOT db entries.

Avatar
Pablo
Jawaban Terbai

Hi, how do you run it manually? thanks

0
Avatar
Buang
DIOR27

You can run it manually by using odoo shell (type ./odoo-bin shell or odoo shell in your terminal), you need to put line by line starting with filestore_path = self.env['ir.config_parameter'].get_param('ir_attachment.location') respecting the indentation

DIOR27

Also you can create a cron with the function and executing it manually

Menikmati diskusi? Jangan hanya membaca, ikuti!

Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!

Daftar
Post Terkait Replies Tampilan Aktivitas
Upload Large File Store to Odoo.sh Diselesaikan
filestore
Avatar
Avatar
1
Jul 25
7764
where is the filestore folder located on odoo 18
filestore
Avatar
Avatar
1
Feb 25
5510
where is filestore information saved in Odoo
filestore
Avatar
0
Nov 23
6570
How to set up a Remote filestore directory in odoo.conf?
filestore
Avatar
0
Mar 22
5433
File Bucket
filestore
Avatar
0
Okt 21
3388
Komunitas
  • Tutorial-tutorial
  • Dokumentasi
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Terjemahan
Layanan
  • Odoo.sh Hosting
  • Bantuan
  • Peningkatan
  • Custom Development
  • Pendidikan
  • Temukan Akuntan
  • Temukan Mitra
  • Menjadi Partner
Tentang Kami
  • Perusahaan kami
  • Aset Merek
  • Hubungi kami
  • Tugas
  • Acara
  • Podcast
  • Blog
  • Pelanggan
  • Hukum • Privasi
  • Keamanan
الْعَرَبيّة 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 adalah rangkaian aplikasi bisnis open source yang mencakup semua kebutuhan perusahaan Anda: CRM, eCommerce, akuntansi, inventaris, point of sale, manajemen project, dan seterusnya.

Mudah digunakan dan terintegrasi penuh pada saat yang sama adalah value proposition unik Odoo.

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