Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
5582 Zobrazení

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


Avatar
Zrušit
Nejlepší odpověď

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


Avatar
Zrušit
Autor

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

Related Posts Odpovědi Zobrazení Aktivita
1
zář 15
4232
0
úno 22
5318
5
úno 24
35467
0
bře 17
3949
0
čvn 23
3531