[FIX] purchase_stock_ux: exclude fully-returned lines from vendor bill#339
Open
mav-adhoc wants to merge 4 commits into
Open
[FIX] purchase_stock_ux: exclude fully-returned lines from vendor bill#339mav-adhoc wants to merge 4 commits into
mav-adhoc wants to merge 4 commits into
Conversation
Contributor
Odoo 19 removed _get_invoiceable_lines and now feeds all order_line into action_create_invoice unconditionally. Our _compute_qty_invoiced subtracts qty_returned from qty_to_invoice, so lines where the full quantity was returned end up as invoice lines with quantity 0, requiring manual deletion. Override action_create_invoice in purchase_stock_ux to skip lines where float_is_zero(qty_to_invoice) and that are neither sections nor downpayments. Sections are preserved for subsequent invoiceable lines in the same block.
…ve.line uses 'product')
In Odoo 19 account.move.line, regular product lines have display_type='product' (truthy string), not False. The partial return test was using the old 'not l.display_type' filter which matched zero lines. Align with the first test's correct filter.
71c3798 to
b4df3bd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
When creating a vendor bill from a PO that has lines with
qty_to_invoice = 0(fully returned with
to_refund=True), the draft invoice included those lineswith quantity 0. The user had to delete them manually.
Root cause: Odoo 19 removed the old
_get_invoiceable_linesfilter fromaction_create_invoiceand now iterates allorder_lineunconditionally.purchase_stock_uxoverrides_compute_qty_invoicedto subtractqty_returnedfrom
qty_to_invoice, so fully-returned lines produceqty_to_invoice = 0andstill end up as invoice lines with that quantity.
Fix: Override
action_create_invoiceinpurchase_stock_uxto skip lineswhere
float_is_zero(qty_to_invoice)and that are not sections/notes ordownpayments. Section headers are preserved: they are only added when a
subsequent invoiceable line consumes them, so empty sections are also dropped.
Test plan
Two new tests in
purchase_stock_ux/tests/test_purchase_order.py:test_invoice_excludes_fully_returned_lines: PO with 2 lines (L0 invoiceable,L1 fully returned) → invoice must contain only L0 with no zero-qty lines.
test_invoice_partial_return_no_regression: single line, partial return (4/10)→ invoice with 1 line at quantity 6 (no regression).
Covers acceptance criteria:
purchase_methodpolicies produceqty_to_invoice = 0for fully-returnedlines, so the filter works for both "Ordered quantities" and "Received quantities"
Internal task: https://www.adhoc.inc/odoo/knowledge/180/project.task/69417