-
Notifications
You must be signed in to change notification settings - Fork 2
OpenERP/Odoo toolkit for client-side XML-RPC testing and scripting
License
nmbooker/oekit
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
OpenERP Kit =========== Author: Nick Booker License: GPLv3 oekit is a collection of libraries and utilities to make interacting with an OpenERP server from scripts and Python prompts that little bit easier, with that bit less repeition. It turns out, for use in scripts and debugging, there's a better module 'erppeek', which provides better proxies to the objects. However you might still find some of the command line tools provided here useful, or the ability to configure via environment variables. You can also use the method get_erppeek_client() on an OEClientEnv object to instantiate an erppeek.Client object based on your OE_CLIENT_* environment variables, should you so wish, if you have erppeek installed. Modules ------- Take a look at the pydoc for those: $ pydoc oekit $ pydoc oekit.oeproxy $ pydoc oekit.oe_client_env $ pydoc oekit.csvdump Scripts ------- Setting up your environment ........................... $ export OE_CLIENT_URL=http://localhost:8069 $ export OE_CLIENT_DBNAME=mytestdb $ export OE_CLIENT_USER=admin $ export OE_CLIENT_PASSWORD=password oe_dump_csv ........... Dump the contents of an OpenERP model as CSV. $ oe_dump_csv res.partner id name id,name 1,Fred Bloggs 2,A Company You might want to pip install csvkit. Then you can get the output in a nice tabular format: $ oe_dump_csv res.partner id name | csvlook |-----+--------------| | id | name | |-----+--------------| | 1 | Fred Bloggs | | 2 | A Company | |-----+--------------| oe_dump_csv also accepts an option -i or --ids-stdin. If you provide this, stdin is read line-by-line. Each line is expected to contain a single id and nothing else. Only the records matching the ids on stdin are output. So in the above example data set you might get this: $ echo 1 | res.partner --ids-stdin id name | csvlook |-----+--------------| | id | name | |-----+--------------| | 1 | Fred Bloggs | |-----+--------------| oe_describe ........... Dump the list of fields in a model to CSV Adding '-n' would only display the field names, without a header. Note the implicit 'id' field isn't included in the output. $ ./oe_describe ir.cron | csvlook |------------------+-----------+-----------+----------------------| | field_name | type | relation | string | |------------------+-----------+-----------+----------------------| | active | boolean | | Active | | args | text | | Arguments | | doall | boolean | | Repeat Missed | | function | char | | Method | | interval_number | integer | | Interval Number | | interval_type | selection | | Interval Unit | | model | char | | Object | | name | char | | Name | | nextcall | datetime | | Next Execution Date | | numbercall | integer | | Number of Calls | | priority | integer | | Priority | | user_id | many2one | res.users | User | |------------------+-----------+-----------+----------------------| oe_list_models .............. Dump a list of models. -M MODULE_NAME restricts the output to the models declared or subclassed by the given module -m only outputs the model (x.y.z) without a header, instead of a CSV table with other info This example restricts to a small module, because there are a lot if you leave it unrestricted. $ ./oe_list_models -M sale | csvlook |-------------------------------+-------------------------------+------------+--------| | model | name | osv_memory | state | |-------------------------------+-------------------------------+------------+--------| | account.config.settings | account.config.settings | True | base | | account.invoice | Invoice | False | base | | mail.compose.message | Email composition wizard | True | base | | res.partner | Partner | False | base | | sale.advance.payment.inv | Sales Advance Payment Invoice | True | base | | sale.config.settings | sale.config.settings | True | base | | sale.make.invoice | Sales Make Invoice | True | base | | sale.order | Sales Order | False | base | | sale.order.line | Sales Order Line | False | base | | sale.order.line.make.invoice | Sale OrderLine Make_invoice | True | base | | sale.report | Sales Orders Statistics | False | base | | sale.shop | Sales Shop | False | base | |-------------------------------+-------------------------------+------------+--------| Here's the number of models currently installed in my OpenERP test database: $ ./oe_list_models -m | wc -l 364 odoo.backup_db .............. Example: $ odoo.backupdb --admin-password adminpass -u http://odooserver:8069 -o mydb.zip mydb With any luck the above should log into the database manager for the Odoo running on odooserver port 8069 with password adminpass (note this is the password for the database manager, and not the password for the admin user of the database itself), and download a backup of the mydb database (including database and filestore) and putting it in the zip file mydb.zip in your current directory. Without -o it will output the zip file on STDOUT, and without -u it will try to use the OE_CLIENT_URL environment variable.
About
OpenERP/Odoo toolkit for client-side XML-RPC testing and scripting
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published