calculate the quantity invoiced for a product and display the total on the product page, using new computed field that sums the invoiced
quantities from all relevant invoices so i tried this function :
for product in self:
total_invoiced_qty = 0
invoice_lines = self.env['account.move.line'].search([
('product_id', '=', product.id),
('move_id.state', 'in', ['posted']), # Consider only posted invoices
('move_id.invoice_date', '>=', '2023-01-01'),
('move_id.invoice_date', '>=', '2023-12-31'),
('move_id.move_type', '=', 'out_invoice') # Consider only customer invoices
])
for line in invoice_lines:
total_invoiced_qty =total_invoiced_qty + line.quantity
product['x_studio_integer_fieldstockint'] = total_invoiced_qty
i found that the given result id difeerent than sales report
https://i.imgur.com/77tLRO2.png