Skip to content

Fork Sync Branch 18.0 - #15

Merged
btl-bot merged 2 commits into
BTLzdravtech:18.0from
ingadhoc:18.0
Sep 3, 2026
Merged

btl-bot merged 2 commits into
BTLzdravtech:18.0from
ingadhoc:18.0

Conversation

@btl-bot

@btl-bot btl-bot commented Sep 3, 2026

Copy link
Copy Markdown

No description provided.

_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 #361

Signed-off-by: Luciano Esperlazza <les@adhoc.inc>
Two cases were still wrong in the lines offered by the 'Match purchase
lines' button:

* Over receipt: when the vendor delivers more than ordered, the line
  ends up fully ordered but not fully billed (ordered 40, received 41,
  billed 40). The bill criterion product_qty > qty_invoiced gives False
  and the quantity left to bill was hidden. Add qty_to_invoice > 0 as a
  second term, the same criterion the native view uses. The first term
  is still needed for a confirmed purchase order with no receipt yet,
  where qty_to_invoice is 0 on products controlled on received
  quantities.

* Forced invoice status: a purchase order set as 'No Bill to Receive' /
  'Nothing to Bill' kept offering its lines, because neither the filter
  nor the native view look at force_invoiced_status. Exclude them, on
  bills and on credit notes: the user already declared that order as
  nothing left to bill.

Add tests for the bill criterion (no receipt, partial receipt, over
receipt, fully billed, forced status) and for the credit note one
(pending refund from a return, return already credited).

* Orders closed with the 'Set Invoiced' button: the button stamped
  invoice_status on the order and zeroed qty_to_invoice on the lines, both
  stored computed fields, so the next recompute undid it and neither the
  matcher nor the lines ever saw the order as closed for billing. Write
  force_invoiced_status instead, which is what everything else reads.

closes #359

Signed-off-by: Luciano Esperlazza <les@adhoc.inc>

@sireko sireko 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.

Auto approved

@btl-bot
btl-bot merged commit c209a13 into BTLzdravtech:18.0 Sep 3, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants