Skip to content

[FIX] purchase_stock_ux: keep the forced invoice status on PO lines - #368

Closed
fw-bot-adhoc wants to merge 1 commit into
ingadhoc:19.0from
adhoc-dev:19.0-18.0-t-72358-mav-1-7866-fw
Closed

[FIX] purchase_stock_ux: keep the forced invoice status on PO lines#368
fw-bot-adhoc wants to merge 1 commit into
ingadhoc:19.0from
adhoc-dev:19.0-18.0-t-72358-mav-1-7866-fw

Conversation

@fw-bot-adhoc

Copy link
Copy Markdown

purchase_stock_ux._compute_invoice_status() calls super() — which honours order_id.force_invoiced_status — and then recomputes every line without that guard, overwriting the result:

super()._compute_invoice_status()
for line in self:
    if not float_is_zero(line.qty_to_invoice, precision_digits=precision):
        line.invoice_status = "to invoice"   # <-- overwrites the forced status
    elif float_compare(line.qty_invoiced, (line.product_qty - line.qty_returned), ...) >= 0:
        line.invoice_status = "invoiced"
    else:
        line.invoice_status = "no"

So on an order manually set as fully invoiced, a line with something left to invoice ends up as to invoice and a line with nothing received as no. The order itself keeps the forced status, only its lines lose it, and recomputing the field does not help because the compute overwrites the value again — there is no data fix, it needs the guard.

Setting the invoice status by hand is the documented way to close an order for billing, so the feature of purchase_ux is unreliable at line level on any database with this module installed: the lines keep showing as pending wherever they are filtered by invoice_status. On one customer database this accounts for 2,756 lines that read to invoice on orders that were forced months ago. The code is the same on 16.0, 18.0 and 19.0, so this is not a recent regression.

Test plan

test_forced_invoiced_status_on_lines in purchase_stock_ux/tests/test_purchase_order.py: a confirmed order forced as invoiced keeps invoiced on its lines. Verified locally on 18.0: 0 failed, 0 errors of 3 tests; without the fix it fails with 'no' != 'invoiced'.

Same task as #359, different module and defect.

https://www.adhoc.inc/odoo/project.task/72358

Forward-Port-Of: #361

_compute_invoice_status() calls super(), which honours
order_id.force_invoiced_status, and then recomputes every line without
that guard, overwriting it: a line with something left to invoice always
ends up as 'to invoice' and one with nothing received as 'no', even when
the order was manually set as fully invoiced. Skip the lines of a forced
order and keep what super() resolved.

Setting the status on an order is the documented way to close it for
billing, so this makes the whole feature unreliable on any database with
this module installed: the lines keep showing up as pending everywhere
they are filtered by invoice_status. Recomputing the field does not help,
the compute overwrites the value again.

X-original-commit: c12cfa8
@roboadhoc

Copy link
Copy Markdown
Contributor

Pull request status dashboard

@fw-bot-adhoc

Copy link
Copy Markdown
Author

@mav-adhoc @les-adhoc cherrypicking of pull request #361 failed.

stdout:

Auto-merging purchase_stock_ux/models/purchase_order_line.py
Auto-merging purchase_stock_ux/tests/test_purchase_order.py
CONFLICT (content): Merge conflict in purchase_stock_ux/tests/test_purchase_order.py

Either perform the forward-port manually (and push to this branch, proceeding as usual) or close this PR (maybe?).

:shipit: you can use git-fw to re-do the forward-port for you locally.

⚠️ after resolving this conflict, you will need to merge it via @roboadhoc.

More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port

@mav-adhoc

Copy link
Copy Markdown
Contributor

Superseded by #362, the port of #361 to 19.0 that was written by hand before this automatic forward-port existed. The conflict is in purchase_stock_ux/tests/test_purchase_order.py, whose 19.0 version the manual port already adapted.

Closing so the fix does not land twice. #362 carries it with its test.

@mav-adhoc mav-adhoc closed this Sep 2, 2026
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.

3 participants