[FIX] base_vat: compute vies_valid on create() without a write() - #286201
Closed
kukor-odoo wants to merge 1 commit into
Closed
[FIX] base_vat: compute vies_valid on create() without a write()#286201kukor-odoo wants to merge 1 commit into
kukor-odoo wants to merge 1 commit into
Conversation
Contributor
Steps to Reproduce: 1. Install Belgium L10n and go to Settings > Accounting/Invoicing and enable Verify VAT Numbers (vat_check_vies). 2. Go to Accounting > Configuration > Fiscal Positions and confirm (or create) an Intra-Community fiscal position with: - Detect Automatically (auto_apply) = enabled - VAT Required (vat_required) = enabled - Country Group = EU (no specific country set) 3. Open an incognito/private browser window (must be a guest, unauthenticated session - do not log in). 4. Go to the website's /shop page and add any product to the cart. 5. Proceed to checkout until you reach the Address step (/shop/address). 6. Enter a delivery address in an EU country different from the company's own country (e.g. company based in Belgium, delivery address in Netherlands). 7. In the VAT Number field, enter a real, valid, VIES-registered EU VAT number matching that same country (e.g. an NL... VAT number for a Netherlands address). 8. Click Save Address / Continue and proceed through to the payment step (/shop/payment). 9. Check the tax shown on the delivery line and order total. Issue: The delivery product and order total are taxed at the standard/ domestic rate instead of the expected 0% intra-community rate, even though a genuinely valid EU VAT number was provided. Root Cause: base_vat's res.partner.create() unconditionally removes vies_valid from the ORM's pending-computation queue (env.remove_to_compute), assuming a subsequent write() call will trigger the actual VIES check. That assumption holds for backend form saves (which perform create() then write()), but website_sale's guest checkout flow (_create_new_address) only performs a single create() call with no follow-up write(). As a result, vies_valid remains permanently unset (NULL) for guest-created partners with a VAT number. Downstream, account.fiscal.position._get_vat_required_valid() reads this blank value as falsy, so the Intra-Community fiscal position's vat_required condition fails and the position is rejected in favor of a lower-priority one (e.g. EU B2C or Domestic). Solution: After partner creation, if the partner has a VAT number and the creation is not part of a file import (import_file context), explicitly trigger _compute_vies_valid() to perform the VIES check immediately, rather than relying on a write() that guest checkout never issues. Result: Guest checkout customers providing a valid, verifiable EU VAT number now correctly get vies_valid computed at creation time, allowing the Intra-Community fiscal position to match as intended and 0% VAT to apply. opw-6522992
kukor-odoo
force-pushed
the
18.0-bas_vat-vies-guest-checkout-fix-kukor
branch
from
September 2, 2026 13:01
71bc9d6 to
04d8fc8
Compare
kukor-odoo
marked this pull request as ready for review
September 4, 2026 05:33
C3POdoo
requested review from
a team and
FlorianGilbert
and removed request for
a team
September 4, 2026 05:35
robodoo
pushed a commit
that referenced
this pull request
Sep 4, 2026
Steps to Reproduce: 1. Install Belgium L10n and go to Settings > Accounting/Invoicing and enable Verify VAT Numbers (vat_check_vies). 2. Go to Accounting > Configuration > Fiscal Positions and confirm (or create) an Intra-Community fiscal position with: - Detect Automatically (auto_apply) = enabled - VAT Required (vat_required) = enabled - Country Group = EU (no specific country set) 3. Open an incognito/private browser window (must be a guest, unauthenticated session - do not log in). 4. Go to the website's /shop page and add any product to the cart. 5. Proceed to checkout until you reach the Address step (/shop/address). 6. Enter a delivery address in an EU country different from the company's own country (e.g. company based in Belgium, delivery address in Netherlands). 7. In the VAT Number field, enter a real, valid, VIES-registered EU VAT number matching that same country (e.g. an NL... VAT number for a Netherlands address). 8. Click Save Address / Continue and proceed through to the payment step (/shop/payment). 9. Check the tax shown on the delivery line and order total. Issue: The delivery product and order total are taxed at the standard/ domestic rate instead of the expected 0% intra-community rate, even though a genuinely valid EU VAT number was provided. Root Cause: base_vat's res.partner.create() unconditionally removes vies_valid from the ORM's pending-computation queue (env.remove_to_compute), assuming a subsequent write() call will trigger the actual VIES check. That assumption holds for backend form saves (which perform create() then write()), but website_sale's guest checkout flow (_create_new_address) only performs a single create() call with no follow-up write(). As a result, vies_valid remains permanently unset (NULL) for guest-created partners with a VAT number. Downstream, account.fiscal.position._get_vat_required_valid() reads this blank value as falsy, so the Intra-Community fiscal position's vat_required condition fails and the position is rejected in favor of a lower-priority one (e.g. EU B2C or Domestic). Solution: After partner creation, if the partner has a VAT number and the creation is not part of a file import (import_file context), explicitly trigger _compute_vies_valid() to perform the VIES check immediately, rather than relying on a write() that guest checkout never issues. Result: Guest checkout customers providing a valid, verifiable EU VAT number now correctly get vies_valid computed at creation time, allowing the Intra-Community fiscal position to match as intended and 0% VAT to apply. opw-6522992 closes #286201 Signed-off-by: Florian Gilbert (flg) <flg@odoo.com>
This was referenced Sep 4, 2026
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.

Description
Steps to Reproduce
vat_check_vies).auto_apply): enabledvat_required): enabled/shoppage and add any product to the cart./shop/address)./shop/payment).Issue
The delivery product and the overall order are taxed at the standard/domestic VAT rate instead of the expected 0% intra-community rate — even though the customer provided a valid, VIES-registered EU VAT number matching the delivery country.
Root Cause
In
base_vat,res.partner.create()unconditionally removesvies_validfrom the ORM's pending computation queue viaenv.remove_to_compute(), relying on a subsequentwrite()to trigger the actual VIES check. This holds for the standard backend flow, where creation is followed by awrite()— but the website guest checkout flow differs:website_salecreates the guest partner through_create_new_address().create()call, with no follow-upwrite()._compute_vies_valid()is therefore never triggered.vies_validremains permanently unset (NULL), despite a VAT number being provided.Downstream,
account.fiscal.position._get_vat_required_valid()reads this unset value as falsy, so the Intra-Community fiscal position'svat_requiredcondition fails and is rejected in favor of another applicable position (e.g. EU B2C or Domestic).Solution
After partner creation, explicitly trigger
_compute_vies_valid()when the partner has a VAT number and the operation is not part of a file import (import_filecontext) — performing the VIES check immediately instead of relying on awrite()that guest checkout never issues.Result
Guest customers providing a valid EU VAT number now get
vies_validcomputed immediately at creation. Fiscal position detection correctly identifies the Intra-Community position, and the expected 0% VAT treatment is applied to the delivery and order.OPW: 6522992