I`m crazy with instruction for making possible search something via OpenERPProxy::search

we have to send array()
but...
what kind of array?

may be someone can help me with a real example
I see a few documentation lines at openerp http://doc.openerp.com/v6.0/developer/6_22_XML-RPC_web_services/index.ht...

     $key = array(new xmlrpcval(array(new xmlrpcval($attribute , "string"),
              new xmlrpcval($operator,"string"),
              new xmlrpcval($keys,"string")),"array"),
        );

in openerp proxy
we are using a bit more different code

  public function request($module, $action, $args = array()) {
  	$ultimate_callback_args = array();
    $url  = variable_get('openerp.url', '');
  	$path = $url."/".$module;
  	$ultimate_callback_args[0]=$path;
  	$ultimate_callback_args[1][$action]=$args;
....

And I`m loosing my mind thinking about how to make search array()

Comments

podarok’s picture

Component: Code » Documentation
Priority: Normal » Critical
lipinponmala007’s picture

dear Podarok.. i didn't understand exactly what you have mentioned..but let me do a guess pls neglect if i make any nonsense..

as an example let me take a project info from openERP searching for any project with id =27

<?php
$proxy =OpenERPProxy::getProxy()
$project_id = $proxy->search=('project.project',$search=array(array('id','=','27')),$offset=0,$limit=10);
print_R($project_id);


//$search=array(array('id','=','27'),(array('id','=','68')) for 27 and 68

?>
sduensin’s picture

I've got a related issue... How do you search on fields returned as arrays? Such as 'partner_id'? I've tried:

$ids = $proxy->search=('project.issue', array(array('partner_id', '=', $partner_id)), 0, 0);

However, 'partner_id' contains both an integer and a string in an array. How can I pull a list of issues for a particular partner?

Thanks.

sduensin’s picture

Status: Active » Fixed

Ok, I'm not sure what was wrong before. Guessing a cache somewhere wasn't flushed. For anyone else who runs into this, you just search for the integer portion of combined fields like partner_id and company_id. The code snippit posted above works if $partner_id is an integer.

lipinponmala007’s picture

omg!!! so that was the confusion ..i couldn't understand it before...thanks sduensin..
case1: the searching field is not an array like id.Then

<?php
$proxy =OpenERPProxy::getProxy();

$project_id = $proxy->search=('project.project',$search=array(array('id','=','27')),$offset=0,$limit=10);
print_R($project_id);
?>

case 2a: the searching field is an array like 'partner_id', then above fails..i.e $search=array(array('partner_id','=','34'));
so to search by partner Id .Then

<?php
$partner_id=34;
$project_id = $proxy->search=('project.project',$search=array(array('partner_id','=',$partner_id)),$offset=0,$limit=10);
?>

Why not..? we can do by partner name

<?php
$partner_id="casesentivepartner Name";
$project_id = $proxy->search=('project.project',$search=array(array('partner_id','=',$partner_id)),$offset=0,$limit=10);
?>

also

<?php
$partner_id="case sentivepartner Name";
$project_id = $proxy->search=('project.project',$search=array(array('partner_id','like',$partner_id)),$offset=0,$limit=10);
?>

hope you will try this...

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.