Odoo Help

Welcome!

This community 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.

0

odoo 8: Perl XMLRPC to lookup product pricelist help

By
Steve Switzer
on 1/16/15, 10:49 PM 807 views

I tried several different ways and calls and I finally have things typed correctly, but after several attempts I can't get past this last error. I've tried calling product.product name_search and I get back ID 1 for the product I want a price for. However, in the product.pricelist model, I've called price_get and price_get_multi and both fail the same way:

Fault returned from XML RPC Server, fault code 2: No value found for product.product('1',).product_tmpl_id

My goal is to lookup the current price of a product for a particular customer, given the current price list.
Here's the code that I'm using with some of my other attempts commented out:

sub get_labor_price {
  my ($pricelistid) = @_;
  my ($uid, $server, $index);
  $server = Frontier::Client->new('url' => $Hours2odoo::Config{O_SERVERURL}.'/xmlrpc/common');
  $uid = $server->call('login',$Hours2odoo::Config{O_DBNAME},$Hours2odoo::Config{O_USERNAME},$Hours2odoo::Config{O_PASSWORD});
  print "UID: $uid\n" if ${DEBUG}>=10;

  $server = Frontier::Client->new('url' => $Hours2odoo::Config{O_SERVERURL}.'/xmlrpc/2/object');
 
  my $query = [
                ['name', '=', 'LAB-Hours'],
            ];
=begin     
  my $productprice = $server->call('execute',
            $Hours2odoo::Config{O_DBNAME}, $uid, $Hours2odoo::Config{O_PASSWORD},
            'product.product', 'search_read', $query
  );
  #print Dumper($productprice);
=cut
 
  print 'Pricelist ID: '.$pricelistid."\n";
  my $productid=$Hours2odoo::Config{O_PARTID};
  #self.pool.get('product.pricelist').price_get(cr, uid, [pricelist], product, qty or 1.0, partner_id, {'uom': 'Hours', 'date': date_order, })            
  my $productprice = $server->call('execute',
            $Hours2odoo::Config{O_DBNAME}, $uid, $Hours2odoo::Config{O_PASSWORD},
#            'product.pricelist', 'price_get', $server->int($pricelistid), $server->string($productid), $server->string(6)
            'product.pricelist', 'price_get', $server->int($pricelistid), $server->string($productid), $server->int(6)
            
#            'product.pricelist', 'price_get_multi', $server->string($pricelistid),
#            [
#                [$productid, 1, 6],
#            ],
 
  );
  print "PRICE: $productprice\n";
}

This is generating an XML request like this:

<?xml version="1.0"?>
<methodCall>
<methodName>execute</methodName>
<params>
<param><value><string>SBS</string></value></param>
<param><value><i4>1</i4></value></param>
<param><value><string>xxxxxxxxx</string></value></param>
<param><value><string>product.pricelist</string></value></param>
<param><value><string>price_get</string></value></param>
<param><value><int>5</int></value>
</param>
<param><value><string>1</string></value>
</param>
<param><value><string>6</string></value>
</param>
</params>
</methodCall>

The response is this:

<?xml version='1.0'?>
<methodResponse>
<fault>
<value><struct>
<member>
<name>faultCode</name>
<value><int>2</int></value>
</member>
<member>
<name>faultString</name>
<value><string>No value found for product.product('1',).product_tmpl_id</string></value>
</member>
</struct></value>
</fault>
</methodResponse>

I would appreciate any insight into why this is not workout the way I expected. Thank you!

Steve

0
IWEINS
On 5/6/15, 12:29 PM

Hi Steve,

I have the same problem, have you found a solution?

Thax

Nicolas


Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 1/16/15, 10:49 PM
Seen: 807 times
Last updated: 5/6/15, 12:29 PM