Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 14.0 #863 +/- ##
==========================================
- Coverage 50.56% 50.53% -0.03%
==========================================
Files 979 979
Lines 16678 16685 +7
Branches 3555 3558 +3
==========================================
- Hits 8433 8432 -1
- Misses 8029 8034 +5
- Partials 216 219 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
6d7c9eb to
5e38952
Compare
…date Override _get_accounting_date instead of adding a separate onchange handler. For purchase documents, route through super's sale document branch (via a scoped context flag on is_sale_document) which applies the tax lock date check and returns invoice_date directly, without the max(invoice_date, today) logic that prevents proper currency recomputation. This lets the core _onchange_invoice_date detect the date change and call _onchange_currency, which recomputes all line debit/credit at the correct exchange rate. The previous _onchange_invoice_date_accounting set date = invoice_date without triggering line recomputations, causing base and tax lines to use different exchange rates on multi-currency invoices.
…e_invoice_date Override _onchange_invoice_date via super instead of adding a separate onchange handler. This guarantees execution order: core runs first (setting the correct date and recomputing currency), then prorate recomputes taxes if needed. The previous separate onchange had no guaranteed execution order relative to the core handler. Also add a guard to only run the full tax recomputation when the invoice has taxes with prorate=True. Previously this ran unconditionally on every invoice.
5e38952 to
93f60bf
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
_get_accounting_dateto returninvoice_datefor purchase documents (same as core does for sales), using a scoped context flag to reuse super's tax lock date logic without code duplication_onchange_invoice_datein the prorate module viasuper()(guaranteed execution order) and add guard to only recompute taxes when prorate taxes existRoot cause
When a user set
invoice_dateon a multi-currency vendor bill:_onchange_invoice_datecalled_get_accounting_date(invoice_date)which returnedmax(invoice_date, today)for purchase documents — same as currentdate— so_onchange_currency()was NOT called (else branch taken)_onchange_invoice_date_accounting) setdate = invoice_datebut didn't recompute line amounts_recompute_dynamic_lines(recompute_all_taxes=True)which recomputed ONLY tax lines at the newdate(invoice_date rate)Result: base lines stayed at the creation rate, tax lines moved to the invoice_date rate. This rate mismatch caused SII error 1242 on intra-community USD invoices (reported on invoice 2026/00934).
Fix approach
Base module: override
_get_accounting_dateso it returnsinvoice_date(after tax lock date check) for purchase documents — the same behavior core already has for sale documents. This makes the core's_onchange_invoice_datedetect the date change and call_onchange_currency(), which recomputes ALL linedebit/creditat the correct exchange rate. To avoid duplicating the tax lock date logic from super, we use a scoped context flag that makesis_sale_document()return True during this specific super call only, routing through the sale branch.Prorate module: override
_onchange_invoice_dateviasuper()instead of having a separate onchange handler (which had no guaranteed execution order). Add guard to only call_recompute_dynamic_lines(recompute_all_taxes=True)when the invoice has taxes withprorate=True— this was the direct cause of the rate mismatch on non-prorate invoices.Test plan
invoice_date= todayinvoice_dateto a past date with a different exchange rate_get_accounting_datelogic)invoice_datebeforetax_lock_dateon an invoice with taxes → accounting date should betax_lock_date + 1invoice_date→ prorate percentage should recalculate for the new dateinvoice_date→ no unnecessary full tax recomputation