Ready to get started?

Download a free trial of the Odoo Data Provider to get started:

 Download Now

Learn more:

Odoo Icon Odoo ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with Odoo ERP data, including Sales Orders, Purchase Orders, Accounts,, and more!

Automate Odoo Integration Tasks from PowerShell



Are you in search of a quick and easy way to access Odoo data from PowerShell? This article demonstrates how to utilize the Odoo Cmdlets for tasks like connecting to Odoo data, automating operations, downloading data, and more.

The CData Cmdlets for Odoo are standard PowerShell cmdlets that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time and bidirectional access to Odoo.

PowerShell Cmdlets or ADO.NET Provider?

The Cmdlets are not only a PowerShell interface to Odoo, but also an SQL interface; this tutorial shows how to use both to create, retrieve, update, and delete Odoo data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for Odoo. To access Odoo data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for Odoo.

Once you have acquired the necessary connection properties, accessing Odoo data in PowerShell can be enabled in three steps.

To connect, set the Url to a valid Odoo site, User and Password to the connection details of the user you are connecting with, and Database to the Odoo database.

PowerShell

  1. Install the module:

    Install-Module OdooCmdlets
  2. Connect:

    $odoo = Connect-Odoo -User "$User" -Password "$Password" -URL "$URL" -Database "$Database"
  3. Search for and retrieve data:

    $id = "1" $res_users = Select-Odoo -Connection $odoo -Table "res_users" -Where "id = `'$id`'" $res_users

    You can also use the Invoke-Odoo cmdlet to execute SQL commands:

    $res_users = Invoke-Odoo -Connection $odoo -Query 'SELECT * FROM res_users WHERE id = @id' -Params @{'@id'='1'}

ADO.NET

  1. Load the provider's assembly:

    [Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Odoo\lib\System.Data.CData.Odoo.dll")
  2. Connect to Odoo:

    $conn= New-Object System.Data.CData.Odoo.OdooConnection("User=MyUser;Password=MyPassword;URL=http://MyOdooSite/;Database=MyDatabase;") $conn.Open()
  3. Instantiate the OdooDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT name, email from res_users" $da= New-Object System.Data.CData.Odoo.OdooDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.name $_.email }

Update Odoo Data

PowerShell

Update-Odoo -Connection $Odoo -Columns @('name','email') -Values @('Myname', 'Myemail') -Table res_users -Id "MyId"

ADO.NET

$cmd = New-Object System.Data.CData.Odoo.OdooCommand("UPDATE res_users SET id='1' WHERE Id = @myId", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.Odoo.OdooParameter("@myId","10456255-0015501366"))) $cmd.ExecuteNonQuery()

Insert Odoo Data

PowerShell

Add-Odoo -Connection $Odoo -Table res_users -Columns @("name", "email") -Values @("Myname", "Myemail")

ADO.NET

$cmd = New-Object System.Data.CData.Odoo.OdooCommand("INSERT INTO res_users (id) VALUES (@myid)", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.Odoo.OdooParameter("@myid","1"))) $cmd.ExecuteNonQuery()

Delete Odoo Data

PowerShell

Remove-Odoo -Connection $Odoo -Table "res_users" -Id "MyId"

ADO.NET

$cmd = New-Object System.Data.CData.Odoo.OdooCommand("DELETE FROM res_users WHERE Id=@myId", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.Odoo.OdooParameter("@myId","001d000000YBRseAAH"))) $cmd.ExecuteNonQuery()