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:
For example, the product "Aceite Hidraulico" appears 3 times on the invoice. Then the function should return a 3 for this product.
Well, this is the function I have in my account.invoice.py:
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
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.
What should I do?
This is the message showing Odoo:
for product in po.product_id.id:TypeError:
intobject is not iterable
Thank you very much for your help and time spent. I appreciate any suggestions or advice to get what you want to do.
