www.numberspeaks.com

BLOG

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 …

How to use datetime in Python

  Exemple 1 : subtract 2 dates from datetime import datetime, date, timedelta date_1 = datetime.strptime(‘2018-06-01’, "%Y-%m-%d") date_2 = datetime.strptime(‘2018-06-04’, "%Y-%m-%d") diff_date = date_2 – date_1 print(diff_date.days) run the command. python3 -m script script.py root@numberspeaks.com:~#3 Exemple 2 : add or subtract days to a date from datetime import datetime, date, timedelta date_1 = datetime.strptime(‘2018-06-01’, "%Y-%m-%d") new_date = date_1 + timedelta(days=4) print(new_date) run the command. python3 -m script script.py root@numberspeaks.com:~#2018-06-05 00:00:00 Exemple 3 : today date from datetime import datetime, date, timedelta today_date = datetime.today() Exemple 4 : convert string to datetime from datetime import datetime, date, timedelta date = datetime.strptime(‘2018-06-01’, …

Problem with Godaddy VPS upgrade

I recently had a problem with Godaddy ubuntu 16.04 VPS, after updating and upgrading the system: apt-get update apt-get upgrade reboot SSH port wasn’t anymore reachable, it’s the only access we have to the server, however other services are working normally, so the system is still running. I tried many times to restart, call the support, but it didn’t solve the problem. The only solution was to destroy the server and rebuild it from scratch + restoration of backups. I’ve also tested the upgrade with a clean and freshly installed system, same issue occurred. If you’re running Ubuntu 16.04 VPS …

Create scheduled actions Odoo 9

Scheduled actions can be set by adding this code in your xml file. This exemple will call the function schedule_action from the model hr.employee and send a notification by email if the boolean enable_send_notification is True. <record id="ir_cron_schedule_action" model="ir.cron"> <field name="name">Schedule actions</field> <field name="user_id" ref="base.user_root" /> <field name="interval_number">1</field> <field name="interval_type">days</field> <field name="numbercall">-1</field> <field eval="False" name="doall" /> <field eval="’hr.employee’" name="model" /> <field eval="’schedule_action’" name="function" /> </record> This model inherits hr.employee and defines 1 additional field, and 2 additional functions. send_notification is sending email based on the the template my_module.email_hr_employee_notification, see this post how to create email template with xml, schedule_action is …

Odoo 11 community SO PO iOS approval

 Simple app to approve Odoo SO, PO from your iPhone / iPad, it has been tested only on Odoo Community 11, but it should work with newer version also. It requires an additional module on Odoo available on Github (link bellow). Odoo – NS module will add “Waiting for confirmation” Status on sale.order and purchase.order model.You will be able to customize the module and add any document that needs approval (like Invoices, payment confirmation, etc…)Long press on document from Odoo – NS iOS app will display PDF.If you have any question, you can contact me here:https://www.numberspeaks.com/contact/ 

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. import openerp.http as http from openerp.http import request import logging _logger = logging.getLogger(__name__) class Controller(http.Controller): @http.route([’/page/random/<string:variable>’], type=’http’, auth="user", methods=[’GET’], website=True) def view(self, **kwargs): values = dict(kwargs) object_ids = request.env[’model.name’].search([(‘your_field’,’=’, values[’variable’])]) values[’object_ids’] = object_ids values[’customer’] = object_ids[0].customer_id.name return request.render(‘module.template_id’, values) in folder view …