Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
1 Balas
5584 Tampilan

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
Buang
Jawaban Terbai

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
Buang
Penulis

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

Post Terkait Replies Tampilan Aktivitas
1
Sep 15
4233
0
Feb 22
5318
5
Feb 24
35468
0
Mar 17
3949
0
Jun 23
3531