Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
5 Ответы
6125 Представления

I want to start Odoo from command line with database, language and country selected from command line.. Is that possible?

Аватар
Отменить
Лучший ответ

Hello, George!)

Tested on Odoo 14.

You can use curl or wget from terminal to achieve your goal:

curl -X POST -F 'master_pwd=dev' -F 'name=db_name_test' -F 'login=admin' -F 'password=admin' -F 'lang=ru_RU' -F 'country_code=by' -F 'phone=+375336665544' http://localhost:11469/web/database/create

Strange, but phone is made required (post['phone'] is used instead post.get('phone'), so you need to provide it not to catch the error.

Original code which parses data posted to /web/database/create:

@http.route('/web/database/create', type='http', auth="none", methods=['POST'], csrf=False)
def create(self, master_pwd, name, lang, password, **post):
insecure = odoo.tools.config.verify_admin_password('admin')
if insecure and master_pwd:
dispatch_rpc('db', 'change_admin_password', ["admin", master_pwd])
try:
if not re.match(DBNAME_PATTERN, name):
raise Exception(_('Invalid database name. Only alphanumerical characters, underscore, hyphen and dot are allowed.'))
# country code could be = "False" which is actually True in python
country_code = post.get('country_code') or False
dispatch_rpc('db', 'create_database', [master_pwd, name, bool(post.get('demo')), lang, password, post['login'], country_code, post['phone']])
request.session.authenticate(name, post['login'], password)
return http.local_redirect('/web/')
except Exception as e:
error = "Database creation error: %s" % (str(e) or repr(e))
return self._render_template(error=error)
Аватар
Отменить
Лучший ответ

Hi George

did you find the option to set the country in the command line? I'm trying to use the same command to create automatically the DB in a script

currently I'm using

./odoo-bin -c  ~/.odoorc -d mycompany -i base --load-language it_IT --stop-after-init 

and I'd like to have something like

./odoo-bin -c  ~/.odoorc -d mycompany -i base --load-language it_IT --country IT --stop-after-init 

but it doesn't work

thanks in advance




Аватар
Отменить
Лучший ответ

Hi, sorry for the late answer, but the parameters I've found are

-d database_name -i base --no-http --load-language=it_IT --stop-after-init
Аватар
Отменить
Автор Лучший ответ

 I want to specify the country on database creation .. there is language and country when creating a database so i want to select that from command line is that possible? 

Аватар
Отменить

As far as I know the db creation is a manual step. If you want to automate it, you may have to write a shell script using curl or wget to simulate the manual step. The following link provides information on how to use it for automated backup. You could write a similar script for database creation.

https://linuxize.com/post/how-to-setup-automatic-odoo-backup/

Hope this helps.

Лучший ответ

You can specify the database on the command line by using the --db-filter parameter. The language and country are specified at the time of creating the database itself.

Аватар
Отменить