Administrator/ Superuser rights OpenERP / Odoo

Administrator user, which is a super user (SUPERUSER_ID=1), has some extra access rights, that no other user are given.

  • Access Rules: If a model doesn’t have records in ir.model.access, then only Administrator user has access to that model.
  • Record rules: Record rules are not applied to the Administrator user.

Python Running from Command line

To run Python on Unbutu Command line

run command
$ python2.7
$ python3.5
or simply
$ python

Note: The last one (python) command will start the default version…
You will see below screen
Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
Type “help”, “copyright”, “credits” or “license” for more information.
Enter Python Code directly
>>> print (“Write on Console”)
Write on Console

Running Python file from command line
Enter command
$ python2.7
$ python3.5
or simpy
$ python

To get argument from command line
Enter command
$ python arg1, arg2, arg3

and your code in file should look like;

import sys
print (sys.argv)
file_name = sys.argv[0]
num1 = int(sys.argv[1])
num2 = int(sys.argv[2])
sum = num1 + num2
print (str(num1) + " + " + str(num2) + " = " + str(sum))

Note: the first argument will always be the name of a file, to get arguments other than file, use >> sys.agrv[1:]
Note: All argument are sent as of string data type.

Arguments Handling

import sys
print ("All Args: " + str(sys.argv))
print ("File Name: " + sys.argv[0])
print ("Other Args: " + str(sys.argv[1:]))

Running Postgresql Queries from Linux Command’s Terminal

To Access Postgresql Interface, Enter command

$ psql db_name

You will be switched to shell below

psql (9.5.5)
Type “help” for help.


Now run your queries as:

Queries for Information Schemas
db_name=# select table_name from information_schema.tables;
db_name=# select table_name from information_schema.tables where table_name is like ‘%cms%’;
db_name=# select table_name from information_schema.columns where table_name = ‘res_users’;

Queries for User Defined Tables
db_name=# select name, father_name from cms_entryregis where id in (1,2,3,4,5);

Using <xpath> in OpenERP/ odoo

<template id="report_saleorder_document">
  <t t-call="report.external_layout">
    <div class="page">
        <span t-field=""/>
      <table class="table table-condensed">
            <th class="text-right">Quantity</th>
            <th class="text-right">Unit Price</th>
            <th t-if="display_discount" class="text-right"</th>
            <th class="text-right">Taxes</th>
            <th class="text-right" name="price_subtotal_head">Price</th>

Using to add new label:

Option 1:

<xpath expr="//th[@name='price_subtotal_head']" position="after">
  <th class="text-right">New Label</th>

Option 2:

<xpath expr="//t/div/table/thead/tr/th[5]" position="after">
  <th class="text-right">New Label</th>

Option 3:

<xpath expr="//t/div/table/thead/tr/th[last()]" position="after">
  <th class="text-right">New Label</th>