Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
11442 Lượt xem

Hi,

I am currently localizing the payroll_module of Odoo13 and one of our requirement for staging the database used in prod is to anonymize the confidential data. I've created a separate module to encrypt or just anonymize the data.

Currently I'm using Odoo shell to call the method that anonymize all records in a duplicated database. Is there such a way I could invoke the Odoo shell and pass some commands to it in a bash script?

 

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

After some effort, I found it:

echo "print(self.name)" | /path/to/env/python3 /odoo/path/odoo-community/odoo-bin shell -c /odoo/path/odoo.conf -d odoo --no-http
The output will be:
Administrator (or) System

The -no-http makes sure that it doesn't start a new web client.

In the echo, you can put whatever command you want to run, the variables available to you are:

env: <odoo.api.Environment object at ...>
odoo: <module 'odoo' from '/odoo/path/odoo-community/odoo/__init__.py'>
openerp: <module 'odoo' from '/odoo/path/odoo-community/odoo/__init__.py'>
self: res.users(1,)
Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 7 23
1600
1
thg 11 21
5065
11
thg 12 23
46716
0
thg 10 22
3413
0
thg 9 21
1508