~openerp-chinese-team/openobject-doc/Chinese-init

« back to all changes in this revision

Viewing changes to i18n/zh_CN/source/developer/12_api.rst

  • Committer: JoshuaJan
  • Date: 2012-12-04 01:36:44 UTC
  • Revision ID: popkar77@gmail.com-20121204013644-k25kpyac672wxe22
Chinese initialization

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
.. i18n: ===
 
3
.. i18n: API
 
4
.. i18n: ===
 
5
..
 
6
 
 
7
===
 
8
API
 
9
===
 
10
 
 
11
.. i18n: Working with Web Services
 
12
.. i18n: =========================
 
13
..
 
14
 
 
15
Working with Web Services
 
16
=========================
 
17
 
 
18
.. i18n: Given the architecture of OpenERP, it is not possible to reliably access the
 
19
.. i18n: database with the PostgreSQL client or through a direct connection method
 
20
.. i18n: such as ODBC.
 
21
.. i18n: Fortunately, OpenERP provides a very comprehensive set of web services that
 
22
.. i18n: allow you to do everything through standard protocols.
 
23
..
 
24
 
 
25
Given the architecture of OpenERP, it is not possible to reliably access the
 
26
database with the PostgreSQL client or through a direct connection method
 
27
such as ODBC.
 
28
Fortunately, OpenERP provides a very comprehensive set of web services that
 
29
allow you to do everything through standard protocols.
 
30
 
 
31
.. i18n: .. note::
 
32
.. i18n:    Though it is technically possible, you must be aware that this can have
 
33
.. i18n:    disastrous consequences for your data, unless you know exactly what you are
 
34
.. i18n:    doing. You are advised to shut down the OpenERP server when accessing the
 
35
.. i18n:    database to avoid caching and concurrency issues.
 
36
..
 
37
 
 
38
.. note::
 
39
   Though it is technically possible, you must be aware that this can have
 
40
   disastrous consequences for your data, unless you know exactly what you are
 
41
   doing. You are advised to shut down the OpenERP server when accessing the
 
42
   database to avoid caching and concurrency issues.
 
43
 
 
44
.. i18n: Supported Web Services Protocols
 
45
.. i18n: --------------------------------
 
46
.. i18n: The currently supported protocols are XML-RPC and Net-RPC. XML-RPC is one of the
 
47
.. i18n: first standard for web services, and can be used in almost any language.
 
48
.. i18n: It is a pretty verbose protocol, which may sometimes introduce a bit of latency.
 
49
.. i18n: Net-RPC, on the other hand, is an optimized protocol particularly designed for
 
50
.. i18n: use between applications written in Python.
 
51
..
 
52
 
 
53
Supported Web Services Protocols
 
54
--------------------------------
 
55
The currently supported protocols are XML-RPC and Net-RPC. XML-RPC is one of the
 
56
first standard for web services, and can be used in almost any language.
 
57
It is a pretty verbose protocol, which may sometimes introduce a bit of latency.
 
58
Net-RPC, on the other hand, is an optimized protocol particularly designed for
 
59
use between applications written in Python.
 
60
 
 
61
.. i18n: Support for REST-style webservices is planned for future releases of OpenERP.
 
62
..
 
63
 
 
64
Support for REST-style webservices is planned for future releases of OpenERP.
 
65
 
 
66
.. i18n: Support for the SOAP protocol is deprecated at the moment, but could maybe be
 
67
.. i18n: revived if sufficient interest is found in the community.
 
68
..
 
69
 
 
70
Support for the SOAP protocol is deprecated at the moment, but could maybe be
 
71
revived if sufficient interest is found in the community.
 
72
 
 
73
.. i18n: Available Web Services
 
74
.. i18n: ----------------------
 
75
.. i18n: The OpenERP server provides you with the following web services.
 
76
..
 
77
 
 
78
Available Web Services
 
79
----------------------
 
80
The OpenERP server provides you with the following web services.
 
81
 
 
82
.. i18n: .. note::
 
83
.. i18n:     You may find out the details of each service in the corresponding class
 
84
.. i18n:     in the server sources, in bin/service/web_services.py .
 
85
..
 
86
 
 
87
.. note::
 
88
    You may find out the details of each service in the corresponding class
 
89
    in the server sources, in bin/service/web_services.py .
 
90
 
 
91
.. i18n: :db:
 
92
.. i18n:     Provides functions to create, drop, backup and restore databases.
 
93
.. i18n:     Use with caution!
 
94
..
 
95
 
 
96
:db:
 
97
    Provides functions to create, drop, backup and restore databases.
 
98
    Use with caution!
 
99
 
 
100
.. i18n: :common:
 
101
.. i18n:     Lets you log in and out of OpenERP, and provides various utility functions. You
 
102
.. i18n:     will need to call the function "login" before you can use most of the other
 
103
.. i18n:     web services.
 
104
..
 
105
 
 
106
:common:
 
107
    Lets you log in and out of OpenERP, and provides various utility functions. You
 
108
    will need to call the function "login" before you can use most of the other
 
109
    web services.
 
110
 
 
111
.. i18n: :object:
 
112
.. i18n:     The most useful web service, as it provides access to the OpenERP Objects.
 
113
.. i18n:     Most notably, the function "execute" lets you call methods of the Objects, such
 
114
.. i18n:     as moste of the ORM methods to search, read and write records. It can also be
 
115
.. i18n:     used to call any other method of the object, such as computing a price for
 
116
.. i18n:     example.
 
117
..
 
118
 
 
119
:object:
 
120
    The most useful web service, as it provides access to the OpenERP Objects.
 
121
    Most notably, the function "execute" lets you call methods of the Objects, such
 
122
    as moste of the ORM methods to search, read and write records. It can also be
 
123
    used to call any other method of the object, such as computing a price for
 
124
    example.
 
125
 
 
126
.. i18n: .. note::
 
127
.. i18n:     Here is a quick reminder of the main ORM methods:
 
128
.. i18n:     
 
129
.. i18n:     create({'field':'value'})
 
130
.. i18n:           * Creates a new record with the specified value
 
131
.. i18n:           * Returns: id of the new record
 
132
.. i18n:     
 
133
.. i18n:     search([('arg1','=','value1')...], offset=0, limit=1000)
 
134
.. i18n:           * arg1, arg2, .. ,argN: list of tuples specifying search criteria
 
135
.. i18n:           *    offset: optional number of records to skip
 
136
.. i18n:           * limit: optional max number of records to return
 
137
.. i18n:           * Returns: list of IDS of records matching the given criteria 
 
138
.. i18n:     
 
139
.. i18n:     read([IDS], ['field1','field2',...])
 
140
.. i18n:           * fields: optional list of field names to return (default: all fields)
 
141
.. i18n:           * Returns: the id of each record and the values of the requested field
 
142
.. i18n:       
 
143
.. i18n:     write([IDS], {'field1':'value1','field2':3})
 
144
.. i18n:           * values: dictionary of field values to update
 
145
.. i18n:           * Updates records with given ids with the given values
 
146
.. i18n:           * Returns: True
 
147
.. i18n:     
 
148
.. i18n:     unlink([IDS])
 
149
.. i18n:           * Deletes records with the given ids
 
150
.. i18n:           * Returns: True
 
151
.. i18n:           
 
152
.. i18n:     browse() can't be used through web services.
 
153
..
 
154
 
 
155
.. note::
 
156
    Here is a quick reminder of the main ORM methods:
 
157
    
 
158
    create({'field':'value'})
 
159
          * Creates a new record with the specified value
 
160
          * Returns: id of the new record
 
161
    
 
162
    search([('arg1','=','value1')...], offset=0, limit=1000)
 
163
          * arg1, arg2, .. ,argN: list of tuples specifying search criteria
 
164
          *     offset: optional number of records to skip
 
165
          * limit: optional max number of records to return
 
166
          * Returns: list of IDS of records matching the given criteria 
 
167
    
 
168
    read([IDS], ['field1','field2',...])
 
169
          * fields: optional list of field names to return (default: all fields)
 
170
          * Returns: the id of each record and the values of the requested field
 
171
      
 
172
    write([IDS], {'field1':'value1','field2':3})
 
173
          * values: dictionary of field values to update
 
174
          * Updates records with given ids with the given values
 
175
          * Returns: True
 
176
    
 
177
    unlink([IDS])
 
178
          * Deletes records with the given ids
 
179
          * Returns: True
 
180
          
 
181
    browse() can't be used through web services.
 
182
 
 
183
.. i18n: Another useful function is "exec_workflow", which lets you make a record
 
184
.. i18n: progress through a workflow.
 
185
..
 
186
 
 
187
Another useful function is "exec_workflow", which lets you make a record
 
188
progress through a workflow.
 
189
 
 
190
.. i18n: :wizard:
 
191
..
 
192
 
 
193
:wizard:
 
194
 
 
195
.. i18n: Provides access to the old-style wizards. Please note that the new-style wizards
 
196
.. i18n: are based on the ORM, and as such they can be accessed though the "object" web
 
197
.. i18n: service.
 
198
..
 
199
 
 
200
Provides access to the old-style wizards. Please note that the new-style wizards
 
201
are based on the ORM, and as such they can be accessed though the "object" web
 
202
service.
 
203
 
 
204
.. i18n: :report:
 
205
..
 
206
 
 
207
:report:
 
208
 
 
209
.. i18n: Lets you generate and retrieve reports.
 
210
..
 
211
 
 
212
Lets you generate and retrieve reports.
 
213
 
 
214
.. i18n: Example : writing data through the Web Services
 
215
.. i18n: -----------------------------------------------
 
216
..
 
217
 
 
218
Example : writing data through the Web Services
 
219
-----------------------------------------------
 
220
 
 
221
.. i18n: Here is an example process that you could follow to write data. You will find
 
222
.. i18n: more detailed examples for XML-RPC in various programming languages in the next
 
223
.. i18n: chapter.
 
224
..
 
225
 
 
226
Here is an example process that you could follow to write data. You will find
 
227
more detailed examples for XML-RPC in various programming languages in the next
 
228
chapter.
 
229
 
 
230
.. i18n: #.  login: call "login" in the web service "common" with the following
 
231
.. i18n:     parameters:
 
232
.. i18n: 
 
233
.. i18n:         * database
 
234
.. i18n:         * user name
 
235
.. i18n:         * password
 
236
.. i18n: 
 
237
.. i18n: #.  create a new partner: call "execute" in the web service "object" with the
 
238
.. i18n:     following parameters:
 
239
.. i18n: 
 
240
.. i18n:         * database
 
241
.. i18n:         * user id provided by "login" in step 1.
 
242
.. i18n:         * the object name : 'res.partner'
 
243
.. i18n:         * the name of the ORM method : "create"
 
244
.. i18n:         * some data to be recorded
 
245
..
 
246
 
 
247
#.  login: call "login" in the web service "common" with the following
 
248
    parameters:
 
249
 
 
250
        * database
 
251
        * user name
 
252
        * password
 
253
 
 
254
#.  create a new partner: call "execute" in the web service "object" with the
 
255
    following parameters:
 
256
 
 
257
        * database
 
258
        * user id provided by "login" in step 1.
 
259
        * the object name : 'res.partner'
 
260
        * the name of the ORM method : "create"
 
261
        * some data to be recorded
 
262
 
 
263
.. i18n: The data mentioned above is a dictionary of keys and values, for example:
 
264
..
 
265
 
 
266
The data mentioned above is a dictionary of keys and values, for example:
 
267
 
 
268
.. i18n:     * name: Fabien Pinckaers
 
269
.. i18n:     * lang: fr_FR
 
270
..
 
271
 
 
272
    * name: Fabien Pinckaers
 
273
    * lang: fr_FR
 
274
 
 
275
.. i18n: But more complex data structures can also be sent - for example you could record
 
276
.. i18n: a partner and their addresses, all in a single call to the web service.
 
277
.. i18n: In that case, all the data is processed by the server during the same
 
278
.. i18n: database transaction - meaning you are sure to keep a consistent state for
 
279
.. i18n: your data - a critical requirement for all ERP applications.
 
280
..
 
281
 
 
282
But more complex data structures can also be sent - for example you could record
 
283
a partner and their addresses, all in a single call to the web service.
 
284
In that case, all the data is processed by the server during the same
 
285
database transaction - meaning you are sure to keep a consistent state for
 
286
your data - a critical requirement for all ERP applications.
 
287
 
 
288
.. i18n: XML-RPC Web services
 
289
.. i18n: ====================
 
290
..
 
291
 
 
292
XML-RPC Web services
 
293
====================
 
294
 
 
295
.. i18n: XML-RPC is known as a web service. Web services are a set of tools that let one build distributed applications on top of existing web infrastructures. These applications use the Web as a kind of "transport layer" but don't offer a direct human interface via the browser.[1] Extensible Markup Language (XML) provides a vocabulary for describing Remote Procedure Calls (RPC), which is then transmitted between computers using the HyperText Transfer Protocol (HTTP). Effectively, RPC gives developers a mechanism for defining interfaces that can be called over a network. These interfaces can be as simple as a single function call or as complex as a large API.
 
296
..
 
297
 
 
298
XML-RPC is known as a web service. Web services are a set of tools that let one build distributed applications on top of existing web infrastructures. These applications use the Web as a kind of "transport layer" but don't offer a direct human interface via the browser.[1] Extensible Markup Language (XML) provides a vocabulary for describing Remote Procedure Calls (RPC), which is then transmitted between computers using the HyperText Transfer Protocol (HTTP). Effectively, RPC gives developers a mechanism for defining interfaces that can be called over a network. These interfaces can be as simple as a single function call or as complex as a large API.
 
299
 
 
300
.. i18n: XML-RPC therefore allows two or more computers running different operating systems and programs written in different languages to share processing. For example, a Java application could talk with a Perl program, which in turn talks with Python application that talks with ASP, and so on. System integrators often build custom connections between different systems, creating their own formats and protocols to make communications possible, but one can often end up with a large number of poorly documented single-use protocols. The RPC approach spares programmers the trouble of having to learn about underlying protocols, networking, and various implementation details.
 
301
..
 
302
 
 
303
XML-RPC therefore allows two or more computers running different operating systems and programs written in different languages to share processing. For example, a Java application could talk with a Perl program, which in turn talks with Python application that talks with ASP, and so on. System integrators often build custom connections between different systems, creating their own formats and protocols to make communications possible, but one can often end up with a large number of poorly documented single-use protocols. The RPC approach spares programmers the trouble of having to learn about underlying protocols, networking, and various implementation details.
 
304
 
 
305
.. i18n: XML-RPC can be used with Python, Java, Perl, PHP, C, C++, Ruby, Microsoft’s .NET and many other programming languages. Implementations are widely available for platforms such as Unix, Linux, Windows and the Macintosh.
 
306
..
 
307
 
 
308
XML-RPC can be used with Python, Java, Perl, PHP, C, C++, Ruby, Microsoft’s .NET and many other programming languages. Implementations are widely available for platforms such as Unix, Linux, Windows and the Macintosh.
 
309
 
 
310
.. i18n: An XML-RPC call is conducted between two parties: the client (the calling process) and the server (the called process). A server is made available at a particular URL (such as http://example.org:8080/rpcserv/).
 
311
..
 
312
 
 
313
An XML-RPC call is conducted between two parties: the client (the calling process) and the server (the called process). A server is made available at a particular URL (such as http://example.org:8080/rpcserv/).
 
314
 
 
315
.. i18n: The above text just touches the surface of XML-RPC. I recommend O'Reilly's "Programming Web Service with XML-RPC" for further reading. One may also wish to review the following links:
 
316
..
 
317
 
 
318
The above text just touches the surface of XML-RPC. I recommend O'Reilly's "Programming Web Service with XML-RPC" for further reading. One may also wish to review the following links:
 
319
 
 
320
.. i18n: Interfaces
 
321
.. i18n: ----------
 
322
..
 
323
 
 
324
Interfaces
 
325
----------
 
326
 
 
327
.. i18n: XML-RPC
 
328
.. i18n: +++++++
 
329
..
 
330
 
 
331
XML-RPC
 
332
+++++++
 
333
 
 
334
.. i18n: XML-RPC Architecture
 
335
.. i18n: """"""""""""""""""""
 
336
..
 
337
 
 
338
XML-RPC Architecture
 
339
""""""""""""""""""""
 
340
 
 
341
.. i18n: OpenERP is a based on a client/server architecture. The server and the client(s) communicate using the XML-RPC protocol. XML-RPC is a very simple protocol which allows the client to do remote procedure calls. The called function, its arguments, and the result of the call are transported using HTTP and encoded using XML. For more information on XML-RPC, please see: http://www.xml-rpc.com.
 
342
..
 
343
 
 
344
OpenERP is a based on a client/server architecture. The server and the client(s) communicate using the XML-RPC protocol. XML-RPC is a very simple protocol which allows the client to do remote procedure calls. The called function, its arguments, and the result of the call are transported using HTTP and encoded using XML. For more information on XML-RPC, please see: http://www.xml-rpc.com.
 
345
 
 
346
.. i18n: Architecture
 
347
.. i18n: """"""""""""
 
348
..
 
349
 
 
350
Architecture
 
351
""""""""""""
 
352
 
 
353
.. i18n: The diagram below synthesizes the client server architecture of OpenERP. OpenERP server and OpenERP clients communicate using XML-RPC.
 
354
..
 
355
 
 
356
The diagram below synthesizes the client server architecture of OpenERP. OpenERP server and OpenERP clients communicate using XML-RPC.
 
357
 
 
358
.. i18n: .. figure:: images/tech_arch.png
 
359
.. i18n:   :scale: 85
 
360
.. i18n:   :align: center
 
361
..
 
362
 
 
363
.. figure:: images/tech_arch.png
 
364
  :scale: 85
 
365
  :align: center
 
366
 
 
367
.. i18n: **Client**
 
368
..
 
369
 
 
370
**Client**
 
371
 
 
372
.. i18n: The logic of OpenERP is configured on the server side. The client is very simple; it is only used to post data (forms, lists, trees) and to send back the result to the server. The updates and the addition of new functionality don't need the clients to be frequently upgraded. This makes OpenERP easier to maintain.
 
373
..
 
374
 
 
375
The logic of OpenERP is configured on the server side. The client is very simple; it is only used to post data (forms, lists, trees) and to send back the result to the server. The updates and the addition of new functionality don't need the clients to be frequently upgraded. This makes OpenERP easier to maintain.
 
376
 
 
377
.. i18n: The client doesn't understand what it posts. Even actions like 'Click on the print icon' are sent to the server to ask how to react.
 
378
..
 
379
 
 
380
The client doesn't understand what it posts. Even actions like 'Click on the print icon' are sent to the server to ask how to react.
 
381
 
 
382
.. i18n: The client operation is very simple; when a user makes an action (save a form, open a menu, print, ...) it sends this action to the server. The server then sends the new action to execute to the client.
 
383
..
 
384
 
 
385
The client operation is very simple; when a user makes an action (save a form, open a menu, print, ...) it sends this action to the server. The server then sends the new action to execute to the client.
 
386
 
 
387
.. i18n: There are three types of action;
 
388
..
 
389
 
 
390
There are three types of action;
 
391
 
 
392
.. i18n:     * Open a window (form or tree)
 
393
.. i18n:     * Print a document
 
394
.. i18n:     * Execute a wizard
 
395
..
 
396
 
 
397
    * Open a window (form or tree)
 
398
    * Print a document
 
399
    * Execute a wizard
 
400
 
 
401
.. i18n: Python
 
402
.. i18n: ++++++
 
403
..
 
404
 
 
405
Python
 
406
++++++
 
407
 
 
408
.. i18n: Access tiny-server using xml-rpc
 
409
.. i18n: """"""""""""""""""""""""""""""""
 
410
..
 
411
 
 
412
Access tiny-server using xml-rpc
 
413
""""""""""""""""""""""""""""""""
 
414
 
 
415
.. i18n: Demo script
 
416
.. i18n: ~~~~~~~~~~~
 
417
..
 
418
 
 
419
Demo script
 
420
~~~~~~~~~~~
 
421
 
 
422
.. i18n:     * **Create a partner and their address**
 
423
..
 
424
 
 
425
    * **Create a partner and their address**
 
426
 
 
427
.. i18n:   ::
 
428
.. i18n: 
 
429
.. i18n:     import xmlrpclib
 
430
.. i18n: 
 
431
.. i18n:     username = 'admin' #the user
 
432
.. i18n:     pwd = 'admin'      #the password of the user
 
433
.. i18n:     dbname = 'terp'    #the database
 
434
.. i18n: 
 
435
.. i18n:     # Get the uid
 
436
.. i18n:     sock_common = xmlrpclib.ServerProxy ('http://localhost:8069/xmlrpc/common')
 
437
.. i18n:     uid = sock_common.login(dbname, username, pwd)
 
438
.. i18n: 
 
439
.. i18n:     #replace localhost with the address of the server
 
440
.. i18n:     sock = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/object')
 
441
.. i18n: 
 
442
.. i18n:     partner = {
 
443
.. i18n:        'name': 'Fabien Pinckaers',
 
444
.. i18n:        'lang': 'fr_FR',
 
445
.. i18n:     }
 
446
.. i18n: 
 
447
.. i18n:     partner_id = sock.execute(dbname, uid, pwd, 'res.partner', 'create', partner)
 
448
.. i18n: 
 
449
.. i18n:     address = {
 
450
.. i18n:        'partner_id': partner_id,
 
451
.. i18n:        'type' : 'default',
 
452
.. i18n:        'street': 'Chaussée de Namur 40',
 
453
.. i18n:        'zip': '1367',
 
454
.. i18n:        'city': 'Grand-Rosière',
 
455
.. i18n:        'phone': '+3281813700',
 
456
.. i18n:        'fax': '+3281733501',
 
457
.. i18n:     }
 
458
.. i18n: 
 
459
.. i18n:     address_id = sock.execute(dbname, uid, pwd, 'res.partner.address', 'create', address)
 
460
..
 
461
 
 
462
  ::
 
463
 
 
464
    import xmlrpclib
 
465
 
 
466
    username = 'admin' #the user
 
467
    pwd = 'admin'      #the password of the user
 
468
    dbname = 'terp'    #the database
 
469
 
 
470
    # Get the uid
 
471
    sock_common = xmlrpclib.ServerProxy ('http://localhost:8069/xmlrpc/common')
 
472
    uid = sock_common.login(dbname, username, pwd)
 
473
 
 
474
    #replace localhost with the address of the server
 
475
    sock = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/object')
 
476
 
 
477
    partner = {
 
478
       'name': 'Fabien Pinckaers',
 
479
       'lang': 'fr_FR',
 
480
    }
 
481
 
 
482
    partner_id = sock.execute(dbname, uid, pwd, 'res.partner', 'create', partner)
 
483
 
 
484
    address = {
 
485
       'partner_id': partner_id,
 
486
       'type' : 'default',
 
487
       'street': 'Chaussée de Namur 40',
 
488
       'zip': '1367',
 
489
       'city': 'Grand-Rosière',
 
490
       'phone': '+3281813700',
 
491
       'fax': '+3281733501',
 
492
    }
 
493
 
 
494
    address_id = sock.execute(dbname, uid, pwd, 'res.partner.address', 'create', address)
 
495
 
 
496
.. i18n: * **Search a partner**
 
497
.. i18n:   ::
 
498
.. i18n: 
 
499
.. i18n:     args = [('vat', '=', 'ZZZZZZ')] #query clause
 
500
.. i18n:     ids = sock.execute(dbname, uid, pwd, 'res.partner', 'search', args)
 
501
.. i18n: 
 
502
.. i18n: * **Read partner data**
 
503
.. i18n:   ::
 
504
.. i18n: 
 
505
.. i18n:     fields = ['name', 'active', 'vat', 'ref'] #fields to read
 
506
.. i18n:     data = sock.execute(dbname, uid, pwd, 'res.partner', 'read', ids, fields) #ids is a list of id
 
507
.. i18n: 
 
508
.. i18n: * **Update partner data**
 
509
.. i18n:   ::
 
510
.. i18n: 
 
511
.. i18n:     values = {'vat': 'ZZ1ZZZ'} #data to update
 
512
.. i18n:     result = sock.execute(dbname, uid, pwd, 'res.partner', 'write', ids, values)
 
513
.. i18n: 
 
514
.. i18n: * **Delete partner**
 
515
.. i18n:   ::
 
516
.. i18n: 
 
517
.. i18n:     # ids : list of id
 
518
.. i18n:     result = sock.execute(dbname, uid, pwd, 'res.partner', 'unlink', ids)
 
519
..
 
520
 
 
521
* **Search a partner**
 
522
  ::
 
523
 
 
524
    args = [('vat', '=', 'ZZZZZZ')] #query clause
 
525
    ids = sock.execute(dbname, uid, pwd, 'res.partner', 'search', args)
 
526
 
 
527
* **Read partner data**
 
528
  ::
 
529
 
 
530
    fields = ['name', 'active', 'vat', 'ref'] #fields to read
 
531
    data = sock.execute(dbname, uid, pwd, 'res.partner', 'read', ids, fields) #ids is a list of id
 
532
 
 
533
* **Update partner data**
 
534
  ::
 
535
 
 
536
    values = {'vat': 'ZZ1ZZZ'} #data to update
 
537
    result = sock.execute(dbname, uid, pwd, 'res.partner', 'write', ids, values)
 
538
 
 
539
* **Delete partner**
 
540
  ::
 
541
 
 
542
    # ids : list of id
 
543
    result = sock.execute(dbname, uid, pwd, 'res.partner', 'unlink', ids)
 
544
 
 
545
.. i18n: PHP
 
546
.. i18n: +++
 
547
..
 
548
 
 
549
PHP
 
550
+++
 
551
 
 
552
.. i18n: Access Open-server using xml-rpc
 
553
.. i18n: """"""""""""""""""""""""""""""""
 
554
..
 
555
 
 
556
Access Open-server using xml-rpc
 
557
""""""""""""""""""""""""""""""""
 
558
 
 
559
.. i18n: **Download the XML-RPC framework for PHP**
 
560
..
 
561
 
 
562
**Download the XML-RPC framework for PHP**
 
563
 
 
564
.. i18n: windows / linux: download the xml-rpc framework for php from http://phpxmlrpc.sourceforge.net/ The latest stable release is version 2.2 released on February 25, 2007
 
565
..
 
566
 
 
567
windows / linux: download the xml-rpc framework for php from http://phpxmlrpc.sourceforge.net/ The latest stable release is version 2.2 released on February 25, 2007
 
568
 
 
569
.. i18n: **Setup the XML-RPC for PHP**
 
570
..
 
571
 
 
572
**Setup the XML-RPC for PHP**
 
573
 
 
574
.. i18n: extract file xmlrpc-2.2.tar.gz and take the file xmlrpc.inc from lib directory place the xmlrpc.inc in the php library folder restart the apache/iis server
 
575
..
 
576
 
 
577
extract file xmlrpc-2.2.tar.gz and take the file xmlrpc.inc from lib directory place the xmlrpc.inc in the php library folder restart the apache/iis server
 
578
 
 
579
.. i18n: **Demo script**
 
580
..
 
581
 
 
582
**Demo script**
 
583
 
 
584
.. i18n: * **Login**
 
585
..
 
586
 
 
587
* **Login**
 
588
 
 
589
.. i18n: .. code-block:: php
 
590
.. i18n: 
 
591
.. i18n:     function connect() {
 
592
.. i18n:        var $user = 'admin';
 
593
.. i18n:        var $password = 'admin';
 
594
.. i18n:        var $dbname = 'db_name';
 
595
.. i18n:        var $server_url = 'http://localhost:8069/xmlrpc/';
 
596
.. i18n: 
 
597
.. i18n:        if(isset($_COOKIE["user_id"]) == true)  {
 
598
.. i18n:            if($_COOKIE["user_id"]>0) {
 
599
.. i18n:            return $_COOKIE["user_id"];
 
600
.. i18n:            }
 
601
.. i18n:        }
 
602
.. i18n: 
 
603
.. i18n:        $sock = new xmlrpc_client($server_url.'common');
 
604
.. i18n:        $msg = new xmlrpcmsg('login');
 
605
.. i18n:        $msg->addParam(new xmlrpcval($dbname, "string"));
 
606
.. i18n:        $msg->addParam(new xmlrpcval($user, "string"));
 
607
.. i18n:        $msg->addParam(new xmlrpcval($password, "string"));
 
608
.. i18n:        $resp =  $sock->send($msg);
 
609
.. i18n:        $val = $resp->value();
 
610
.. i18n:        $id = $val->scalarval();
 
611
.. i18n:        setcookie("user_id",$id,time()+3600);
 
612
.. i18n:        if($id > 0) {
 
613
.. i18n:            return $id;
 
614
.. i18n:        }else{
 
615
.. i18n:            return -1;
 
616
.. i18n:        }
 
617
.. i18n:      }
 
618
..
 
619
 
 
620
.. code-block:: php
 
621
 
 
622
    function connect() {
 
623
       var $user = 'admin';
 
624
       var $password = 'admin';
 
625
       var $dbname = 'db_name';
 
626
       var $server_url = 'http://localhost:8069/xmlrpc/';
 
627
 
 
628
       if(isset($_COOKIE["user_id"]) == true)  {
 
629
           if($_COOKIE["user_id"]>0) {
 
630
           return $_COOKIE["user_id"];
 
631
           }
 
632
       }
 
633
 
 
634
       $sock = new xmlrpc_client($server_url.'common');
 
635
       $msg = new xmlrpcmsg('login');
 
636
       $msg->addParam(new xmlrpcval($dbname, "string"));
 
637
       $msg->addParam(new xmlrpcval($user, "string"));
 
638
       $msg->addParam(new xmlrpcval($password, "string"));
 
639
       $resp =  $sock->send($msg);
 
640
       $val = $resp->value();
 
641
       $id = $val->scalarval();
 
642
       setcookie("user_id",$id,time()+3600);
 
643
       if($id > 0) {
 
644
           return $id;
 
645
       }else{
 
646
           return -1;
 
647
       }
 
648
     }
 
649
 
 
650
.. i18n: * **Search**
 
651
..
 
652
 
 
653
* **Search**
 
654
 
 
655
.. i18n: .. code-block:: php
 
656
.. i18n: 
 
657
.. i18n:     /**
 
658
.. i18n:      * $client = xml-rpc handler
 
659
.. i18n:      * $relation = name of the relation ex: res.partner
 
660
.. i18n:      * $attribute = name of the attribute ex:code
 
661
.. i18n:      * $operator = search term operator ex: ilike, =, !=
 
662
.. i18n:      * $key=search for
 
663
.. i18n:      */
 
664
.. i18n: 
 
665
.. i18n:     function search($client,$relation,$attribute,$operator,$keys) {
 
666
.. i18n:          var $user = 'admin';
 
667
.. i18n:          var $password = 'admin';
 
668
.. i18n:          var $userId = -1;
 
669
.. i18n:          var $dbname = 'db_name';
 
670
.. i18n:          var $server_url = 'http://localhost:8069/xmlrpc/';
 
671
.. i18n: 
 
672
.. i18n:          $key = array(new xmlrpcval(array(new xmlrpcval($attribute , "string"),
 
673
.. i18n:                   new xmlrpcval($operator,"string"),
 
674
.. i18n:                   new xmlrpcval($keys,"string")),"array"),
 
675
.. i18n:             );
 
676
.. i18n: 
 
677
.. i18n:          if($userId<=0) {
 
678
.. i18n:          connect();
 
679
.. i18n:          }
 
680
.. i18n: 
 
681
.. i18n:          $msg = new xmlrpcmsg('execute');
 
682
.. i18n:          $msg->addParam(new xmlrpcval($dbname, "string"));
 
683
.. i18n:          $msg->addParam(new xmlrpcval($userId, "int"));
 
684
.. i18n:          $msg->addParam(new xmlrpcval($password, "string"));
 
685
.. i18n:          $msg->addParam(new xmlrpcval($relation, "string"));
 
686
.. i18n:          $msg->addParam(new xmlrpcval("search", "string"));
 
687
.. i18n:          $msg->addParam(new xmlrpcval($key, "array"));
 
688
.. i18n: 
 
689
.. i18n:          $resp = $client->send($msg);
 
690
.. i18n:          $val = $resp->value();
 
691
.. i18n:          $ids = $val->scalarval();
 
692
.. i18n: 
 
693
.. i18n:          return $ids;
 
694
.. i18n:     }
 
695
..
 
696
 
 
697
.. code-block:: php
 
698
 
 
699
    /**
 
700
     * $client = xml-rpc handler
 
701
     * $relation = name of the relation ex: res.partner
 
702
     * $attribute = name of the attribute ex:code
 
703
     * $operator = search term operator ex: ilike, =, !=
 
704
     * $key=search for
 
705
     */
 
706
 
 
707
    function search($client,$relation,$attribute,$operator,$keys) {
 
708
         var $user = 'admin';
 
709
         var $password = 'admin';
 
710
         var $userId = -1;
 
711
         var $dbname = 'db_name';
 
712
         var $server_url = 'http://localhost:8069/xmlrpc/';
 
713
 
 
714
         $key = array(new xmlrpcval(array(new xmlrpcval($attribute , "string"),
 
715
                  new xmlrpcval($operator,"string"),
 
716
                  new xmlrpcval($keys,"string")),"array"),
 
717
            );
 
718
 
 
719
         if($userId<=0) {
 
720
         connect();
 
721
         }
 
722
 
 
723
         $msg = new xmlrpcmsg('execute');
 
724
         $msg->addParam(new xmlrpcval($dbname, "string"));
 
725
         $msg->addParam(new xmlrpcval($userId, "int"));
 
726
         $msg->addParam(new xmlrpcval($password, "string"));
 
727
         $msg->addParam(new xmlrpcval($relation, "string"));
 
728
         $msg->addParam(new xmlrpcval("search", "string"));
 
729
         $msg->addParam(new xmlrpcval($key, "array"));
 
730
 
 
731
         $resp = $client->send($msg);
 
732
         $val = $resp->value();
 
733
         $ids = $val->scalarval();
 
734
 
 
735
         return $ids;
 
736
    }
 
737
 
 
738
.. i18n: * **Create**
 
739
..
 
740
 
 
741
* **Create**
 
742
 
 
743
.. i18n: .. code-block:: php
 
744
.. i18n: 
 
745
.. i18n:         <?
 
746
.. i18n: 
 
747
.. i18n:         include('xmlrpc.inc');
 
748
.. i18n: 
 
749
.. i18n:         $arrayVal = array(
 
750
.. i18n:         'name'=>new xmlrpcval('Fabien Pinckaers', "string") ,
 
751
.. i18n:         'vat'=>new xmlrpcval('BE477472701' , "string")
 
752
.. i18n:         );
 
753
.. i18n: 
 
754
.. i18n:         $client = new xmlrpc_client("http://localhost:8069/xmlrpc/object");
 
755
.. i18n: 
 
756
.. i18n:         $msg = new xmlrpcmsg('execute');
 
757
.. i18n:         $msg->addParam(new xmlrpcval("dbname", "string"));
 
758
.. i18n:         $msg->addParam(new xmlrpcval("3", "int"));
 
759
.. i18n:         $msg->addParam(new xmlrpcval("demo", "string"));
 
760
.. i18n:         $msg->addParam(new xmlrpcval("res.partner", "string"));
 
761
.. i18n:         $msg->addParam(new xmlrpcval("create", "string"));
 
762
.. i18n:         $msg->addParam(new xmlrpcval($arrayVal, "struct"));
 
763
.. i18n: 
 
764
.. i18n:         $resp = $client->send($msg);
 
765
.. i18n: 
 
766
.. i18n:         if ($resp->faultCode())
 
767
.. i18n: 
 
768
.. i18n:             echo 'Error: '.$resp->faultString();
 
769
.. i18n: 
 
770
.. i18n:         else
 
771
.. i18n: 
 
772
.. i18n:             echo 'Partner '.$resp->value()->scalarval().' created !';
 
773
.. i18n: 
 
774
.. i18n:         ?>
 
775
..
 
776
 
 
777
.. code-block:: php
 
778
 
 
779
        <?
 
780
 
 
781
        include('xmlrpc.inc');
 
782
 
 
783
        $arrayVal = array(
 
784
        'name'=>new xmlrpcval('Fabien Pinckaers', "string") ,
 
785
        'vat'=>new xmlrpcval('BE477472701' , "string")
 
786
        );
 
787
 
 
788
        $client = new xmlrpc_client("http://localhost:8069/xmlrpc/object");
 
789
 
 
790
        $msg = new xmlrpcmsg('execute');
 
791
        $msg->addParam(new xmlrpcval("dbname", "string"));
 
792
        $msg->addParam(new xmlrpcval("3", "int"));
 
793
        $msg->addParam(new xmlrpcval("demo", "string"));
 
794
        $msg->addParam(new xmlrpcval("res.partner", "string"));
 
795
        $msg->addParam(new xmlrpcval("create", "string"));
 
796
        $msg->addParam(new xmlrpcval($arrayVal, "struct"));
 
797
 
 
798
        $resp = $client->send($msg);
 
799
 
 
800
        if ($resp->faultCode())
 
801
 
 
802
            echo 'Error: '.$resp->faultString();
 
803
 
 
804
        else
 
805
 
 
806
            echo 'Partner '.$resp->value()->scalarval().' created !';
 
807
 
 
808
        ?>
 
809
 
 
810
.. i18n: * **Write**
 
811
..
 
812
 
 
813
* **Write**
 
814
 
 
815
.. i18n: .. code-block:: php
 
816
.. i18n: 
 
817
.. i18n:     /**
 
818
.. i18n:      * $client = xml-rpc handler
 
819
.. i18n:      * $relation = name of the relation ex: res.partner
 
820
.. i18n:      * $attribute = name of the attribute ex:code
 
821
.. i18n:      * $operator = search term operator ex: ilike, =, !=
 
822
.. i18n:      * $id = id of the record to be updated
 
823
.. i18n:      * $data = data to be updated
 
824
.. i18n:      */
 
825
.. i18n: 
 
826
.. i18n:     function write($client,$relation,$attribute,$operator,$data,$id) {
 
827
.. i18n:          var $user = 'admin';
 
828
.. i18n:          var $password = 'admin';
 
829
.. i18n:          var $userId = -1;
 
830
.. i18n:          var $dbname = 'db_name';
 
831
.. i18n:          var $server_url = 'http://localhost:8069/xmlrpc/';
 
832
.. i18n: 
 
833
.. i18n:          $id_val = array();
 
834
.. i18n:         $id_val[0] = new xmlrpcval($id, "int");
 
835
.. i18n: 
 
836
.. i18n:          if($userId<=0) {
 
837
.. i18n:          connect();
 
838
.. i18n:          }
 
839
.. i18n: 
 
840
.. i18n:          $msg = new xmlrpcmsg('execute');
 
841
.. i18n:          $msg->addParam(new xmlrpcval($dbname, "string"));
 
842
.. i18n:          $msg->addParam(new xmlrpcval($userId, "int"));
 
843
.. i18n:          $msg->addParam(new xmlrpcval($password, "string"));
 
844
.. i18n:          $msg->addParam(new xmlrpcval($relation, "string"));
 
845
.. i18n:          $msg->addParam(new xmlrpcval("write", "string"));
 
846
.. i18n:          $msg->addParam(new xmlrpcval($id, "array"));
 
847
.. i18n:          $msg->addParam(new xmlrpcval($data, "struct"));
 
848
.. i18n: 
 
849
.. i18n:          $resp = $client->send($msg);
 
850
.. i18n:          $val = $resp->value();
 
851
.. i18n:          $record = $val->scalarval();
 
852
.. i18n: 
 
853
.. i18n:          return $record;
 
854
.. i18n: 
 
855
.. i18n:     }
 
856
..
 
857
 
 
858
.. code-block:: php
 
859
 
 
860
    /**
 
861
     * $client = xml-rpc handler
 
862
     * $relation = name of the relation ex: res.partner
 
863
     * $attribute = name of the attribute ex:code
 
864
     * $operator = search term operator ex: ilike, =, !=
 
865
     * $id = id of the record to be updated
 
866
     * $data = data to be updated
 
867
     */
 
868
 
 
869
    function write($client,$relation,$attribute,$operator,$data,$id) {
 
870
         var $user = 'admin';
 
871
         var $password = 'admin';
 
872
         var $userId = -1;
 
873
         var $dbname = 'db_name';
 
874
         var $server_url = 'http://localhost:8069/xmlrpc/';
 
875
 
 
876
         $id_val = array();
 
877
         $id_val[0] = new xmlrpcval($id, "int");
 
878
 
 
879
         if($userId<=0) {
 
880
         connect();
 
881
         }
 
882
 
 
883
         $msg = new xmlrpcmsg('execute');
 
884
         $msg->addParam(new xmlrpcval($dbname, "string"));
 
885
         $msg->addParam(new xmlrpcval($userId, "int"));
 
886
         $msg->addParam(new xmlrpcval($password, "string"));
 
887
         $msg->addParam(new xmlrpcval($relation, "string"));
 
888
         $msg->addParam(new xmlrpcval("write", "string"));
 
889
         $msg->addParam(new xmlrpcval($id, "array"));
 
890
         $msg->addParam(new xmlrpcval($data, "struct"));
 
891
 
 
892
         $resp = $client->send($msg);
 
893
         $val = $resp->value();
 
894
         $record = $val->scalarval();
 
895
 
 
896
         return $record;
 
897
 
 
898
    }
 
899
 
 
900
.. i18n: JAVA
 
901
.. i18n: ++++
 
902
..
 
903
 
 
904
JAVA
 
905
++++
 
906
 
 
907
.. i18n: Access Open-server using xml-rpc
 
908
.. i18n: """"""""""""""""""""""""""""""""
 
909
..
 
910
 
 
911
Access Open-server using xml-rpc
 
912
""""""""""""""""""""""""""""""""
 
913
 
 
914
.. i18n: **Download the apache XML-RPC framework for JAVA**
 
915
..
 
916
 
 
917
**Download the apache XML-RPC framework for JAVA**
 
918
 
 
919
.. i18n: Download the xml-rpc framework for java from http://ws.apache.org/xmlrpc/ The latest stable release is version 3.1 released on August 12, 2007.
 
920
.. i18n: All OpenERP errors throw exceptions because the framework allows only an int as the error code where OpenERP returns a string.
 
921
..
 
922
 
 
923
Download the xml-rpc framework for java from http://ws.apache.org/xmlrpc/ The latest stable release is version 3.1 released on August 12, 2007.
 
924
All OpenERP errors throw exceptions because the framework allows only an int as the error code where OpenERP returns a string.
 
925
 
 
926
.. i18n: **Demo script**
 
927
..
 
928
 
 
929
**Demo script**
 
930
 
 
931
.. i18n: * **Find Databases**
 
932
..
 
933
 
 
934
* **Find Databases**
 
935
 
 
936
.. i18n: .. code-block:: java
 
937
.. i18n: 
 
938
.. i18n:     import java.net.URL;
 
939
.. i18n:     import java.util.Vector;
 
940
.. i18n: 
 
941
.. i18n:     import org.apache.commons.lang.StringUtils;
 
942
.. i18n:     import org.apache.xmlrpc.XmlRpcException;
 
943
.. i18n:     import org.apache.xmlrpc.client.XmlRpcClient;
 
944
.. i18n:     import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
 
945
.. i18n: 
 
946
.. i18n:     public Vector<String> getDatabaseList(String host, int port)
 
947
.. i18n:     {
 
948
.. i18n:       XmlRpcClient xmlrpcDb = new XmlRpcClient();
 
949
.. i18n: 
 
950
.. i18n:       XmlRpcClientConfigImpl xmlrpcConfigDb = new XmlRpcClientConfigImpl();
 
951
.. i18n:       xmlrpcConfigDb.setEnabledForExtensions(true);
 
952
.. i18n:       xmlrpcConfigDb.setServerURL(new URL("http",host,port,"/xmlrpc/db"));
 
953
.. i18n: 
 
954
.. i18n:       xmlrpcDb.setConfig(xmlrpcConfigDb);
 
955
.. i18n: 
 
956
.. i18n:       try {
 
957
.. i18n:         //Retrieve databases
 
958
.. i18n:         Vector<Object> params = new Vector<Object>();
 
959
.. i18n:         Object result = xmlrpcDb.execute("list", params);
 
960
.. i18n:         Object[] a = (Object[]) result;
 
961
.. i18n: 
 
962
.. i18n:         Vector<String> res = new Vector<String>();
 
963
.. i18n:         for (int i = 0; i < a.length; i++) {
 
964
.. i18n:         if (a[i] instanceof String)
 
965
.. i18n:         {
 
966
.. i18n:           res.addElement((String)a[i]);
 
967
.. i18n:         }
 
968
.. i18n:       }
 
969
.. i18n:       catch (XmlRpcException e) {
 
970
.. i18n:         logger.warn("XmlException Error while retrieving OpenERP Databases: ",e);
 
971
.. i18n:         return -2;
 
972
.. i18n:       }
 
973
.. i18n:       catch (Exception e)
 
974
.. i18n:       {
 
975
.. i18n:         logger.warn("Error while retrieving OpenERP Databases: ",e);
 
976
.. i18n:         return -3;
 
977
.. i18n:       }
 
978
.. i18n:     }
 
979
..
 
980
 
 
981
.. code-block:: java
 
982
 
 
983
    import java.net.URL;
 
984
    import java.util.Vector;
 
985
 
 
986
    import org.apache.commons.lang.StringUtils;
 
987
    import org.apache.xmlrpc.XmlRpcException;
 
988
    import org.apache.xmlrpc.client.XmlRpcClient;
 
989
    import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
 
990
 
 
991
    public Vector<String> getDatabaseList(String host, int port)
 
992
    {
 
993
      XmlRpcClient xmlrpcDb = new XmlRpcClient();
 
994
 
 
995
      XmlRpcClientConfigImpl xmlrpcConfigDb = new XmlRpcClientConfigImpl();
 
996
      xmlrpcConfigDb.setEnabledForExtensions(true);
 
997
      xmlrpcConfigDb.setServerURL(new URL("http",host,port,"/xmlrpc/db"));
 
998
 
 
999
      xmlrpcDb.setConfig(xmlrpcConfigDb);
 
1000
 
 
1001
      try {
 
1002
        //Retrieve databases
 
1003
        Vector<Object> params = new Vector<Object>();
 
1004
        Object result = xmlrpcDb.execute("list", params);
 
1005
        Object[] a = (Object[]) result;
 
1006
 
 
1007
        Vector<String> res = new Vector<String>();
 
1008
        for (int i = 0; i < a.length; i++) {
 
1009
        if (a[i] instanceof String)
 
1010
        {
 
1011
          res.addElement((String)a[i]);
 
1012
        }
 
1013
      }
 
1014
      catch (XmlRpcException e) {
 
1015
        logger.warn("XmlException Error while retrieving OpenERP Databases: ",e);
 
1016
        return -2;
 
1017
      }
 
1018
      catch (Exception e)
 
1019
      {
 
1020
        logger.warn("Error while retrieving OpenERP Databases: ",e);
 
1021
        return -3;
 
1022
      }
 
1023
    }
 
1024
 
 
1025
.. i18n: * **Login**
 
1026
..
 
1027
 
 
1028
* **Login**
 
1029
 
 
1030
.. i18n: .. code-block:: java
 
1031
.. i18n: 
 
1032
.. i18n:     import java.net.URL;
 
1033
.. i18n: 
 
1034
.. i18n:     import org.apache.commons.lang.StringUtils;
 
1035
.. i18n:     import org.apache.xmlrpc.XmlRpcException;
 
1036
.. i18n:     import org.apache.xmlrpc.client.XmlRpcClient;
 
1037
.. i18n:     import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
 
1038
.. i18n: 
 
1039
.. i18n:     public int Connect(String host, int port, String tinydb, String login, String password)
 
1040
.. i18n:     {
 
1041
.. i18n:       XmlRpcClient xmlrpcLogin = new XmlRpcClient();
 
1042
.. i18n: 
 
1043
.. i18n:       XmlRpcClientConfigImpl xmlrpcConfigLogin = new XmlRpcClientConfigImpl();
 
1044
.. i18n:       xmlrpcConfigLogin.setEnabledForExtensions(true);
 
1045
.. i18n:       xmlrpcConfigLogin.setServerURL(new URL("http",host,port,"/xmlrpc/common"));
 
1046
.. i18n: 
 
1047
.. i18n:       xmlrpcLogin.setConfig(xmlrpcConfigLogin);
 
1048
.. i18n: 
 
1049
.. i18n:       try {
 
1050
.. i18n:         //Connect
 
1051
.. i18n:         params = new Object[] {tinydb,login,password};
 
1052
.. i18n:         Object id = xmlrpcLogin.execute("login", params);
 
1053
.. i18n:         if (id instanceof Integer)
 
1054
.. i18n:           return (Integer)id;
 
1055
.. i18n:         return -1;
 
1056
.. i18n:       }
 
1057
.. i18n:       catch (XmlRpcException e) {
 
1058
.. i18n:         logger.warn("XmlException Error while logging to OpenERP: ",e);
 
1059
.. i18n:         return -2;
 
1060
.. i18n:       }
 
1061
.. i18n:       catch (Exception e)
 
1062
.. i18n:       {
 
1063
.. i18n:         logger.warn("Error while logging to OpenERP: ",e);
 
1064
.. i18n:         return -3;
 
1065
.. i18n:       }
 
1066
.. i18n:     }
 
1067
..
 
1068
 
 
1069
.. code-block:: java
 
1070
 
 
1071
    import java.net.URL;
 
1072
 
 
1073
    import org.apache.commons.lang.StringUtils;
 
1074
    import org.apache.xmlrpc.XmlRpcException;
 
1075
    import org.apache.xmlrpc.client.XmlRpcClient;
 
1076
    import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
 
1077
 
 
1078
    public int Connect(String host, int port, String tinydb, String login, String password)
 
1079
    {
 
1080
      XmlRpcClient xmlrpcLogin = new XmlRpcClient();
 
1081
 
 
1082
      XmlRpcClientConfigImpl xmlrpcConfigLogin = new XmlRpcClientConfigImpl();
 
1083
      xmlrpcConfigLogin.setEnabledForExtensions(true);
 
1084
      xmlrpcConfigLogin.setServerURL(new URL("http",host,port,"/xmlrpc/common"));
 
1085
 
 
1086
      xmlrpcLogin.setConfig(xmlrpcConfigLogin);
 
1087
 
 
1088
      try {
 
1089
        //Connect
 
1090
        params = new Object[] {tinydb,login,password};
 
1091
        Object id = xmlrpcLogin.execute("login", params);
 
1092
        if (id instanceof Integer)
 
1093
          return (Integer)id;
 
1094
        return -1;
 
1095
      }
 
1096
      catch (XmlRpcException e) {
 
1097
        logger.warn("XmlException Error while logging to OpenERP: ",e);
 
1098
        return -2;
 
1099
      }
 
1100
      catch (Exception e)
 
1101
      {
 
1102
        logger.warn("Error while logging to OpenERP: ",e);
 
1103
        return -3;
 
1104
      }
 
1105
    }
 
1106
 
 
1107
.. i18n: * **Search**
 
1108
.. i18n:   ::
 
1109
.. i18n: 
 
1110
.. i18n:     TODO
 
1111
.. i18n: 
 
1112
.. i18n: * **Create**
 
1113
.. i18n:   ::
 
1114
.. i18n: 
 
1115
.. i18n:     TODO
 
1116
.. i18n: 
 
1117
.. i18n: * **Write**
 
1118
.. i18n:   ::
 
1119
.. i18n: 
 
1120
.. i18n:     TODO
 
1121
..
 
1122
 
 
1123
* **Search**
 
1124
  ::
 
1125
 
 
1126
    TODO
 
1127
 
 
1128
* **Create**
 
1129
  ::
 
1130
 
 
1131
    TODO
 
1132
 
 
1133
* **Write**
 
1134
  ::
 
1135
 
 
1136
    TODO
 
1137
 
 
1138
.. i18n: Python Example
 
1139
.. i18n: --------------
 
1140
..
 
1141
 
 
1142
Python Example
 
1143
--------------
 
1144
 
 
1145
.. i18n: Example of creation of a partner and their address.
 
1146
..
 
1147
 
 
1148
Example of creation of a partner and their address.
 
1149
 
 
1150
.. i18n: .. code-block:: python
 
1151
.. i18n: 
 
1152
.. i18n:     import xmlrpclib
 
1153
.. i18n: 
 
1154
.. i18n:     sock = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/object')
 
1155
.. i18n:     uid = 1
 
1156
.. i18n:     pwd = 'demo'
 
1157
.. i18n: 
 
1158
.. i18n:     partner = {
 
1159
.. i18n:         'title': 'Monsieur',
 
1160
.. i18n:         'name': 'Fabien Pinckaers',
 
1161
.. i18n:         'lang': 'fr',
 
1162
.. i18n:         'active': True,
 
1163
.. i18n:     }
 
1164
.. i18n: 
 
1165
.. i18n:     partner_id = sock.execute(dbname, uid, pwd, 'res.partner', 'create', partner)
 
1166
.. i18n: 
 
1167
.. i18n:     address = {
 
1168
.. i18n:         'partner_id': partner_id,
 
1169
.. i18n:         'type': 'default',
 
1170
.. i18n:         'street': 'Rue du vieux chateau, 21',
 
1171
.. i18n:         'zip': '1457',
 
1172
.. i18n:         'city': 'Walhain',
 
1173
.. i18n:         'phone': '(+32)10.68.94.39',
 
1174
.. i18n:         'fax': '(+32)10.68.94.39',
 
1175
.. i18n:     }
 
1176
.. i18n: 
 
1177
.. i18n:     sock.execute(dbname, uid, pwd, 'res.partner.address', 'create', address)
 
1178
..
 
1179
 
 
1180
.. code-block:: python
 
1181
 
 
1182
    import xmlrpclib
 
1183
 
 
1184
    sock = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/object')
 
1185
    uid = 1
 
1186
    pwd = 'demo'
 
1187
 
 
1188
    partner = {
 
1189
        'title': 'Monsieur',
 
1190
        'name': 'Fabien Pinckaers',
 
1191
        'lang': 'fr',
 
1192
        'active': True,
 
1193
    }
 
1194
 
 
1195
    partner_id = sock.execute(dbname, uid, pwd, 'res.partner', 'create', partner)
 
1196
 
 
1197
    address = {
 
1198
        'partner_id': partner_id,
 
1199
        'type': 'default',
 
1200
        'street': 'Rue du vieux chateau, 21',
 
1201
        'zip': '1457',
 
1202
        'city': 'Walhain',
 
1203
        'phone': '(+32)10.68.94.39',
 
1204
        'fax': '(+32)10.68.94.39',
 
1205
    }
 
1206
 
 
1207
    sock.execute(dbname, uid, pwd, 'res.partner.address', 'create', address)
 
1208
 
 
1209
.. i18n: To get the UID of a user, you can use the following script:
 
1210
..
 
1211
 
 
1212
To get the UID of a user, you can use the following script:
 
1213
 
 
1214
.. i18n: .. code-block:: python
 
1215
.. i18n: 
 
1216
.. i18n:     sock = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/common')
 
1217
.. i18n:      UID = sock.login('terp3', 'admin', 'admin')
 
1218
..
 
1219
 
 
1220
.. code-block:: python
 
1221
 
 
1222
    sock = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/common')
 
1223
     UID = sock.login('terp3', 'admin', 'admin')
 
1224
 
 
1225
.. i18n: CRUD example:
 
1226
..
 
1227
 
 
1228
CRUD example:
 
1229
 
 
1230
.. i18n: .. code-block:: python
 
1231
.. i18n: 
 
1232
.. i18n:     """
 
1233
.. i18n:     :The login function is under
 
1234
.. i18n:     ::    http://localhost:8069/xmlrpc/common
 
1235
.. i18n:     :For object retrieval use:
 
1236
.. i18n:     ::    http://localhost:8069/xmlrpc/object
 
1237
.. i18n:     """
 
1238
.. i18n:     import xmlrpclib
 
1239
.. i18n: 
 
1240
.. i18n:     user = 'admin'
 
1241
.. i18n:     pwd = 'admin'
 
1242
.. i18n:     dbname = 'terp3'
 
1243
.. i18n:     model = 'res.partner'
 
1244
.. i18n: 
 
1245
.. i18n:     sock = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/common')
 
1246
.. i18n:     uid = sock.login(dbname ,user ,pwd)
 
1247
.. i18n: 
 
1248
.. i18n:     sock = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/object')
 
1249
.. i18n: 
 
1250
.. i18n:     # CREATE A PARTNER
 
1251
.. i18n:     partner_data = {'name'.. code-block:: php:'Tiny', 'active':True, 'vat':'ZZZZZ'}
 
1252
.. i18n:     partner_id = sock.execute(dbname, uid, pwd, model, 'create', partner_data)
 
1253
.. i18n: 
 
1254
.. i18n:     # The relation between res.partner and res.partner.category is of type many2many
 
1255
.. i18n:     # To add  categories to a partner use the following format:
 
1256
.. i18n:     partner_data = {'name':'Provider2', 'category_id': [(6,0,[3, 2, 1])]}
 
1257
.. i18n:     # Where [3, 2, 1] are id fields of lines in res.partner.category
 
1258
.. i18n: 
 
1259
.. i18n:     # SEARCH PARTNERS
 
1260
.. i18n:     args = [('vat', '=', 'ZZZZZ'),]
 
1261
.. i18n:     ids = sock.execute(dbname, uid, pwd, model, 'search', args)
 
1262
.. i18n: 
 
1263
.. i18n:     # READ PARTNER DATA
 
1264
.. i18n:     fields = ['name', 'active', 'vat', 'ref']
 
1265
.. i18n:     results = sock.execute(dbname, uid, pwd, model, 'read', ids, fields)
 
1266
.. i18n:     print results
 
1267
.. i18n: 
 
1268
.. i18n:     # EDIT PARTNER DATA
 
1269
.. i18n:     values = {'vat':'ZZ1ZZ'}
 
1270
.. i18n:     results = sock.execute(dbname, uid, pwd, model, 'write', ids, values)
 
1271
.. i18n: 
 
1272
.. i18n:     # DELETE PARTNER DATA
 
1273
.. i18n:     results = sock.execute(dbname, uid, pwd, model, 'unlink', ids)
 
1274
..
 
1275
 
 
1276
.. code-block:: python
 
1277
 
 
1278
    """
 
1279
    :The login function is under
 
1280
    ::    http://localhost:8069/xmlrpc/common
 
1281
    :For object retrieval use:
 
1282
    ::    http://localhost:8069/xmlrpc/object
 
1283
    """
 
1284
    import xmlrpclib
 
1285
 
 
1286
    user = 'admin'
 
1287
    pwd = 'admin'
 
1288
    dbname = 'terp3'
 
1289
    model = 'res.partner'
 
1290
 
 
1291
    sock = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/common')
 
1292
    uid = sock.login(dbname ,user ,pwd)
 
1293
 
 
1294
    sock = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/object')
 
1295
 
 
1296
    # CREATE A PARTNER
 
1297
    partner_data = {'name'.. code-block:: php:'Tiny', 'active':True, 'vat':'ZZZZZ'}
 
1298
    partner_id = sock.execute(dbname, uid, pwd, model, 'create', partner_data)
 
1299
 
 
1300
    # The relation between res.partner and res.partner.category is of type many2many
 
1301
    # To add  categories to a partner use the following format:
 
1302
    partner_data = {'name':'Provider2', 'category_id': [(6,0,[3, 2, 1])]}
 
1303
    # Where [3, 2, 1] are id fields of lines in res.partner.category
 
1304
 
 
1305
    # SEARCH PARTNERS
 
1306
    args = [('vat', '=', 'ZZZZZ'),]
 
1307
    ids = sock.execute(dbname, uid, pwd, model, 'search', args)
 
1308
 
 
1309
    # READ PARTNER DATA
 
1310
    fields = ['name', 'active', 'vat', 'ref']
 
1311
    results = sock.execute(dbname, uid, pwd, model, 'read', ids, fields)
 
1312
    print results
 
1313
 
 
1314
    # EDIT PARTNER DATA
 
1315
    values = {'vat':'ZZ1ZZ'}
 
1316
    results = sock.execute(dbname, uid, pwd, model, 'write', ids, values)
 
1317
 
 
1318
    # DELETE PARTNER DATA
 
1319
    results = sock.execute(dbname, uid, pwd, model, 'unlink', ids)
 
1320
 
 
1321
.. i18n: PRINT example:
 
1322
..
 
1323
 
 
1324
PRINT example:
 
1325
 
 
1326
.. i18n:    1. PRINT INVOICE
 
1327
.. i18n:    2. IDS is the invoice ID, as returned by:
 
1328
.. i18n:    3. ids = sock.execute(dbname, uid, pwd, 'account.invoice', 'search', [('number', 'ilike', invoicenumber), ('type', '=', 'out_invoice')])
 
1329
..
 
1330
 
 
1331
   1. PRINT INVOICE
 
1332
   2. IDS is the invoice ID, as returned by:
 
1333
   3. ids = sock.execute(dbname, uid, pwd, 'account.invoice', 'search', [('number', 'ilike', invoicenumber), ('type', '=', 'out_invoice')])
 
1334
 
 
1335
.. i18n: .. code-block:: python
 
1336
.. i18n: 
 
1337
.. i18n:     import time
 
1338
.. i18n:     import base64
 
1339
.. i18n:     printsock = xmlrpclib.ServerProxy('http://server:8069/xmlrpc/report')
 
1340
.. i18n:     model = 'account.invoice'
 
1341
.. i18n:     id_report = printsock.report(dbname, uid, pwd, model, ids, {'model': model, 'id': ids[0], 'report_type':'pdf'})
 
1342
.. i18n:     time.sleep(5)
 
1343
.. i18n:     state = False
 
1344
.. i18n:     attempt = 0
 
1345
.. i18n:     while not state:
 
1346
.. i18n:         report = printsock.report_get(dbname, uid, pwd, id_report)
 
1347
.. i18n:         state = report['state']
 
1348
.. i18n:         if not state:
 
1349
.. i18n:         time.sleep(1)
 
1350
.. i18n:         attempt += 1
 
1351
.. i18n:         if attempt>200:
 
1352
.. i18n:         print 'Printing aborted, too long delay !'
 
1353
.. i18n: 
 
1354
.. i18n:         string_pdf = base64.decodestring(report['result'])
 
1355
.. i18n:         file_pdf = open('/tmp/file.pdf','w')
 
1356
.. i18n:         file_pdf.write(string_pdf)
 
1357
.. i18n:         file_pdf.close()
 
1358
..
 
1359
 
 
1360
.. code-block:: python
 
1361
 
 
1362
    import time
 
1363
    import base64
 
1364
    printsock = xmlrpclib.ServerProxy('http://server:8069/xmlrpc/report')
 
1365
    model = 'account.invoice'
 
1366
    id_report = printsock.report(dbname, uid, pwd, model, ids, {'model': model, 'id': ids[0], 'report_type':'pdf'})
 
1367
    time.sleep(5)
 
1368
    state = False
 
1369
    attempt = 0
 
1370
    while not state:
 
1371
        report = printsock.report_get(dbname, uid, pwd, id_report)
 
1372
        state = report['state']
 
1373
        if not state:
 
1374
        time.sleep(1)
 
1375
        attempt += 1
 
1376
        if attempt>200:
 
1377
        print 'Printing aborted, too long delay !'
 
1378
 
 
1379
        string_pdf = base64.decodestring(report['result'])
 
1380
        file_pdf = open('/tmp/file.pdf','w')
 
1381
        file_pdf.write(string_pdf)
 
1382
        file_pdf.close()
 
1383
 
 
1384
.. i18n: PHP Example
 
1385
.. i18n: -----------
 
1386
..
 
1387
 
 
1388
PHP Example
 
1389
-----------
 
1390
 
 
1391
.. i18n: Here is an example on how to insert a new partner using PHP. This example makes use the phpxmlrpc library, available on sourceforge.
 
1392
..
 
1393
 
 
1394
Here is an example on how to insert a new partner using PHP. This example makes use the phpxmlrpc library, available on sourceforge.
 
1395
 
 
1396
.. i18n: .. code-block:: php
 
1397
.. i18n: 
 
1398
.. i18n:     <?
 
1399
.. i18n: 
 
1400
.. i18n:         include('xmlrpc.inc');
 
1401
.. i18n: 
 
1402
.. i18n:         $arrayVal = array(
 
1403
.. i18n:         'name'=>new xmlrpcval('Fabien Pinckaers', "string") ,
 
1404
.. i18n:         'vat'=>new xmlrpcval('BE477472701' , "string")
 
1405
.. i18n:         );
 
1406
.. i18n: 
 
1407
.. i18n:         $client = new xmlrpc_client("http://localhost:8069/xmlrpc/object");
 
1408
.. i18n: 
 
1409
.. i18n:         $msg = new xmlrpcmsg('execute');
 
1410
.. i18n:         $msg->addParam(new xmlrpcval("dbname", "string"));
 
1411
.. i18n:         $msg->addParam(new xmlrpcval("3", "int"));
 
1412
.. i18n:         $msg->addParam(new xmlrpcval("demo", "string"));
 
1413
.. i18n:         $msg->addParam(new xmlrpcval("res.partner", "string"));
 
1414
.. i18n:         $msg->addParam(new xmlrpcval("create", "string"));
 
1415
.. i18n:         $msg->addParam(new xmlrpcval($arrayVal, "struct"));
 
1416
.. i18n: 
 
1417
.. i18n:         $resp = $client->send($msg);
 
1418
.. i18n: 
 
1419
.. i18n:         if ($resp->faultCode())
 
1420
.. i18n: 
 
1421
.. i18n:             echo 'Error: '.$resp->faultString();
 
1422
.. i18n: 
 
1423
.. i18n:         else
 
1424
.. i18n: 
 
1425
.. i18n:             echo 'Partner '.$resp->value()->scalarval().' created !';
 
1426
.. i18n: 
 
1427
.. i18n:         ?>
 
1428
..
 
1429
 
 
1430
.. code-block:: php
 
1431
 
 
1432
    <?
 
1433
 
 
1434
        include('xmlrpc.inc');
 
1435
 
 
1436
        $arrayVal = array(
 
1437
        'name'=>new xmlrpcval('Fabien Pinckaers', "string") ,
 
1438
        'vat'=>new xmlrpcval('BE477472701' , "string")
 
1439
        );
 
1440
 
 
1441
        $client = new xmlrpc_client("http://localhost:8069/xmlrpc/object");
 
1442
 
 
1443
        $msg = new xmlrpcmsg('execute');
 
1444
        $msg->addParam(new xmlrpcval("dbname", "string"));
 
1445
        $msg->addParam(new xmlrpcval("3", "int"));
 
1446
        $msg->addParam(new xmlrpcval("demo", "string"));
 
1447
        $msg->addParam(new xmlrpcval("res.partner", "string"));
 
1448
        $msg->addParam(new xmlrpcval("create", "string"));
 
1449
        $msg->addParam(new xmlrpcval($arrayVal, "struct"));
 
1450
 
 
1451
        $resp = $client->send($msg);
 
1452
 
 
1453
        if ($resp->faultCode())
 
1454
 
 
1455
            echo 'Error: '.$resp->faultString();
 
1456
 
 
1457
        else
 
1458
 
 
1459
            echo 'Partner '.$resp->value()->scalarval().' created !';
 
1460
 
 
1461
        ?>
 
1462
 
 
1463
.. i18n: Perl Example
 
1464
.. i18n: ------------
 
1465
.. i18n: Here is an example in Perl for creating, searching and deleting a partner.
 
1466
..
 
1467
 
 
1468
Perl Example
 
1469
------------
 
1470
Here is an example in Perl for creating, searching and deleting a partner.
 
1471
 
 
1472
.. i18n: .. code-block:: perl
 
1473
.. i18n: 
 
1474
.. i18n:   #!c:/perl/bin/perl
 
1475
.. i18n:   # 17-02-2010
 
1476
.. i18n:   # OpenERP XML RPC communication example
 
1477
.. i18n:   # Todor Todorov <todorov@hp.com> <tttodorov@yahoo.com>
 
1478
.. i18n: 
 
1479
.. i18n:   use strict;
 
1480
.. i18n:   use Frontier::Client;
 
1481
.. i18n:   use Data::Dumper;
 
1482
.. i18n: 
 
1483
.. i18n:   my($user) = 'admin';
 
1484
.. i18n:   my($pw) = 'admin';
 
1485
.. i18n:   my($db) = 'put_your_dbname_here';
 
1486
.. i18n:   my($model) = 'res.partner';
 
1487
.. i18n: 
 
1488
.. i18n:   #login
 
1489
.. i18n:   my $server_url = 'http://localhost:8069/xmlrpc/common';
 
1490
.. i18n:   my $server = Frontier::Client->new('url' => $server_url);
 
1491
.. i18n:   my $uid = $server->call('login',$db,$user,$pw);
 
1492
.. i18n: 
 
1493
.. i18n:   print Dumper($uid);
 
1494
.. i18n: 
 
1495
.. i18n:   my $server_url = 'http://localhost:8069/xmlrpc/object';
 
1496
.. i18n:   my $server = Frontier::Client->new('url' => $server_url);
 
1497
.. i18n: 
 
1498
.. i18n:   print Dumper($server);
 
1499
.. i18n: 
 
1500
.. i18n:   #
 
1501
.. i18n:   # CREATE A PARTNER
 
1502
.. i18n:   #
 
1503
.. i18n:   my $partner_data = {'name'=>'MyNewPartnerName',
 
1504
.. i18n:                     'active'=> 'True',
 
1505
.. i18n:             'vat'=>'ZZZZZ'};
 
1506
.. i18n:   my $partner_id = $server->call('execute',$db, $uid, $pw, $model, 'create', $partner_data);
 
1507
.. i18n: 
 
1508
.. i18n:   print Dumper($partner_id);
 
1509
.. i18n: 
 
1510
.. i18n:   #
 
1511
.. i18n:   # SEARCH PARTNERS
 
1512
.. i18n:   #
 
1513
.. i18n:   my $query = [['vat', '=', 'ZZZZZ']];
 
1514
.. i18n: 
 
1515
.. i18n:   print Dumper($query);
 
1516
.. i18n: 
 
1517
.. i18n:   my $ids = $server->call('execute',$db, $uid, $pw, $model, 'search', $query);
 
1518
.. i18n: 
 
1519
.. i18n:   print Dumper($ids);
 
1520
.. i18n: 
 
1521
.. i18n:   #Here waiting for user input
 
1522
.. i18n:   #OpenERP interface my be checked if partner is shown there
 
1523
.. i18n: 
 
1524
.. i18n:   print $/."Check OpenERP if partner is inserted. Press ENTER".$/;
 
1525
.. i18n:   <STDIN>;
 
1526
.. i18n: 
 
1527
.. i18n:   #
 
1528
.. i18n:   # DELETE PARTNER DATA
 
1529
.. i18n:   #
 
1530
.. i18n:   my $results = $server->call('execute',$db, $uid, $pw, $model, 'unlink', $ids);
 
1531
.. i18n: 
 
1532
.. i18n:   print Dumper($results);
 
1533
..
 
1534
 
 
1535
.. code-block:: perl
 
1536
 
 
1537
  #!c:/perl/bin/perl
 
1538
  # 17-02-2010
 
1539
  # OpenERP XML RPC communication example
 
1540
  # Todor Todorov <todorov@hp.com> <tttodorov@yahoo.com>
 
1541
 
 
1542
  use strict;
 
1543
  use Frontier::Client;
 
1544
  use Data::Dumper;
 
1545
 
 
1546
  my($user) = 'admin';
 
1547
  my($pw) = 'admin';
 
1548
  my($db) = 'put_your_dbname_here';
 
1549
  my($model) = 'res.partner';
 
1550
 
 
1551
  #login
 
1552
  my $server_url = 'http://localhost:8069/xmlrpc/common';
 
1553
  my $server = Frontier::Client->new('url' => $server_url);
 
1554
  my $uid = $server->call('login',$db,$user,$pw);
 
1555
 
 
1556
  print Dumper($uid);
 
1557
 
 
1558
  my $server_url = 'http://localhost:8069/xmlrpc/object';
 
1559
  my $server = Frontier::Client->new('url' => $server_url);
 
1560
 
 
1561
  print Dumper($server);
 
1562
 
 
1563
  #
 
1564
  # CREATE A PARTNER
 
1565
  #
 
1566
  my $partner_data = {'name'=>'MyNewPartnerName',
 
1567
                    'active'=> 'True',
 
1568
            'vat'=>'ZZZZZ'};
 
1569
  my $partner_id = $server->call('execute',$db, $uid, $pw, $model, 'create', $partner_data);
 
1570
 
 
1571
  print Dumper($partner_id);
 
1572
 
 
1573
  #
 
1574
  # SEARCH PARTNERS
 
1575
  #
 
1576
  my $query = [['vat', '=', 'ZZZZZ']];
 
1577
 
 
1578
  print Dumper($query);
 
1579
 
 
1580
  my $ids = $server->call('execute',$db, $uid, $pw, $model, 'search', $query);
 
1581
 
 
1582
  print Dumper($ids);
 
1583
 
 
1584
  #Here waiting for user input
 
1585
  #OpenERP interface my be checked if partner is shown there
 
1586
 
 
1587
  print $/."Check OpenERP if partner is inserted. Press ENTER".$/;
 
1588
  <STDIN>;
 
1589
 
 
1590
  #
 
1591
  # DELETE PARTNER DATA
 
1592
  #
 
1593
  my $results = $server->call('execute',$db, $uid, $pw, $model, 'unlink', $ids);
 
1594
 
 
1595
  print Dumper($results);
 
1596
 
 
1597
.. i18n: Everything done in the GTK or web client in OpenERP is through XML/RPC webservices. Start openERP GTK client
 
1598
.. i18n: using ./openerp-client.py -l debug_rpc (or debug_rpc_answer) then do what you want in the GTK client and watch
 
1599
.. i18n: your client logs, you will find out the webservice signatures. By creating indents in the logs will help you to
 
1600
.. i18n: spot which webservice you want.
 
1601
..
 
1602
 
 
1603
Everything done in the GTK or web client in OpenERP is through XML/RPC webservices. Start openERP GTK client
 
1604
using ./openerp-client.py -l debug_rpc (or debug_rpc_answer) then do what you want in the GTK client and watch
 
1605
your client logs, you will find out the webservice signatures. By creating indents in the logs will help you to
 
1606
spot which webservice you want.