Siirry sisältöön
Odoo Menu
  • Kirjaudu sisään
  • Kokeile ilmaiseksi
  • Sovellukset
    Talous
    • Kirjanpito
    • Laskutus
    • Kulut
    • Datataulukot (BI)
    • Asiakirjat
    • Allekirjoita
    Myynti
    • CRM
    • Myynti
    • Kassajärjestelmä myymälään
    • Kassajärjestelmä ravintolaan
    • Tilaukset
    • Vuokraus
    Verkkosivut
    • Verkkosivun Rakennustyökalu
    • Verkkokauppa
    • Blogi
    • Foorumi
    • Livechat
    • Verkko-oppiminen
    Toimitusketju
    • Varastointi
    • Tuotanto
    • Tuotteen elinkaaren hallinta (PLM)
    • Ostot
    • Huolto
    • Laatu
    Henkilöstöhallinto
    • Työntekijät
    • Rekrytointi
    • Vapaat
    • Arvioinnit
    • Suositukset
    • Kuljetuskalusto
    Markkinointi
    • Somemarkkinointi
    • Sähköpostimarkkinointi
    • Tekstiviestimarkkinointi
    • Tapahtumat
    • Markkinoinnin automaatio
    • Kyselyt
    Palvelut
    • Projekti
    • Työaikakirjaukset
    • Kenttähuolto
    • Asiakaspalvelu
    • Suunnittelu
    • Ajanvaraukset
    Tuottavuus
    • Viestintä
    • Hyväksynnät
    • IoT
    • IP-puhe
    • Tietokirjasto
    • WhatsApp
    Kolmannen osapuolen sovellukset Odoo-Studio Odoo-Pilvialusta
  • Toimialat
    Vähittäiskauppa
    • Kirjakauppa
    • Vaatekauppa
    • Huonekaluliike
    • Ruokakauppa
    • Laitteistokauppa
    • Lelukauppa
    Ruoka & Majoitus
    • Baari ja Pubi
    • Ravintola
    • Pikaruoka
    • Majatalo
    • Juomien jakelija
    • Hotelli
    Kiinteistöt
    • Kiinteistönvälitystoimisto
    • Arkkitehtitoimisto
    • Rakentaminen
    • Kiinteistönhallinta
    • Puutarhanhoito
    • Kiinteistön omistajien yhdistys
    Konsultointi
    • Tilitoimisto
    • Odoo-kumppani
    • Markkinointitoimisto
    • Lakitoimisto
    • Osaajahankinta
    • Tilintarkastus & sertifiointi
    Tuotanto
    • Tekstiili
    • Metalli
    • Huonekalut
    • Ruoka
    • Panimo
    • Yrityslahjat
    Terveys & Liikunta
    • Urheiluseura
    • Silmälasiliike
    • Kuntokeskus
    • Hyvinvointialan ammattilaiset
    • Apteekki
    • Kampaamo
    Kaupat
    • Yleismies
    • IT-laitteisto & Tuki
    • Aurinkoenergiajärjestelmät
    • Suutari
    • Siivouspalvelut
    • LVI-palvelut
    Muut
    • Voittoa tavoittelematon järjestö
    • Ympäristötoimisto
    • Mainostaulujen vuokraus  
    • Valokuvaus
    • Leasing-pyörät
    • Ohjelmistojen jälleenmyyjä
    Selaa kaikkia toimialoja
  • Yhteisö
    Opi
    • Kurssit
    • Dokumentaatio
    • Todistukset
    • Koulutus
    • Blogi
    • Podcast
    Kannusta kouluttautumaan
    • Koulutusohjelmat
    • Scale Up! Liiketoimintapeli
    • Vieraile Odoolla
    Hanki ohjelmisto
    • Lataa
    • Vertaile versioita
    • Julkaisut
    Tee yhteistyötä
    • Github
    • Foorumi
    • Tapahtumat
    • Käännökset
    • Ryhdy kumppaniksi
    • Kumppanipalvelut
    • Rekisteröi tilitoimistosi
    Hanki palveluja
    • Löydä kumppani
    • Löydä kirjanpitäjä
    • Varaa asiantuntijatapaaminen
    • Implementaatiopalvelut
    • Asiakasreferenssit
    • Tuki
    • Versionkorotukset
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Varaa demo
  • Hinnoittelu
  • Asiakaspalvelu

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Kirjanpito
  • Varastointi
  • PoS
  • Projekti
  • MRP
All apps
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Kaikki kirjoitukset Ihmiset Merkit
Tunnisteet (Näytä kaikki)
odoo accounting v14 pos v15
Tietoa tästä foorumista
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Kaikki kirjoitukset Ihmiset Merkit
Tunnisteet (Näytä kaikki)
odoo accounting v14 pos v15
Tietoa tästä foorumista
Apua

How to connect a Google Script to Openerp(odoo) using XML RPC?

Tilaa

Saat ilmoituksen, kun tähän viestiin ilmaantuu aktiviteettia

Tämä kysymys on merkitty
12 Vastaukset
14904 Näkymät
Avatar
Anabela Damas

Hi, 

I've made a python script using XML  RPC to connect to openerp and create res.partners and it works fine.

Now I wonder if the same is possible in a google script?

I've tried but I can't connect to openerp!

Do you know the library to use, or a clue to start implementing the connection through XML RPC in a google script? 

I've tried to use this code https://github.com/ikikko/Mimic-for-Google-Apps-Script/blob/master/mimic-gas.js , and then this :
 

function teste() {
  var method = "login" ; 
  var request = new XmlRpcRequest("http://192.168.2.141:8086/xmlrpc/common", method); 
  request.addParam('testes'); 
  request.addParam('admin'); 
  request.addParam('password'); 
  request.setAuthentication('admin','password','testes');
  //var request_aut = request.setAuthentication('admin','vi!aveirofast#69');
  //Logger.log(request);
  //Logger.log('___________________________________');
  var response = request.send(); 
  //var response = request_aut.send(); 
  //Logger.log(response);
  //Logger.log(response.parseXML());
  return response.parseXML(); 
};

 

But I always get the error : 

Unable to parse the text. (line 253, file "Code")

253:    return new XmlRpcResponse(Xml.parse(response.getContentText()));

 

Doing Logger.log(response); the log is empthy... 

Thanks

2
Avatar
Hylkää
Sehrish

Try this one: http://learnopenerp.blogspot.com/2019/10/connecting-to-odoo-using-xml-rpc.html

Avatar
Jdugomier
Paras vastaus

Hi, 

Here is a very simple / small GSCript to connect to Odoo but using JSONRPC :


function OdooJSONRPC2(db_settings)

{

/**

* Random client id generation. To be provided in jsonrpc calls and returned to differentiate requests if necessary.

*/

this._guid = function() {

function s4() {

return Math.floor((1 + Math.random()) * 0x10000)

.toString(16)

.substring(1);

}

return s4() + s4() + "-" + s4() + "-" + s4() + "-" +

s4() + "-" + s4() + s4() + s4();

}

/**

* Jsonrpc2 call (internal function)

* @param jsonrpc_method : type of jsonrpc method (ex: call)

* @param url : url on which jsonrpc needs to be called

* @param params : json object with the API parameters

**/

this._jsonrpc2_call = function(jsonrpc_method,url,params)

{

var json = JSON.stringify({

"jsonrpc": "2.0",

"method" : jsonrpc_method,

"id" : this.id,

"params": params

});

var headers = {

"Content-Type" : "application/json",

"Accept" : "application/json",

};

if(this.sid)

{ //adds the session_id in the request (in a cookie). Optional because doesn"t exist on the first call (authentication)

headers["Cookie"]="session_id="+this.sid;

}

var options = {

method: "post",

payload : json,

headers : headers,

contentLength : json.length

};

return JSON.parse(UrlFetchApp.fetch(url,options).getContentText());

}

this.search_read = function(model,params)

{

params["model"]=model;

return this._jsonrpc2_call("call",db_settings.base_location + "/web/dataset/search_read",params).result.records;

}

/* constructor : after the methods declaration because some methods are used by constructor */

this.db_settings = db_settings;

this.id = this._guid();

if(this.db_settings["db"] && this.db_settings["login"] && this.db_settings["password"] && this.db_settings["base_location"])

{

this.sid = this._jsonrpc2_call("call",db_settings.base_location + "/web/session/authenticate",db_settings).result.session_id;

}

else

{

throw "Incomplete DB settings required keys are : db, login, password, base_location";

}

}


//Examples

  var odoo = new OdooJSONRPC2({"db": "?", "login": "?","password": "?","base_location": "?"});

var rental_products = odoo.search_read("product.template",{"domain" : [["rental_ok","=","true"]], "fields":["id"]});

var specific_product = odoo.search_read("product.template",{"domain" : [["id","=",52]], "fields":["display_name"]});

var product_by_id = odoo.search_read("product.template",{"domain" : [["id","in",[50,51,52]]], "fields":["display_name"]});

2
Avatar
Hylkää
Randy Risser

Thank you for this info! It was extremely helpful.

Randy Risser

Is there any way to create/write records from google script?

Avatar
tommy.henry@5b.com.au
Paras vastaus

Hi there,

This topic seems pretty dead but I was having the exact same issue and managed to figure it out so thought I should post here. The easiest approach I found, which most closely matches the method in the odoo api documentation is as follows:

First: Include the XMLRPC library in your appscript project using the following library code (In your appscript project go to Resources > Library > Add):

My_8O8KRa_MszCVjoC01DTlqpU7Swg-M5

Then, if you are following these odoo api documentation steps:
https://www.odoo.com/documentation/11.0/webservices/odoo.html
you can modify the code as follows to make the same methods work in appscript:

url = <insert server URL>
db = <insert database name>
username = <insert username>
password = <insert password>​
// Authenticate user and get uid:
var common = new XMLRPC.XmlRpcRequest(url + "/xmlrpc/2/common", "authenticate");
common.addParam(db);
common.addParam(username);
common.addParam(password);
common.addParam({});

uid = common.send().parseXML();
// Check access right
var models = new XMLRPC.XmlRpcRequest(url + "/xmlrpc/2/object", "execute_kw");
models.addParam(db);
models.addParam(uid);
models.addParam(password);

models.addParam('res.partner');
models.addParam('check_access_rights');
models.addParam(['read']);
models.addParam({'raise_exception': False});

var response = models.send().parseXML();
// create user
var models = new XMLRPC.XmlRpcRequest(url + "/xmlrpc/2/object", "execute_kw");
models.addParam(db);
models.addParam(uid);
models.addParam(password);

models.addParam('res.partner');
models.addParam('create');
models.addParam([{
'name': "New Partner",
}]);

id = models.send().parseXML();
1
Avatar
Hylkää
Randy Risser

Hello, Thanks so much for your reply to this post! Have you tested the script you posted? I can't get it to work. Something seems to be missing.

Randy Risser

One of the errors I am getting.

"TypeError: Cannot call method "addParam" of undefined. (line 10, file "Code")"

Doesn't this:

var common = XMLRPC.XmlRpcRequest(url + "/xmlrpc/2/common", "authenticate");

Need to be somthing like:

var common = new XMLRPC.XmlRpcRequest(url + "/xmlrpc/2/common", "authenticate");

tommy.henry@5b.com.au

yep good catch missed that bit when I was writing it up for this post. I've amended my reply above :)

tommy.henry@5b.com.au

If it's useful I've started building out an odoo api for appscript: 1cz44Ex1_MaQAw6u57aAf3ozA2utiTJarpqxf3wOoZ6tUNnQX6C7Bpre9

or https://github.com/tommyhenry90/odooAppscriptApi

tommy.henry@5b.com.au

project key for above api is: Mz85GDFoKyx2elkECWYElEvQMf9HPR6wp

Randy Risser

Could you give a search_read example yet? I can't seem to figure out the syntax.

Randy Risser

Also, just not saw your post on the API for appscript! That is awesome! The community will really appreciate this! When you get time if you could give examples in your readme for the calls like here: https://github.com/faisalsami/odoo-xmlrpc#usage

tommy.henry@5b.com.au

I've added create, read, update and delete methods to the api now and added some more documentation on github. Please let me know if you find this helpful or run into any issues. :)

Randy Risser

Awesome work! If you could add one more thing.

The "Search and Read" https://www.odoo.com/documentation/11.0/webservices/odoo.html#search-and-read

I use that to get data back from a search with the related field contents. Thanks again for doing this!

tommy.henry@5b.com.au

I added searchRecord and searchReadRecord yesterday and added a bit more documentation on github. should also now be able to update and delete multiple records at once.

Avatar
Fausto R.
Paras vastaus

I will be workiing on this approach next week, so I am very interested.

However, note that GAS (Google Apps Script) is runing on Google servers, so they cannot access an Odoo server in your local network.

This aproach might / should work with Odoo online, though I am still struggling with the right url:port to use.

ps. I am new to this forum, so I cannot post a question yet

1
Avatar
Hylkää
Anabela Damas
Tekijä

Hope that my "like" helps you to get karma ;) For you to post questions about GAS.

OdooBot
thanks Anabela
yes, it helped !!
I already posted my question, thanks

ps. this is the link, still dealing with Python sample scripts before working from GAS


Regards, Fausto | 416-821-3185 | go.theXS.ca/now | simplifying IT

On Fri, Nov 28, 2014 at 9:39 AM, Anabela Damas <adamas-versaointegral-pt@mail.odoo.com> wrote:

Hope that my "like" helps you to get karma ;) For you to post questions about GAS.

--
Anabela Damas
Sent by Odoo S.A. using Odoo about Forum Post False

Avatar
Ludo - 21South
Paras vastaus

What have you tried? Where did your script stop and what was the error? 

I am by no means an expert in google script, but the error might be explained from the OpenERP point of view.

------------

One thing I noticed is that the url of your connection is pointing to port 8086. Have you tried port 8069, which is the default for XML-RPC in OpenERP?

Other than that, the parse error usually means that you are trying to parse something using the wrong format OR the field itself does not exist.

0
Avatar
Hylkää
Anabela Damas
Tekijä

I've update my answer. Thanks for try to help =)

Anabela Damas
Tekijä

**question

Ludo - 21South

Updated the answer. Perhaps someone with some more experience can answer the question better.

Anabela Damas
Tekijä

cat /etc/openerp-server.conf | grep xmlrpc xmlrpcs = False xmlrpcs_interface = xmlrpcs_port = 8087 xmlrpc_interface = xmlrpc_port = 8086 xmlrpc = True I'm using the correct port. Thanks

Nautitko keskustelusta? Älä vain lue, vaan osallistu!

Luo tili jo tänään nauttiaksesi yksinoikeusominaisuuksista ja osallistuaksesi mahtavaan yhteisöömme!

Rekisteröidy
Yhteisö
  • Kurssit
  • Dokumentaatio
  • Foorumi
Avoin lähdekoodi
  • Lataa
  • Github
  • Runbot
  • Käännökset
Palvelut
  • Odoo.sh hosting
  • Tuki
  • Versionkorotus
  • Räätälöidyt kehitykset
  • Koulutus
  • Löydä kirjanpitäjä
  • Löydä kumppani
  • Ryhdy kumppaniksi
Meistä
  • Yrityksemme
  • Brändiominaisuudet
  • Ota yhteyttä
  • Työpaikat
  • Tapahtumat
  • Podcast
  • Blogi
  • Asiakkaat
  • Oikeudellinen ilmoitus • Yksityisyys
  • Tietoturva
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo on kokoelma avoimen lähdekoodin yrityssovelluksia, jotka kattavat kaikki yrityksesi tarpeet: asiakkuudenhallinta eli CRM, verkkokauppa, kirjanpito, varastointi, kassajärjestelmä, projektinhallinta, jne.

Odoon uniikki arvolupaus on olla samanaikaisesti erittäin helppokäyttöinen ja täysin integroitu.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now