Skip to content

[19.0][FIX] account_invoice_report_grouped_by_picking: convert grouped qty to invoice line UoM - #424

Merged
OCA-git-bot merged 1 commit into
OCA:19.0from
rwagemans:19.0-account_invoice_report_grouped_by_picking-fix-uom
Jun 25, 2026
Merged

[19.0][FIX] account_invoice_report_grouped_by_picking: convert grouped qty to invoice line UoM#424
OCA-git-bot merged 1 commit into
OCA:19.0from
rwagemans:19.0-account_invoice_report_grouped_by_picking-fix-uom

Conversation

@rwagemans

Copy link
Copy Markdown

Bug

lines_grouped_by_picking sums and subtracts the stock move quantity returned by _get_signed_quantity_done (expressed in the move's UoM, i.e. the product's stock UoM) against line.quantity / remaining_qty (expressed in the invoice line UoM), without converting between the two:

remaining_qty = line.quantity            # invoice line UoM (e.g. 2 packs)
for move in line.move_line_ids:
    qty = self._get_signed_quantity_done(line, move, sign)  # move.quantity in stock UoM (e.g. 12 units)
    picking_dict[key] += qty             # printed in stock UoM
    remaining_qty -= qty                 # 2 - 12 = -10
...
if remaining_qty:                        # -10 is truthy
    lines_dict[line] = remaining_qty     # phantom remainder line

When the invoice line UoM differs from the product's stock UoM (e.g. selling in packs/pallets while stock is kept in units), two things go wrong:

  1. The per-picking quantity is printed in the stock UoM instead of the invoice line UoM.
  2. A bogus remainder line with a negative quantity is produced, because a stock-UoM quantity is subtracted from an invoice-line-UoM quantity.

It goes unnoticed in the common case where both UoMs are equal.

Fix

_get_signed_quantity_done now converts the move quantity to the invoice line UoM before it is summed/subtracted. A regression test (test_account_invoice_group_picking_uom_conversion) covers a product sold per pack of 6 while delivered in units: exactly one group, expressed in packs, with no phantom remainder line.

Test

account_invoice_report_grouped_by_picking test suite: 6/6 green.

…to invoice line UoM

lines_grouped_by_picking summed and subtracted the stock move quantity (in the
move's UoM) against the invoice line quantity (in the invoice line UoM) without
converting. When the invoice line UoM differs from the product's stock UoM
(e.g. selling in packs/pallets while stock is in units), the per-picking
quantity was printed in the stock UoM and a bogus negative remainder line was
produced. _get_signed_quantity_done now converts the move quantity to the
invoice line UoM. Adds a regression test.
@OCA-git-bot OCA-git-bot added series:19.0 mod:account_invoice_report_grouped_by_picking Module account_invoice_report_grouped_by_picking labels Jun 24, 2026
@pedrobaeza pedrobaeza changed the title [FIX] account_invoice_report_grouped_by_picking: convert grouped qty to invoice line UoM [19.0][FIX] account_invoice_report_grouped_by_picking: convert grouped qty to invoice line UoM Jun 24, 2026
"name": "Account Invoice Grouped by Picking",
"summary": "Print invoice lines grouped by picking",
"version": "19.0.1.0.0",
"version": "19.0.1.0.1",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't change manually the module version. It's done on merge.

@BhaveshHeliconia BhaveshHeliconia left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@pedrobaeza pedrobaeza added this to the 19.0 milestone Jun 25, 2026
@pedrobaeza

Copy link
Copy Markdown
Member

As no conflict has arisen with the module version change, let's merge with nobump:

/ocabot merge nobump

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hey, thanks for contributing! Proceeding to merge this for you.
Prepared branch 19.0-ocabot-merge-pr-424-by-pedrobaeza-bump-nobump, awaiting test results.

@OCA-git-bot
OCA-git-bot merged commit 3093591 into OCA:19.0 Jun 25, 2026
5 of 7 checks passed
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Congratulations, your PR was merged at 6699a21. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants