Odoo RPC Call Python Script

Odoo RPC Call Python Script

Probuse Admin

Odoo CMS- Sample image floating  

#!/usr/bin/env python

import odoorpc

# Prepare the connection to the server

odoo = odoorpc.ODOO('localhost', port=8069)

# Check available databases


# Login

odoo.login('leave', 'admin', 'a')

# Current user

user = odoo.env.user

print(user.name) # name of the user connected

print(user.company_id.name) # the name of its company

# Simple 'raw' query

user_data = odoo.execute('res.users', 'read', [user.id])


# Use all methods of a model

Order = odoo.env['sale.order']

order_ids = Order.search([])

for order in Order.browse(order_ids):


     products = [line.product_id.name for line in order.order_line]


# Update data through a record

user.name = "Brian Jones"

print('User Name',user.name)