Pular para o conteúdo
Odoo Menu
  • Entrar
  • Experimente grátis
  • Aplicativos
    Finanças
    • Financeiro
    • Faturamento
    • Despesas
    • Planilhas (BI)
    • Documentos
    • Assinar Documentos
    Vendas
    • CRM
    • Vendas
    • PDV Loja
    • PDV Restaurantes
    • Assinaturas
    • Locação
    Websites
    • Criador de Sites
    • e-Commerce
    • Blog
    • Fórum
    • Chat ao Vivo
    • e-Learning
    Cadeia de mantimentos
    • Inventário
    • Fabricação
    • PLM - Ciclo de Vida do Produto
    • Compras
    • Manutenção
    • Qualidade
    Recursos Humanos
    • Funcionários
    • Recrutamento
    • Folgas
    • Avaliações
    • Indicações
    • Frota
    Marketing
    • Redes Sociais
    • Marketing por E-mail
    • Marketing por SMS
    • Eventos
    • Automação de Marketing
    • Pesquisas
    Serviços
    • Projeto
    • Planilhas de Horas
    • Serviço de Campo
    • Central de Ajuda
    • Planejamento
    • Compromissos
    Produtividade
    • Mensagens
    • Aprovações
    • Internet das Coisas
    • VoIP
    • Conhecimento
    • WhatsApp
    Aplicativos de terceiros Odoo Studio Plataforma Odoo Cloud
  • Setores
    Varejo
    • Loja de livros
    • Loja de roupas
    • Loja de móveis
    • Mercearia
    • Loja de ferramentas
    • Loja de brinquedos
    Comida e hospitalidade
    • Bar e Pub
    • Restaurante
    • Fast Food
    • Hospedagem
    • Distribuidor de bebidas
    • Hotel
    Imóveis
    • Imobiliária
    • Escritório de arquitetura
    • Construção
    • Administração de propriedades
    • Jardinagem
    • Associação de proprietários de imóveis
    Consultoria
    • Escritório de Contabilidade
    • Parceiro Odoo
    • Agência de marketing
    • Escritório de advocacia
    • Aquisição de talentos
    • Auditoria e Certificação
    Fabricação
    • Têxtil
    • Metal
    • Móveis
    • Alimentação
    • Cervejaria
    • Presentes corporativos
    Saúde e Boa forma
    • Clube esportivo
    • Loja de óculos
    • Academia
    • Profissionais de bem-estar
    • Farmácia
    • Salão de cabeleireiro
    Comércio
    • Handyman
    • Hardware e Suporte de TI
    • Sistemas de energia solar
    • Sapataria
    • Serviços de limpeza
    • Serviços de climatização
    Outros
    • Organização sem fins lucrativos
    • Agência Ambiental
    • Aluguel de outdoors
    • Fotografia
    • Aluguel de bicicletas
    • Revendedor de software
    Navegar por todos os setores
  • Comunidade
    Aprenda
    • Tutoriais
    • Documentação
    • Certificações
    • Treinamento
    • Blog
    • Podcast
    Empodere a Educação
    • Programa de educação
    • Scale Up! Jogo de Negócios
    • Visite a Odoo
    Obtenha o Software
    • Baixar
    • Comparar edições
    • Releases
    Colaborar
    • Github
    • Fórum
    • Eventos
    • Traduções
    • Torne-se um parceiro
    • Serviços para parceiros
    • Cadastre seu escritório contábil
    Obtenha os serviços
    • Encontre um parceiro
    • Encontre um Contador
    • Conheça um consultor
    • Serviços de Implementação
    • Referências de Clientes
    • Suporte
    • Upgrades
    Github YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Faça uma demonstração
  • Preços
  • Ajuda

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

  • CRM
  • e-Commerce
  • Financeiro
  • Inventário
  • PoS
  • Projeto
  • MRP
All apps
É necessário estar registrado para interagir com a comunidade.
Todas as publicações Pessoas Emblemas
Marcadores (Ver tudo)
odoo accounting v14 pos v15
Sobre este fórum
É necessário estar registrado para interagir com a comunidade.
Todas as publicações Pessoas Emblemas
Marcadores (Ver tudo)
odoo accounting v14 pos v15
Sobre este fórum
Ajuda

How to convert from filestore to databasestore?

Inscrever

Seja notificado quando houver atividade nesta publicação

Esta pergunta foi sinalizada
v6.1databasefilestore
2 Respostas
13517 Visualizações
Avatar
ton123

Does anybody know an easy method how to convert all the knowledgemanagement files in the filestore internal or external to database and visa versa?

4
Avatar
Cancelar
Avatar
Andreas Brueckl
Melhor resposta

I have migrated from databasestore to a filesystem storage. Therefore I have used the following python-Script. Maybe this can help you. I have applied this script on OpenERP version 6.0, but the functionality should be the same.

#!/usr/bin/python

# Check total size afterwards: "du -b <filestore>" minux 4096 (size of dir '.')
# Check total size in DB: "select sum(file_size) from ir_attachment"
# UPDATE SQL: 
# update ir_attachment set db_datas = null
# --select count(*) from ir_attachment
# where store_fname is not null 
#

import xmlrpclib

username = 'admin' #the user
pwd = 'xxx'      #the password of the user
dbname = 'prod_2812'    #the database

# Get the uid
sock_common = xmlrpclib.ServerProxy ('http://localhost:8069/xmlrpc/common')
uid = sock_common.login(dbname, username, pwd)
sock = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/object')

FILESTORE = 2

def migrate_attachment(att_id):
    # 1. get data
    att = sock.execute(dbname, uid, pwd, 'ir.attachment', 'read', att_id, ['datas','parent_id'])

    dir_id = att['parent_id'][0]
    data = att['datas']

    # 2. Save old storage_id
    dir = sock.execute(dbname, uid, pwd, 'document.directory', 'read', dir_id, ['storage_id'])
    old_storage_id = dir['storage_id'][0]

    if old_storage_id == FILESTORE:
        print "skipping"
        return

    # Set storage to "FileStore"
    sock.execute(dbname, uid, pwd, 'document.directory', 'write', [dir_id], {'storage_id': FILESTORE})

    # Re-Write attachment
    a = sock.execute(dbname, uid, pwd, 'ir.attachment', 'write', [att_id], {'datas': data})

    # Reset storage to "Database"
    sock.execute(dbname, uid, pwd, 'document.directory', 'write', [dir_id], {'storage_id': old_storage_id})


# SELECT attachemnts:
att_ids = sock.execute(dbname, uid, pwd, 'ir.attachment', 'search', [('parent_id','=',1),('store_fname','=',False)])

cnt = len(att_ids)
i = 0
for id in att_ids:
    att = sock.execute(dbname, uid, pwd, 'ir.attachment', 'read', id, ['datas','parent_id'])

    migrate_attachment(id)
    print 'Migrated ID %d (attachment %d of %d)' % (id,i,cnt)
    i = i + 1
#    if i > 10:
#        break

print "done ..."
7
Avatar
Cancelar
ton123
Autor

Thanks Andreas! I am not familiar with python so I need time to study and test. As a matter of fact I have an old v6.0 version with database store with 300 documents in it. I am happy I can convert if needed. And I also think a script doing the opposite can be made based on this script.

ton123
Autor

Although the answer is not 100% touch, for me it is good enough to vote for correct answer.

Avatar
Giulio Marcon
Melhor resposta

I modified the script for OpenERP 7.0:

#!/usr/bin/python

import xmlrpclib

username = 'admin' #the user
pwd = 'password'      #the password of the user
dbname = 'database'    #the database

# Get the uid
sock_common = xmlrpclib.ServerProxy ('<URL>/xmlrpc/common')
uid = sock_common.login(dbname, username, pwd)
sock = xmlrpclib.ServerProxy('<URL>/xmlrpc/object')

def migrate_attachment(att_id):
    # 1. get data
    att = sock.execute(dbname, uid, pwd, 'ir.attachment', 'read', att_id, ['datas'])            

    data = att['datas']

    # Re-Write attachment
    a = sock.execute(dbname, uid, pwd, 'ir.attachment', 'write', [att_id], {'datas': data})

# SELECT attachments:
att_ids = sock.execute(dbname, uid, pwd, 'ir.attachment', 'search', [('store_fname','=',False)])

cnt = len(att_ids)        
i = 0
for id in att_ids:
    att = sock.execute(dbname, uid, pwd, 'ir.attachment', 'read', id, ['datas','parent_id'])

    migrate_attachment(id)
    print 'Migrated ID %d (attachment %d of %d)' % (id,i,cnt)
    i = i + 1

print "done ..."

After running the script, clean up your ir_attachments table:

update ir_attachment set db_datas = null where store_fname is not null
vacuum (full, analyze) ir_attachment

Replace <URL> with your OpenERP installation URL (sorry for that, I do not have enough Karma to post the standard localhost link).

5
Avatar
Cancelar
ton123
Autor

Thank you Giulio. This is becoming a nice collection of scripts! Hope we can collect the backwards conversion also.

Lithin T

How can I restore the files from Filesystem to database?

phoebe

Hi Giulio, I'm not sure where to settle this script. I just put it to under openerp installation directory and, change the <URL> part and login information part, and type 'python migration.py' (I called it like that). Then I would get 'done...' in the terminal screen. but in fact, no change in the filestore folder. Could you kindly teach me how to handle the script? Thanks in advance and sorry I'm a newbie in OpenERP

Está gostando da discussão? Não fique apenas lendo, participe!

Crie uma conta hoje mesmo para aproveitar os recursos exclusivos e interagir com nossa incrível comunidade!

Inscreva-se
Publicações relacionadas Respostas Visualizações Atividade
DB table relating Partner and its Payment term
v6.1 database
Avatar
Avatar
Avatar
Avatar
Avatar
4
jan. 17
12066
database backup keep getting corrupted
database filestore odoo16
Avatar
Avatar
2
mar. 25
2142
ir_attachment_force_storage then files not found
database filestore attachments
Avatar
0
ago. 18
4493
ODOO9: which is better filestore or database store Resolvido
database filestore odoo9
Avatar
Avatar
1
mar. 16
6470
Where the files uploaded on openerp are stocked ?
database filestore v7
Avatar
Avatar
1
mar. 15
5003
Comunidade
  • Tutoriais
  • Documentação
  • Fórum
Open Source
  • Baixar
  • Github
  • Runbot
  • Traduções
Serviços
  • Odoo.sh Hosting
  • Suporte
  • Upgrade
  • Desenvolvimentos personalizados
  • Educação
  • Encontre um Contador
  • Encontre um parceiro
  • Torne-se um parceiro
Sobre nós
  • Nossa empresa
  • Ativos da marca
  • Contato
  • Empregos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidade
  • Segurança
الْعَرَبيّة 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 é um conjunto de aplicativos de negócios em código aberto que cobre todas as necessidades de sua empresa: CRM, comércio eletrônico, contabilidade, estoque, ponto de venda, gerenciamento de projetos, etc.

A proposta de valor exclusiva Odoo é ser, ao mesmo tempo, muito fácil de usar e totalmente integrado.

Site feito com

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