تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
5645 أدوات العرض

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

المنشورات ذات الصلة الردود أدوات العرض النشاط
1
سبتمبر 15
4294
0
فبراير 22
5433
5
فبراير 24
35659
0
مارس 17
4041
0
يونيو 23
3592