Skip to main content

Do massive operations on Odoo Cloud

Project description

License: AGPL-3

Overview

Introduction

Clodoo is a set of tools to manage to manage multiple Odoo installations with many DBs.

With clodoo you can do massive operations on 1 or more Odoo databases based on different Odoo versions. Main operation are:

  • create consistent database to run tests

  • repeat consistent action on many db with same or different Odoo version

  • repeat above actions on every new database

clodoo is also a PYPI package to simplify RPC connection to Odoo. The PYPI package is a hub to oerplib and odoorpc packages, so generic python client can execute any command to any Odoo version server (from 6.1 to 13.0)

Available commands & features are:

Function

Note

Add new repository

odoo_install_repository

Update paid invoice

inv2draft_n_restore.py

List requirement of Odoo

list_requirements.py

Create full configurated Odoo DB

manage_db

Manage Odoo installation

manage_odoo

Set Odoo Skin (backoffice)

odoo_skin.sh

Run Odoo instance to debug

run_odoo_debug

Manage version depending names

transodoo.py

General Purpose RPC

clodoo.py

Export Odoo model to test file

export_db_model.py

Migrate Odoo

migrate_odoo.py (deprecated)

Examples

example*.py

clodoo.py: general Purpose RPC

clodoo.py ia general purpose xmlrpc / json interface. It is called by bash console, there is no funcional web/GUI interface.

$ usage: clodoo.py [-h] [-A actions] [-b version] [-c file] [-d regex] [-D]

[-l iso_lang] [-n] [-p dir] [-P password] [-q] [-r port] [-U username] [-u list] [-v] [-V] [-x]

optional arguments:
-h, --help

show this help message and exit

-A actions, --action-to-do actions

action to do (use help to dir)

-b version, --odoo-branch version

talk server Odoo version

-c file, --config file

configuration command file

-d regex, --dbfilter regex

DB filter

-D, --with-demo

create db with demo data

-l iso_lang, --lang iso_lang

user language

-n, --dry-run

test execution mode

-p dir, --data-path dir

Import file path

-P password, --pwd password

login password

-q, --quiet

run silently

-r port, --xmlrpc-port port

xmlrpc port

-U username, --user username

login username

-u list, --upgrade-modules list

Module list to upgrade

-v, --verbose

run with debugging output

-V, --version

show program’s version number and exit

-x, --exit-on-error

exit on error

Import_file

Import file loads data from a csv file into DB. This action works as standard Odoo but has some enhanced features. Field value may be:

  • external identifier, format module.name (as Odoo standard) i.e. ‘base.main_company’

  • text with macros, format ${macro} (no Odoo standard), dictionary passed i.e. ‘${company_id}’ text may contains one or more macros

  • text with DB extraction, format ${model:values} (w/o company, no Odoo std) i.e. ‘${res.company:your company}’ data is searched by name

  • text with DB extraction, format ${model::values} (with company, no Odoo std) i.e. ‘${res.partner::Odoo SA}’ data is searched by name, company from ctx[‘company_id’]

  • text with DB extraction, format ${model(params):values} (w/o company) i.e. ‘${res.company(zip):1010}’ data is searched by param(s)

  • text with function, format ${function(params)::values} (add company) i.e. ‘${res.partner(zip)::1010}’ data is searched by param(s), company from ctx[‘company_id’]

  • full text function, format ${function[field](params):values} (w/o company) full text function, format ${function[field](params)::values} (add company) i.e. ‘${res.partner[name](zip)::1010}’ data is searched as in above function; returned value is not id but field

  • crypted data, begins with $1$! i.e ‘$1$!abc’

  • expression, begin with = (deprecated)

  • odoo multiversion text, format model.constant.0 (in model replace ‘.’ by ‘_’) i.e. ‘res_groups.SALES.0’

  • odoo versioned value, format model.value.majversion i.e. ‘res_groups.Sales.8’

Predefines macros (in ctx):

company_id default company_id company_name name of default company (if company_id not valid) country_code ISO-3166 default country (see def_country_id) customer-supplier if field contains ‘customer’ or ‘client’ set customer=True if it contains ‘supplier’ or ‘vendor’ or ‘fornitore’ set supplier=True def_country_id default country id (from company or from user) def_email default mail; format: {username}{majversion}@example.com full_model load all field values, even if not in csv header_id id of header when import header/details files lang language, format lang_COUNTRY, i.e. it_IT (default en_US) name2 if present, is merged with name name_first if present with name last, are merged to compose name name_last if present with name first, are merged to compose name street2 if present and just numeric, is merged with street zeroadm_mail default user mail from conf file or <def_mail> if -D switch zeroadm_login default admin username from conf file oneadm_mail default user2 mail from conf file or <def_mail> if -D switch oneadm_login default admin2 username from conf file botadm_mail default bot user mail from conf file or <def_mail> if -D switch botadm_login default bot username from conf file _today date.today() _current_year date.today().year _last_year’ date.today().year - 1 TNL_DICT dictionary with field translation, format csv_name: field_name; i.e {‘partner_name’: ‘name’} or csv_position: field_name, i.e. {‘0’: ‘name’} TNL_VALUE dictionary with value translation for field; format is field_name: {csv_value: field_value, …} i.e. {‘country’: {‘Inghilterra’: ‘Regno Unito’}} special value ‘$BOOLEAN’ return True or False DEFAULT dictionary with default value, format field_name: value EXPR evaluate value from expression, format csv_name: expression; expression can refer to other fields of csv record in format csv[field_name] or other fields of record in format row[field_name] i.e. {‘is_company’: ‘row[“ref”] != “”’} {‘is_company’: ‘csv[“CustomerRef”] != “”’} MANDATORY dictionary with mandatory field names

Import searches for existing data (this behavior differs from Odoo standard) Search is based on <o_model> dictionary; default field to search is ‘name’ or ‘id’, if passed.

File csv can contain some special fields:
db_type: select record if DB name matches db type; values are
    'D' for demo,
    'T' for test,
    'Z' for zeroincombenze production,
    'V' for VG7 customers
    'C' other customers
oe_versions: select record if matches Odoo version
    i.e  +11.0+10.0 => select record if Odoo 11.0 or 10.0
    i.e  -6.1-7.0 => select record if Odoo is not 6.1 and not 7.0

odoo_install_repository: manage repositories

Usage: odoo_install_repository [-h][-b branch][-c file][-CDjLmn][-O git-org][-o path][-qrU][-u username][-Vvy1] git_repo odoo_vid new_odoo_vid
Add or duplicate odoo repository into local filesystem
 -h              this help
 -b branch       default odoo branch
 -c file         configuration file (def .travis.conf)
 -C              do not touch configuration file (conflict with -D)
 -D              update default values in /etc configuration file before creating script (conflict with -C)
 -j              install only repository owned by git organization
 -L              create symbolic link rather copy files (if new_odoo_ver supplied)
 -m              multi-version odoo environment
 -n              do nothing (dry-run)
 -O git-org      git organization, one of oca oia[-git|-http] zero[-git|-http] (def zero)
 -o path         odoo directory
 -q              silent mode
 -r              do just update remote info (if no new_odoo_ver supplied)
 -U              do not install, do upgrade
 -u username     execute as username (def=odoo)
 -V              show version
 -v              verbose mode
 -y              assume yes
 -1              if clone depth=1

odoorc: general purpose bash function

The bash file odoorc is a general purpose Odoo library. It supplies some Odoo values from odoo_vid or from odoo directory. Some values may depends by environment:

  • ODOO_DB_USER is the rule to return db username (def odoo%(MAJVER)s)

  • ODOO_GIT_HOSTNAME is the git hostname (def github.com)

  • ODOO_GIT_SHORT -> regex of git organizzations with vid short name (def /(oca)/, see odoo-vid)

Usage:

. odoorc RES=$(build_odoo_param PARAM odoo_vid [(search|DEBUG|default|tree|SERVER|<rptname>|<modname>)] [oca|zero|zero-http|zero-git|librerp|flectra] [(search|DEBUG|default|tree|SERVER)])

where:

PARAM is one of (ALL|BIN|CONFN|DB_USER|DDIR|FLOG|FPID|FULLVER|FULL_SVCNAME|GIT_BRANCH|GIT_OPTS|GIT_ORG|GIT_ORGNM|GIT_PROT|GIT_URL|HOME|INVALID_MODNAMES|INVALID_MODNAMES_RE|LICENSE|LCONFN|MAJVER|MANIFEST|OCB_SUBDIRS|OCB_SUBDIRS_RE|OPTS_ASM|PARENTDIR|PKGNAME|PKGPATH|REPOS|ROOT|RORIGIN|RPCPORT|RUPSTREAM|SVCNAME|UPSTREAM|URL|URL_BRANCH|USER|VCS|VDIR|VENV)



Getting started

N/A

Prerequisites

Zeroincombenze tools require:

  • Linux Centos 7/8 or Debian 9/10 or Ubuntu 18/20/22

  • python 2.7+, some tools require python 3.6+

  • bash 5.0+

Installation

N/A

Stable version via Python Package

pip install clodoo

Current version via Git

cd $HOME
git clone https://github.com/zeroincombenze/tools.git
cd ./tools
./install_tools.sh -p
source $HOME/devel/activate_tools

Upgrade

Stable version via Python Package

pip install clodoo -U

Current version via Git

cd $HOME
./install_tools.sh -U
source $HOME/devel/activate_tools

ChangeLog History

2.0.7 (2023-09-26)

  • [FIX] Some fixes due old wrong code (id -> name)

2.0.7.0.7

  • [IMP] Incorporated new pypi oerlib3

  • [IMP] Discriminate http_port and xmlrpc_port to avoid mistake

  • [IMP] New param IS_MULTI

2.0.7.0.7

  • [FIX] clodoo.py: minor fixes

  • [IMP] odoorc: odoo version 16.0

2.0.7.0.7

  • [IMP] odoorc: minor improvements

  • [IMP] odoorc: test for Odoo 16.0

  • [IMP] transodoo.py: minor improvements

2.0.7.0.7

  • [FIX] odoorc: GIT_BRANCH sometimes fails



Credits

Authors

Contributors

Antonio M. Vigliotti <antoniomaria.vigliotti@gmail.com>


This module is part of tools project.

Last Update / Ultimo aggiornamento: 2023-10-27

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

clodoo-2.0.7.tar.gz (151.5 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page