how to iterate ono2many and add the quantities of the products with the same name or id

Viewed 39

(Model list of materials "components") odoo studio; If I have two similar products and then choose two other products with the same id as shown in the image, the amount that belongs to them must be added and stored in a list and then divided with the amount by hand for each result.

We achieve that only the first two products are added, and the other two equals are not added.

for record in self:[enter image description here][1]
  dog = 0
  if = 0
  can1 = 0
  id1 = 0
  id2 = 0
  p = True
  minor=999999
  list = []

  for cm in record.bom_line_ids:
    # validates that it takes the amount by hand from the first row yes or yes, it
     #we did like this since I didn't want to take the first line
    if cm.x_studio_id_product and p == True:
      record['x_studio_suma3_1'] = cm.x_studio_amount_on_hand
      p = False
      se = cm.x_studio_id_product
     
      for and in record.bom_line_ids:
       if e.x_studio_id_product == se:
         id2 = se
         can = e.x_studio_quantity_on_hand
       
      # validates with the product id if they are equal and so add them
       if e.x_studio_id_product == se:
         id1 = se
         can1 += e.product_qty
   
       elif id1 == id2:
         result = can / can1 if can1 else 0
         list.append(result)
         for number in list:
            if number<smaller:
              smaller=number'enter code here`
              record['x_studio_sum3_1'] = smallest[enter image description here][1]
0 Answers
Related