I want to add the quantities of the products by id or name, that is, if I have 3 equal products in a one2many field, each one with a different quantity and then another product with a different quantity is added 2 times, at the end I want to show the total quantity in another field showing the name and total quantity of the two products.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Akuntansi
- Inventaris
- PoS
- Project
- MRP
Pertanyaan ini telah diberikan tanda
1
Balas
3728
Tampilan
product_qty = {}
for line in order.order_line: # assuming "order" is the parent record with a one2many field "order_line"
if line.product_id.id in product_qty:
product_qty[line.product_id.id] += line.product_uom_qty
else:
product_qty[line.product_id.id] = line.product_uom_qty
# Now, product_qty dictionary will contain product IDs as keys and their respective quantities as values
Menikmati diskusi? Jangan hanya membaca, ikuti!
Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!
DaftarPost Terkait | Replies | Tampilan | Aktivitas | |
---|---|---|---|---|
|
1
Nov 23
|
2159 | ||
|
1
Okt 23
|
2784 | ||
How can I delete an Odoo.sh project completely?
Diselesaikan
|
|
3
Jul 24
|
6030 | |
Merge Same Item in Sale Order Line
Diselesaikan
|
|
2
Jan 24
|
5378 | |
|
1
Agu 23
|
2060 |
Hi,
Try refer the following forum post
https://www.odoo.com/forum/help-1/como-puedo-recorrer-un-campo-one2many-y-sumar-la-cantidad-de-productos-que-tienen-el-mismo-id-en-odoo-version-15-223705