I have dynamic report that bring customers and product quantity
how to get product quantity sold and delivery to particular customer ?
like this table:
partner | product1 | product2 | product3 |
customer1 | 12 | 10 | o |
customer2 | o | 3 | o |
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
I have dynamic report that bring customers and product quantity
how to get product quantity sold and delivery to particular customer ?
like this table:
partner | product1 | product2 | product3 |
customer1 | 12 | 10 | o |
customer2 | o | 3 | o |
Hi,
By using the search or search count, you can fetch the value from corresponding database models right,
see an example:
partner_a_product_a_count = self.env['sale.order.line'].search_count(
[('order_partner_id', '=', partner_a.id), ('product_id', '=', product_a.id)])
You can pass the values accordingly to the above code or even you can change it to sql queries to fetch data in efficient way.
Thanks
HI Niyas.. I use these query but seem that something wrong
"""SELECT distinct pt.name as product ,
s.id,
s.date_order
,p.name as partner
,sum(sl.product_uom_qty) as qty
FROM public.sale_order as s
left join res_partner as p on s.partner_id=p.id
inner join sale_order_line as sl on sl.order_id= s.id
left join product_product as pp on pp.id =sl.product_id
left join product_template as pt on pt.id = pp.product_tmpl_id
where s.state='sale' and sl.order_partner_id = p.id
group by s.id,
s.date_order
,p.name
,pt.name
order by s.id """
the output repeat customers and products and does not domain quants for each customer