Setting Settings with Doodba

Using an Odoo shell script

Graeme Gellatly

I have become a big fan of Tecnativa's Doodba project in everything but name.  One of the great things it has is the ability to easily run scripts.  One of the big challenges with developing Odoo is faithfully reproducing development into test and production (and vice versa).  This is often not so much a function of the code involved, or even the modules installed, but rather the data, especially when it comes to settings.

The obvious benefit of having this scripted is it saves time. It also means you can be comfortable that a fresh database is setup correctly, especially if combined with a profile module. But perhaps less obvious, it means that configuration and subsequent changes are documented and under version control.

Below is an example script to set settings.

#!/usr/local/bin/python-odoo-shell

# docker-compose run --rm odoo custom/shell-scripts/<filename>.py

conf = env['res.config.settings'].create({
"group_multi_currency": True,
"group_product_variant": True,
"group_uom": True,
"group_discount_per_so_line": True,
"group_sale_delivery_address": True,
"group_warning_sale": True,
"group_warning_purchase": True,
"group_warning_stock": True,
"group_manage_vendor_price": True,
"group_stock_production_lot": True,
"group_stock_multi_warehouses": True,
"group_stock_multi_locations": True,
"group_stock_adv_location": True,
"group_warning_account": True,
"group_multi_company": True,

"module_sale_order_dates": True,
"module_crm_phone_validation": True,
"module_stock_dropshipping": True,
"module_procurement_jit": 1,
"module_stock_picking_batch": True,
"module_purchase_requisition": True,

"default_purchase_method": "receive",
"default_picking_policy": "one",
"default_invoice_policy": "order",

"auto_done_setting": True,
"auth_signup_uninvited": "b2b",
"crm_phone_valid_method": "no_prefix",
"sale_show_tax": "subtotal",
"external_report_layout": 'clean',
"partner_names_order": 'first_last',
"multi_sales_price": True,
"multi_sales_price_method": 'formula',
"tax_calculation_rounding_method": 'round_globally',
})
env.cr.commit()
conf.execute()
env.cr.commit()