Quiero sumar las cantidades de los productos por id o nombre, es decir si tengo 3 productos iguales en un campo one2many, cada uno con diferente cantidad y luego se agrega 2 veces otro producto con diferente cantidad, al final Quiero mostrar la cantidad total en otro campo que muestre el nombre y la cantidad total de los dos productos
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- إدارة علاقات العملاء
- e-Commerce
- المحاسبة
- المخزون
- PoS
- Project
- MRP
لقد تم الإبلاغ عن هذا السؤال
1
الرد
3131
أدوات العرض
Hello,
First you need to define a function according to your requirement, In the function you need to get the orderlines of corresponding _order,
ie,
order_lines = self.env['sale.order.line'].search([('order_id', '=', self.id)])
now you need to get the products and corresponding quantity, for that
product = []
qty = []
for order in order_lines:
if order.product_id not in product:
product.append(order.product_id)
qty.append(order.product_uom_qty)
else:
index = product.index(order.product_id)
qty[index] += order.product_uom_qty
Here you will get each product and their qty respectively in the lists product and qty. You can add the values from the list to the needed field by looping them.
Regards
هل أعجبك النقاش؟ لا تكن مستمعاً فقط. شاركنا!
أنشئ حساباً اليوم لتستمتع بالخصائص الحصرية، وتفاعل مع مجتمعنا الرائع!
تسجيلالمنشورات ذات الصلة | الردود | أدوات العرض | النشاط | |
---|---|---|---|---|
|
1
يوليو 23
|
4132 | ||
|
3
يوليو 24
|
6812 | ||
|
1
أغسطس 23
|
2595 | ||
|
1
ديسمبر 22
|
3834 | ||
|
0
أكتوبر 22
|
2975 |