Passa al contenuto
Odoo Menu
  • Accedi
  • Provalo gratis
  • App
    Finanze
    • Contabilità
    • Fatturazione
    • Note spese
    • Fogli di calcolo (BI)
    • Documenti
    • Firma
    Vendite
    • CRM
    • Vendite
    • Punto vendita Negozio
    • Punto vendita Ristorante
    • Abbonamenti
    • Noleggi
    Siti web
    • Configuratore sito web
    • E-commerce
    • Blog
    • Forum
    • Live chat
    • E-learning
    Supply chain
    • Magazzino
    • Produzione
    • PLM
    • Acquisti
    • Manutenzione
    • Qualità
    Risorse umane
    • Dipendenti
    • Assunzioni
    • Ferie
    • Valutazioni
    • Referral dipendenti
    • Parco veicoli
    Marketing
    • Social marketing
    • E-mail marketing
    • SMS marketing
    • Eventi
    • Marketing automation
    • Sondaggi
    Servizi
    • Progetti
    • Fogli ore
    • Assistenza sul campo
    • Helpdesk
    • Pianificazione
    • Appuntamenti
    Produttività
    • Comunicazioni
    • Approvazioni
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    App di terze parti Odoo Studio Piattaforma cloud Odoo
  • Settori
    Retail
    • Libreria
    • Negozio di abbigliamento
    • Negozio di arredamento
    • Alimentari
    • Ferramenta
    • Negozio di giocattoli
    Cibo e ospitalità
    • Bar e pub
    • Ristorante
    • Fast food
    • Pensione
    • Grossista di bevande
    • Hotel
    Agenzia immobiliare
    • Agenzia immobiliare
    • Studio di architettura
    • Edilizia
    • Gestione immobiliare
    • Impresa di giardinaggio
    • Associazione di proprietari immobiliari
    Consulenza
    • Società di contabilità
    • Partner Odoo
    • Agenzia di marketing
    • Studio legale
    • Selezione del personale
    • Audit e certificazione
    Produzione
    • Tessile
    • Metallo
    • Arredamenti
    • Alimentare
    • Birrificio
    • Ditta di regalistica aziendale
    Benessere e sport
    • Club sportivo
    • Negozio di ottica
    • Centro fitness
    • Centro benessere
    • Farmacia
    • Parrucchiere
    Commercio
    • Tuttofare
    • Hardware e assistenza IT
    • Ditta di installazione di pannelli solari
    • Calzolaio
    • Servizi di pulizia
    • Servizi di climatizzazione
    Altro
    • Organizzazione non profit
    • Ente per la tutela ambientale
    • Agenzia di cartellonistica pubblicitaria
    • Studio fotografico
    • Punto noleggio di biciclette
    • Rivenditore di software
    Carica tutti i settori
  • Community
    Apprendimento
    • Tutorial
    • Documentazione
    • Certificazioni 
    • Formazione
    • Blog
    • Podcast
    Potenzia la tua formazione
    • Programma educativo
    • Scale Up! Business Game
    • Visita Odoo
    Ottieni il software
    • Scarica
    • Versioni a confronto
    • Note di versione
    Collabora
    • Github
    • Forum
    • Eventi
    • Traduzioni
    • Diventa nostro partner
    • Servizi per partner
    • Registra la tua società di contabilità
    Ottieni servizi
    • Trova un partner
    • Trova un contabile
    • Incontra un esperto
    • Servizi di implementazione
    • Testimonianze dei clienti
    • Supporto
    • Aggiornamenti
    GitHub Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Richiedi una demo
  • Prezzi
  • Aiuto

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

  • CRM
  • e-Commerce
  • Contabilità
  • Magazzino
  • PoS
  • Progetti
  • MRP
All apps
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
Assistenza

Easy way to transfer Settings from one database to another. Can I export them? Can I programmatically "configure" a database?

Iscriviti

Ricevi una notifica quando c'è un'attività per questo post

La domanda è stata contrassegnata
configurationdatabasetransferportabilityautomate
2 Risposte
8882 Visualizzazioni
Avatar
Community Question

Prior to configuring a production database, I am performing several manual configuration steps in development and staging branches.

It seems like I have to repeat all of these manual steps .

It is possible to export settings between databases?

Is it possible to programmatically configure a database?


1
Avatar
Abbandona
Avatar
Ray Carnes (ray)
Risposta migliore

Yes, you can script the configuration of a database and reuse the script.


Note: You need to (a) understand this is an advanced technique and (b) be familiar / fluent in using Python to set values for different types of data structures. Configuration options can be represented in different ways - check boxes, radio buttons, fields to enter text, fields to enter numbers, fields to select dates, fields to select related records, etc. - which translate to model fields of different types: boolean, selection, char, integer, date, many2one, etc. - and each needs a different method to set and/or change the value.


We do this in our test scripts, so you can also do it in your own scripts.  (Please test and verify what you think is happening is actually happening!).


In the code at https://github.com/odoo/odoo/blob/17.0/addons/base_setup/tests/test_res_config.py#L40 you can see these lines configure a database to support multiple currencies (res.config.settings is a transient model):

# get access to the configuration model
ResConfig = self.env['res.config.settings']

# get a copy of the default values
default_values = ResConfig.default_get(list(ResConfig.fields_get()))

# update the default values
default_values.update({'group_multi_currency': True})

# persist the updated defaults
ResConfig.create(default_values).execute()


Example:

Let's say we want to change the default currency of a database to $USD and also configure the database to support multi-currency, and the current configuration looks like this:



First, hover over each of the fields to see their technical name, since these are the fields you will need to update:

                   


Next, you can script.  This example uses a Scheduled Action configured as inactive so the only time it runs is when the RUN MANUALLY button is clicked.  You may prefer to write an XML-RPC based script. 




default_values = model.default_get(list(model.fields_get()))

default_values.update({
'currency_id': env.ref('base.USD').id,
'group_multi_currency': True
})

model.create(default_values).execute()


After the script is run:



You can also install modules:

for app in ['stock','account_consolidation','contacts','helpdesk','sale_purchase','sale_management','crm','web_studio']:
    env['ir.module.module'].search([('name','=',app)],limit=1).button_immediate_install()


Populate company data:

coname = 'ACME'
 
# ↓↓↓ add details to the main Company, "ACME USA Inc."
us_company = env.ref('base.main_company')
us_company.update({'name': coname + ' USA Inc.', 'street': '100 Main Street', 'city': 'Springfield', 'state_id': env.ref('base.state_us_5').id, 'zip': '90123'})


Activate currencies:

# ↓↓↓ Activate Currencies and rename prefixes
env.ref('base.AUD').update({'active': True,'symbol': '$AUD'})
env.ref('base.EUR')['active'] = True
env.ref('base.GBP')['active'] = True
env.ref('base.JPY')['active'] = True


Create fake historic data:

# ↓↓↓ Create CRM Teams
env.ref('sales_team.team_sales_department').update({'name': 'Farmers', 'company_id': 1})
farmers = env.ref('sales_team.team_sales_department').id
hunters = env['crm.team'].create({'name': 'Hunters'}).id

# ↓↓↓ Sort Sales Teams alphabetically
sorted_teams = env['crm.team'].search([]).sorted(key=lambda r: r.name)
for i in range(len(sorted_teams)):
  sorted_teams[i].update({'sequence': i})

# ↓↓↓  mediums for historic data
web = env.ref('utm.utm_medium_website').id
phone = env.ref('utm.utm_medium_phone').id

# ↓↓↓  historic data
for i in range(1,142):
  env.cr.execute("insert into crm_lead (create_date,active,name,medium_id,team_id,type) values ('%s','f','l',%d,%d,'lead')" % \
(datetime.datetime.today() - datetime.timedelta(weeks=52),phone,farmers))


If you are writing a module for this, you can also use the function tag to call model methods in your XML files.  See https://www.odoo.com/documentation/master/developer/reference/backend/data.html#function

9
Avatar
Abbandona
Ray Carnes (ray)

install module xml install app xml configure app xml configure module xml

Avatar
Agung Sepruloh
Risposta migliore

You can use this module https://apps.odoo.com/apps/modules/16.0/export_import_settings

-1
Avatar
Abbandona
Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!

Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!

Registrati
Post correlati Risposte Visualizzazioni Attività
How to transfer database from one account to another Odoo account?
database transfer
Avatar
Avatar
1
mar 24
3530
transfer a database
database transfer
Avatar
0
nov 23
2308
Set up a database from a configuration file
configuration database
Avatar
0
ott 25
4029
How to select one database by default ? Risolto
configuration database v7
Avatar
Avatar
Avatar
Avatar
Avatar
6
lug 24
85158
Internal Transfer error - Missing required account on accountable invoice line Risolto
configuration transfer internal
Avatar
Avatar
Avatar
Avatar
3
ago 24
7191
Community
  • Tutorial
  • Documentazione
  • Forum
Open source
  • Scarica
  • Github
  • Runbot
  • Traduzioni
Servizi
  • Hosting Odoo.sh
  • Supporto
  • Aggiornamenti
  • Sviluppi personalizzati
  • Formazione
  • Trova un contabile
  • Trova un partner
  • Diventa nostro partner
Chi siamo
  • La nostra azienda
  • Branding
  • Contattaci
  • Lavora con noi
  • Eventi
  • Podcast
  • Blog
  • Clienti
  • Note legali • Privacy
  • Sicurezza
الْعَرَبيّة 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 è un gestionale di applicazioni aziendali open source pensato per coprire tutte le esigenze della tua azienda: CRM, Vendite, E-commerce, Magazzino, Produzione, Fatturazione elettronica, Project Management e molto altro.

Il punto di forza di Odoo è quello di offrire un ecosistema unico di app facili da usare, intuitive e completamente integrate tra loro.

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