"ESX, 37 products invoiced, 69$ total"
I got it! If anyone is also wondering how to this, I did it within my custom module.
First of all, you have to create two new fields in python code. The first in the model "sale.order.line" which gets the category of the product model. It should look like this:
x_category_on_saleorderline = fields.Many2one(related="product_id.categ_id")Now we have the field on the sale.order.line so we can process it to the invoice by creating another related field on the model "account.move.line". This should look like following:
x_category_on_invoiceline = fields.Many2one(related='sale_line_ids.xcategory_on_saleorderline')
Now we can add the field to the invoice QWeb template and even filter it there. For example, to get the summed up quantities for one category I did it like:
<span t-esc="int(sum(line.quantity for line in lines.filtered(lambda r: r.x_category_on_invoiceline.name == '[name of category]')))"/>
Don't mind to contact me if you have any questions regarding this.