Odoo Error: TypeError: 'int' object is not iterable
<p>I'm creating a function in the invoice module. What you should do is to have this function products line are equal invoice and return the amount per product. This is better explained in the following image:</p>

<p><a href="https://i.stack.imgur.com/D5iBh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/D5iBh.png" alt="enter image description here"></a></p>

<p>For example, the product "Aceite Hidraulico" appears 3 times on the invoice. Then the function should return a 3 for this product.</p>

<p>Well, this is the function I have in my account.invoice.py:</p>

<pre><code>total_quantity = fields.Integer(compute='count_invoice_invoice', string = 'Cantidad Productos', readonly = True, store=True)

@api.one
@api.depends('invoice_line_ids.product_id')
def count_invoice_invoice(self):
    res = {}
    counter = 0
    for po in self.invoice_line_ids:
        for product in po.product_id.id:
            counter += 1
            res [self.total_quantity] = counter
    return res
</code></pre>

<p>For the function to differentiate between one product and another, I use the id field product.product model. But when I try to create the invoice, Odoo shows me a message int type fields can not be iterables. This is a problem because the id field to differentiate products is an integer.</p>

<p>What should I do?</p>

<p>This is the message showing Odoo:</p>

<blockquote>
<pre><code>for product in po.product_id.id:
</code></pre>
  
  <p>TypeError: <code>int</code> object is not iterable</p>
</blockquote>

<p>Thank you very much for your help and time spent. I appreciate any suggestions or advice to get what you want to do.</p>