Author: ananthukrishna

pip install pyodbc failing: error: command ‘x86_64-linux-gnu-gcc’ failed with exit status 1

ODBC header files need to be installed.
1. sudo apt-get install unixodbc-dev
2. sudo pip install pyodbc


How to run automated actions at a specific time everyday

<record id="ir_cron_module_get_active_sr" model="ir.cron">
        <field name="name">Get Active Srs</field>
        <field eval="True" name="get_active_srs" />
        <!--<field name="user_id" ref="base.user_root" />-->
        <field name="interval_number">1</field>
        <field name="nextcall" eval="( + timedelta(days=1)).strftime('%Y-%m-%d 12:00:00')" />        
        <!--<field name="nextcall" eval="( + timedelta(days=1)).strftime('%Y-%m-%d 21:00:00')"/>-->
        <field name="interval_type">days</field>
        <field name="numbercall">-1</field>
        <field eval="False" name="doall" />
        <field eval="'hr.attendance'" name="model" />
        <field eval="'get_active_srs'" name="function" />
        <field eval="'(None,)'" name="args" />
        <field name="priority">1000</field>

How to call python function from QWeb

.xml code

<t t-foreach="o._get_purchase_mrn_details(o.origin,pack_operation.product_id)" t-as="purchase_line">
   <td class="text-right"><span t-esc="purchase_line['price_unit']"/></td>                            
   <td class="text-right"><span t-esc="purchase_line['taxes_id']"/></td>

.py code

    def _get_purchase_mrn_details(self,origin,product_id):
        if origin and product_id:
            purchase_data = []
            purchase_order_obj = self.env['purchase.order'].search([('name','=',origin)])
            order_line_ids = purchase_order_obj.order_line.mapped('product_id')
            for line in purchase_order_obj.order_line:
                if ==
                    purchase_data.append ({
                        'price_unit': line.price_unit,
                        'taxes_value': line.taxes_id.amount,
            return purchase_data

OSError: [Errno 98] Address already in use

odoo@odoo-11:~/odoo$ ps -fA | grep python

root 1680 1 1 09:16 ? 00:00:01 /usr/bin/python3 /usr/sbin/aptd
odoo 2369 2350 0 09:19 pts/10 00:00:00 grep python
odoo 5760 1 0 يون10 ? 00:01:07 python3 ./odoo-bin -d hr

odoo@odoo-11:~/odoo$ sudo kill 1680
odoo@odoo-11:~/odoo$ sudo kill 2369
odoo@odoo-11:~/odoo$ sudo kill 5760

How to Reset Encrypted Password for Admin User in Odoo v8, v9, v10 and v11?

Login as postgres user:

sudo su postgres;

Switch to the database in question:

psql <databaseName>;

List all users with their passwords:

select * from res_users;

Now copy the password and use it in the following command:

update res_users set password_crypt = ‘<copiedPasswordFromAbove>’ where id = ‘1’;

That’s it. Go and login with username admin and password you used to register the user in the first place.

If it helped you… don’t forget to share this post on your wall. It may be helpful to someone else.

Dump Postgresql

Dump DB
$ sudo pg_dump --no-owner db_name > /opt/db_name.sql or .dump

Restore DB
$ sudo su postgres
$ psql
$ create database db_name;
$ psql db_name > db_name.sql
Dump DB
$ sudo pg_dump --no-owner db_name | gzip > /opt/db_name.sql.gz

Restore DB
createdb  db_name -T template1 -U odoo -h localhost
zless db_name.sql.gz | psql db_name

VirtualBox can’t find host-only adapters on Windows 10

I get the same results when using the command lines tools. The creation of new interfaces works without problems:

C:\> VBoxManage.exe hostonlyif create
Interface 'VirtualBox Host-Only Ethernet Adapter #5' was successfully created

But VirtualBox can’t find the adapters, as the following command does not return any output:

$ VBoxManage.exe list hostonlyifs