Invoice lines by move

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):

  1. Create a sale line with quantity=2. Process the sale.
  2. On the shipment, send quantity=1
  3. An invoice is created with 1u.
  4. Send the rest of the goods left (1u)
  5. A line is added with 1u.
  6. So we have an invoice with 2 lines (quantities: 1+1)
  7. Remove the invoice (invoice is recreated)
  8. 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 :slight_smile:

I do not see the point, you will always need to deal with multiple moves linked to an invoice line just because there is stock split, stock package etc.