Wednesday, 18 December 2013

Hide field in tree view based on condition

Hide Field in Tree view

In tree view we know how to put domain or attrs to visible or invisible any field,

But, if we want to hide particular field in tree view based on type or state means based on any condition , then its hard to hide as we cannot use attrs to hide as attrs hide only value not a field.

So, its need to put some condition like below as its get value from context and check.

invisible="context.get('picking_type', False) in ['in']"

Version : V8

Monday, 16 December 2013

Call xmlrpc when want to access functional field

Hello All,

In openerp sometimes we need to update database value on basis of some field value, we can direct do it but if we want to apply in old data then we use sql query and we update but if there is functional field which is not stored in database but you need to update data base on it. At that time we can do it by xmlrpc.

Here, i defined xmlrpc script in which if there is Purchase order which is 'received' and 'invoiced' but still not in 'done' state by this script purchase order gone in 'done' state.

Purchase Order Done :

import xmlrpclib
import time

username = 'admin' #the user
pwd = 'a'      #the password of the user
dbname = 'test'    #the database
model = 'purchase.order' # model name

# Get the uid
sock_common = xmlrpclib.ServerProxy ('http://localhost:8069/xmlrpc/common')
uid = sock_common.login(dbname, username, pwd)

#replace localhost with the address of the server
sock = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/object')

# argument passed to search
args = [('shipped', '=', True), ('state', 'not in', ['done']), ('invoice_method', 'in', ['manual','picking'])]
# search ids
ids = sock.execute(dbname, uid, pwd, model, 'search', args)

# READ functional field
ids_f = []
fields = ['invoiced']
po_ord = sock.execute(dbname, uid, pwd, model, 'read', ids, fields)
for re in po_ord :
    if re['invoiced'] :

# write state done
values = {'state':'done'}
results = sock.execute(dbname, uid, pwd, model, 'write', ids_f, values)

if ids_f :
    print "Successfully applied records ",ids_f
    print "No records found to update"