Hello,
I need to automate the task of generating a report of the POS statistics.
The same as described here: https://www.odoo.com/documentation/user/9.0/point_of_sale/analyze/statistics.html
So I was trying to generate the totals based on some criteria without doing the entire process of getting orders, then getting the order lines, read the products and sum the totals and more...
I found that the model report.pos.order retrieves the data I need but I needed to group it by some fields.
Example:
$models = ripcord::client("$url/xmlrpc/2/object");
$report = $models->execute_kw($db, $uid, $password, 'report.pos.order', 'search', array(array()));
But i found that the method read_group allows me to group the report.pos.order by specified fields .
Based on: https://www.odoo.com/documentation/9.0/reference/orm.html
$fields = [];
$groupby = ['product_id','config_id'];
$criteria = [['date', '>=', '2019-11-01 00:00:00']];
$data = $models->execute_kw($db, $uid, $password, 'report.pos.order', 'read_group', array($criteria), array('fields'=>$fields, 'groupby'=>$groupby));
This is better because I can get the final values of the actual report based on criteria and groups. But it only groups by the first field declared (product_id) in this case because the last one on $groupby doesn't make any change.
But in the Pivot view of POS Analysis you can set multiple groups and it will retrieve a full list.
How is this possible through API?
I would appreciate any help!
Thank you!
Technical Details:
- PHP 7.1
- Odoo 9.0c
- Ripcord: https://github.com/DarkaOnLine/Ripcord