Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

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

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

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

Subscribe

Get notified when there's activity on this post

This question has been flagged
configurationdatabasetransferportabilityautomate
2 Replies
8869 Views
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
Discard
Avatar
Ray Carnes (ray)
Best Answer

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
Discard
Ray Carnes (ray)

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

Avatar
Agung Sepruloh
Best Answer

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

-1
Avatar
Discard
Enjoying the discussion? Don't just read, join in!

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

Sign up
Related Posts Replies Views Activity
How to transfer database from one account to another Odoo account?
database transfer
Avatar
Avatar
1
Mar 24
3522
transfer a database
database transfer
Avatar
0
Nov 23
2305
Set up a database from a configuration file
configuration database
Avatar
0
Oct 25
4015
How to select one database by default ? Solved
configuration database v7
Avatar
Avatar
Avatar
Avatar
Avatar
6
Jul 24
85141
Internal Transfer error - Missing required account on accountable invoice line Solved
configuration transfer internal
Avatar
Avatar
Avatar
Avatar
3
Aug 24
7178
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة 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 is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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