www.numberspeaks.com

BLOG

How to use datetime in Python

  Exemple 1 : subtract 2 dates run the command. Exemple 2 : add or subtract days to a date run the command. Exemple 3 : today date Exemple 4 : convert string to datetime Exemple 5 : convert datetime to string

How to search string in files Linux

Use this command bellow to find a pattern in the arborescence. https://stackoverflow.com/questions/16956810/how-do-i-find-all-files-containing-specific-text-on-linux

Odoo – Redirect user to a page in python

This code bellow will redirect the user to customer invoice page, you will be able to set the model you would like to use with res_model and the id of the record in res_id, the view template in views, target can have new or self value. new value will open a popup and display the requested page, self will load the page in the current window.

How to get data from URL with a controller in Odoo 9

Create under your module a folder controller, in that folder create files controller.py and __init__.py and link your new file in __init__.py, don’t forget to add controller folder in the __init__.py at the root folder of your module. controller.py code bellow will make available the URL www.myodoo.com/page/random/random_variable, random_variable value will be stored in values dictionary on key variable. in folder view of your module create the file template.xml

Linux

Odoo 9 Linux bash backup script

Bash backup odoo script is available on GitHub for Odoo 8 and 11. This bash script will help you to backup Odoo database, set a password on the backup file and remove files older than 7 days. You’ll need curl and 7zip linux package to make it work. This example is backing up od11-01 and od11-02 databases. It’s not really optimized with the double compression. BACKUP_DIR=/opt/backup ODOO_DATABASES="od11-01 od11-02" ADMIN_PASSWORD="ODOO_DATABASE_MANAGER_PASSORD" FILE_PASSWORD="ZIP_FILE_PASSWORD" TIMESTAMP=`date +%Y-%m-%d_%H-%M-%S` for DB in ${ODOO_DATABASES} do # create a backup curl -X POST \ -F "master_pwd=${ADMIN_PASSWORD}" \ -F "name=${DB}" \ -F "backup_format=zip" \ -o ${BACKUP_DIR}/${DB}/${DB}.${TIMESTAMP}.zip \ http://localhost:8069/web/database/backup 7z a …

Disable database manager in Odoo

Module for odoo 8 and 11 available on Github. Some tips found on the web hides only the link from Odoo homepage however URL are still reachable (~/web/database/manager). By installing this module, it will filter the access to Odoo database manager through the controller except connections coming from IPs listed in system parameters. Whitelist option: Key: disable_database_manager.database_manager_whitelist Value: 192.168.1.1,192.168.1.2,etc… This module will avoid unwanted connections attempts and secure your database manager access. Works with NGINX with some modification on nginx config file, click here for more detail. To disable completely database manager access: Add list_db = False in odoo.conf / …