Skip to content

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

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

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

Conversation

@mav-adhoc

Copy link
Copy Markdown
Contributor

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 19.0: 0 failed, 0 errors of 8 tests; without the fix it fails with 'no' != 'invoiced'.

Same task as #360, different module and defect. Port of #361 to 19.0.

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

@roboadhoc

Copy link
Copy Markdown
Contributor

Pull request status dashboard

@les-adhoc

Copy link
Copy Markdown
Contributor

@roboadhoc r+ nobump

roboadhoc pushed a commit that referenced this pull request Sep 2, 2026
_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.

closes #362

Signed-off-by: Luciano Esperlazza <les@adhoc.inc>
roboadhoc pushed a commit that referenced this pull request Sep 2, 2026
_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.

closes #362

Signed-off-by: Luciano Esperlazza <les@adhoc.inc>
_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.
@les-adhoc

Copy link
Copy Markdown
Contributor

@roboadhoc r+

roboadhoc pushed a commit that referenced this pull request Sep 2, 2026
_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.

closes #362

Signed-off-by: Luciano Esperlazza <les@adhoc.inc>
@roboadhoc roboadhoc closed this in b6d5381 Sep 2, 2026
@roboadhoc
roboadhoc deleted the 19.0-t-72358-mav-1 branch September 2, 2026 16:44
@roboadhoc roboadhoc added the 18.1 label Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants