Odoo Help

2

0
3 Answers
1
Avatar

Andreas Brueckl Austria

--Andreas Brueckl--

5546
| 8 8 9
Vienna, Austria
--Andreas Brueckl--
OpenERP Consulting and Development
Andreas Brueckl Austria
3/19/13, 8:04 AM

You first have to obtain the ids. You can do this with the search method like this:

my $ids = $server->call('execute',$db, $uid, $pw, $model, 'search', []);

I am not a Perl expert, so maybe the [] is not correct. [] should denote an empty array. (Maybe you can use '' instead)

Afterward you can execute the read method:

my $data = $server->call('execute',$db, $uid, $pw, $model, 'read', $ids, '');

If you want to only see certain fields you have to pass an array with the field names instead of the ''.

1 Comment
Nicolas C France
3/19/13, 11:09 AM

Thank you for your help. I dealed with the perl syntax but keep your "idea" : 1) make a search on all ids (using ' ') 2) use theses ids within read method.

0
Nicolas C France
3/19/13, 11:17 AM

Thank you yo Andreas I have the solution.

1st => search all ids 2nd => read the selected fields on the whole list of ids.

Only 2 rpc-xml requests :o)

Here is my code now :

#!/usr/bin/perl
use strict;
use warnings;
use Frontier::Client;
use Data::Dumper;

my($user) = 'admin';
my($pw) = 'admin';
my($db) = 'Base2';
my($model) = 'product.product';

#login
my $server_url = 'h t t p : / / localhost:8069/xmlrpc/common';
my $server = Frontier::Client->new('url' => $server_url);
my $uid = $server->call('login',$db,$user,$pw);

my $server_url = 'h t t p : / / localhost:8069/xmlrpc/object';
my $server = Frontier::Client->new('url' => $server_url);

# 1) search all ids
my $ids = $server->call('execute',$db, $uid, $pw, $model, 'search', '');

# 2) read the whole range of ids with required field only :
my $fields = ['name', 'default_code', 'ids'];
my $data = $server->call('execute',$db, $uid, $pw, $model, 'read', $ids, $fields);

print Dumper($data);
0
Avatar

saad Morocco

--saad--

1028
| 5 4 10
Casablanca, Morocco
--saad--
saad Morocco
3/19/13, 8:05 AM

Use a search function with empty args to get all ids :

my $ids = $server->call('execute',$db, $uid, $pw, $model, 'search', []); 
my $fields = ['name','defaut_code']; 
my $data = $server->call('execute',$db, $uid, $pw, $model, 'read', $ids, $fields); 
print Dumper($data);
Ask a Question
Writer
Keep Informed
0 follower(s)
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now