Search code examples
phpapiodoo-8odoo

How to get get order from openerp between a specific date dynamically using PHP?


Actually, I need help to get sales order from openerp, I am getting the records but the issue is that when I logged in to openerp and going to sales order and checking for the records of one particular date then it showing me 22 records on the site.

At the same time the logic we put in our script to get the sales order is getting only 3 records for the same date.

We have put logic as below:-
1. We are making connection and getting res.partner id's using below code
$ids = $models->execute_kw($db, $uid, $password,
    'res.partner', 'search',
     array(array(array('is_company', '=', true),
      array('customer', '=', true)
     ))
    );
2. After that I am getting all partner id's for the specific date via below given code
$partner_ids = $models->execute_kw($db, $uid, $password,
      'sale.order', 'search',array(array(array('partner_id', '=', $ids),array('create_date', '>=', '2018-04-17 00:00:00'),array('create_date', '<=', '2018-04-17 23:59:59')))
          );

3. After that I am getting all sales record from the below given code
$saledata=$models->execute_kw($db, $uid, $password,
     'sale.order', 'read',
     array($partner_ids)
    );

And the above code is giving me only few orders but there are lot's of order on the site.

When I remove array('is_company', '=', true) from my first request then it is giving 115 records for the same date.

Please let me know the way so that I can get all sales orders which are showing in the site


Solution

  • Agree with @CZoellner, follow his comment and these answer.

    It seems like you are trying to search in sale order with date. So technical field name is "date_order".

    Replace create_date condition with date_order

    And also you need to take care of following items:

    • Sale order status,
    • Specific company record,
    • If not looking for specific Customer, then remove partner_ids condition