A common request we have is when a customer wants monthly invoices (sale_invoice_grouping
) is to group the invoice lines by it’s shipment.
Apart from the request, a not intuitive behavior occurs in case of multiple shipments when invoice_method='shipment'
(also using sale_invoice_grouping
):
- Create a sale line with quantity=2. Process the sale.
- On the shipment, send quantity=1
- An invoice is created with 1u.
- Send the rest of the goods left (1u)
- A line is added with 1u.
- So we have an invoice with 2 lines (quantities: 1+1)
- Remove the invoice (invoice is recreated)
- We now have an invoice with 1 line (quantity: 2)
= Notice the difference of lines between step 6 and 8
When we have a scenario like step 6, it’s easy to solve with a groupby of the line by its stock moves shipments (because there’s only one move). Then we just render on the report a separation line with the corresponding shipment.
But when the invoice is recreated (step 8), the same product line have 2 moves so the grouping can not work anymore.
To address both aspects, I have already partially implemented the following change that I was planning to propose:
- Create a new
invoice_method='move'
. Leverage existing_get_invoice_line_moves()
to create an invoice line of each move. - Create a property for the invoice report that group the lines by:
shipment
,sale
Looking forward to hearing your thoughts