Thursday, October 30, 2014

Make field readonly / display or hide a field in Odoo / OpenERP conditionally

Make a field read-only or visible based on another field value in Odoo / Openerp
Ex1: Hide field field1 when field2 has no data

<field name="field1" attrs="{'invisible':[('field2', '!=', False)]}"/>

Ex2: Hide field field1 when field2 has no data:
<field name="field1" attrs="{'readonly':[('field2', '!=', False)]}"/>


Wednesday, October 15, 2014

Create new OpenERP database, and get DataError: new encoding (UTF8) is incompatible


Create new OpenERP database, and get DataError: new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII)
HINT: Use the same encoding as in the template database, or use template0 as template

1.1 - ERROR ? openerp.sql_db: bad query: CREATE DATABASE ENCODING 'unicode' TEMPLATE "template1" Traceback (most recent call last):

Fix steps:
Login to Postgresql:
# sudo -u postgres psql

Then execute these statements:
postgres=# UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';
postgres=# DROP DATABASE template1;
postgres=# CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = ‘UNICODE’;
postgres=# UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1'
postgres=# \c template1
psql (8.4.13)
You are now connected to database “template1″.
template1=# VACUUM FREEZE;

Then you just have to \q to quit. and rerun the openerp server + run the database creation.