| Availability |
Odoo Online
Odoo.sh
On Premise
|
| Odoo Apps Dependencies |
•
Invoicing (account)
• Discuss (mail) • Inventory (stock) • Accounting (accountant) |
| Community Apps Dependencies | Show |
| Lines of code | 4872 |
| Technical Name |
l10n_ro_declaration_D406 |
| License | OPL-1 |
| Website | https://www.nexterp.ro |
| Versions | 18.0 19.0 |
| Availability |
Odoo Online
Odoo.sh
On Premise
|
| Odoo Apps Dependencies |
•
Invoicing (account)
• Discuss (mail) • Inventory (stock) • Accounting (accountant) |
| Community Apps Dependencies | Show |
| Lines of code | 4872 |
| Technical Name |
l10n_ro_declaration_D406 |
| License | OPL-1 |
| Website | https://www.nexterp.ro |
| Versions | 18.0 19.0 |
Romania - D406 ANAF Declaration
Romania - D406 ANAF Declaration
Overview
This module generates the D406 declaration (Standard Audit File for Tax, SAF-T) for Romanian ANAF. SAF-T is the OECD-standard XML export of the taxpayer's accounting, master data and operational records that Romanian companies must submit to ANAF — monthly for large and medium-size taxpayers, quarterly for small taxpayers, and on demand for non-resident entities registered for VAT in Romania.
A single D406 file contains the chart of accounts, the customer and
supplier master data, the products and stock items, all journal entries
posted in the period, every invoice and payment with full detail, the
fixed-assets register (annual file) and the inventory balance (annual
file). The Romanian SAF-T schema is Ro_SAFT_Schema_v249_2025.xsd —
namespace mfp:anaf:dgti:d406:declaratie:v1.
The wizard reads the Odoo general-ledger report for the selected period,
renders the QWeb template l10n_ro_declaration_D406.saft_template with
all required sections, post-processes the output to add the nsSAFT:
namespace prefix and the xsi:schemaLocation attribute, then attaches the
resulting XML to the wizard for download. Three filing variants are
supported: Declaration (monthly / quarterly transactional file),
Stocks (annual inventory) and Assets (annual fixed-assets file).
Built & supported by NextERP Romania
Romanian Odoo specialists, here for the long run — from implementation to localization and day-to-day production support.
What we do
Odoo Solutions
From quick-start rollouts to multi-company deployments and custom modules built for your processes.
Romanian Localization
SAF-T (D406), e-Factura, e-Transport, D300 / D390 / D394, ANAF integration, full chart of accounts and fiscal positions.
Our Services
Implementation, customization, migration, integration, support and consultancy — Romanian-speaking, SLA-backed.
Features
- SAF-T (Standard Audit File for Tax) — wizard
l10n.ro.anaf.d406generates<nsSAFT:AuditFile>under namespacemfp:anaf:dgti:d406:declaratie:v1, validated againstRo_SAFT_Schema_v249_2025.xsd. - Three filing variants — toggle
include_stocks/include_assetson the wizard to switch between (1) the monthly / quarterly transactional declaration, (2) the annual stock report and (3) the annual fixed-assets report. The selected variant drives thel10n_ro_saft_required_sectionsoption used by the underlyingl10n_ro_saftengine. - Rectificative filings — the
rectificativeflag sets thel10n_ro_rectificativeoption, marking the file as a corrective submission. - Partner SAF-T codes precomputed —
res.partner.l10n_ro_saft_codeis a stored compute that builds the 2-digit ANAF code (00Romanian company with valid CUI,03Romanian taxpayer without CUI,04unidentified RO,01EU with VIES-valid VAT,02other foreign with VAT,05/06EU/foreign without VAT,08unknown) followed by the resolved VAT identifier. A SQL-only pre-init hook seeds the field on install to avoid hour-long computes on large partner bases. - Manual SAF-T code refresh — the Recompute Ro SAFT Code server action (added to the partner list) re-runs the Python compute for picked partners.
- Tax entity classification —
res.company.l10n_ro_tax_entity(Company / Division / Branch) drives the SAF-THeaderblock; configured under Settings → Accounting → Romanian Localization. - General-ledger driven —
build_file()callsaccount.general.ledger.report.handlerwith a custom-range option; the QWeb template emits all SAF-T tables (Header, MasterFiles, GeneralLedgerEntries, SourceDocuments, optional Assets / Inventory). - Streaming-friendly XML rewriting — to support files up to hundreds of megabytes the wizard rewrites the namespace prefix with a single regex pass over the rendered string instead of reparsing with lxml (which previously took 100+ seconds on a 47 MB output and scaled poorly).
- Error surfacing — actionable errors from the SAF-T engine are
shown via the
account.report.file.download.error.wizardso the accountant can fix the source data before resubmitting. - Bank account override — the
saft_report.xmlpatches the standardl10n_ro_saftcompany header template so every IBAN / account number is emitted, addressing ANAF's requirement that the full list of company bank accounts be reported.
Configuration
1. Prerequisites
Complete the setup described in the l10n_ro_declaration and l10n_ro_saft base modules shipped with this one:
- Romanian VAT/CUI on the company.
- The CAEN code on the company record.
- The chart of accounts must be the OMF 1802/2014 PCG RO
(
l10n_ro_account_enterprise). - All bank accounts of the company configured under Accounting → Configuration → Bank Accounts.
- The fiscal-position mappings and the standard VAT tax tags configured.
2. Tax entity
Set the company's SAF-T tax entity at Settings → Accounting → Romanian Localization → Romania - Company tax entity:
| Value | When to use |
|---|---|
| Company | Default — independent Romanian legal entity |
| Division | A division reported separately under a parent |
| Branch reference | A branch reporting under the parent's CUI |
This drives the SAF-T Header.TaxAccountingBasis block.
3. Partner SAF-T codes
The 2-digit SAF-T partner code is computed automatically from country,
VAT number, VIES validity and is_company. On module installation a
SQL pre-init hook (hooks.py) seeds l10n_ro_saft_code on every
partner so the first install completes in seconds even on databases
with hundreds of thousands of partners.
To refresh codes manually after data corrections:
- Select the partners in the Contacts list.
- Use the Action → Recompute Ro SAFT Code server action.
| Code | Meaning |
|---|---|
00 |
Romanian company with valid CUI |
01 |
EU company with VIES-valid VAT |
02 |
Non-EU foreign with VAT |
03 |
Romanian taxpayer without CUI |
04 |
Unidentified Romanian |
05 |
EU without VIES-valid VAT |
06 |
Non-EU foreign without VAT |
08 |
Unknown country |
4. SAF-T sections expected for your file
The wizard supports three variants:
- Declaration (monthly / quarterly) — chart of accounts, partner master data, products, journal entries, invoices, payments.
- Stocks (annual) — inventory balance per warehouse and location.
- Assets (annual) — fixed-assets register with depreciation schedules.
Make sure the corresponding Odoo records (stock valuations, fixed assets) are complete for the period if you intend to file Stocks or Assets.
5. Wizard location
Open the wizard at Accounting → Reports → Romania → D406 Declaration.
After configuration, generate the declaration as described in USAGE.md.
How it works
Open Accounting → Reports → Romania → D406 Declaration.

Steps
-
Header fields
- Declaration / Version — defaults to
D406 / Versiunea 1. - Date From / Date To — set the period:
- one calendar month for monthly filers,
- one quarter for quarterly filers,
- the full fiscal year for the annual Stocks / Assets files.
- Signature — pick the ANAF signature configured for the declarant.
- Bank Account — the company bank account printed in the file.
- Declaration / Version — defaults to
-
Variant flags
- Rectificative — tick to mark the file as a corrective submission
(sets
l10n_ro_rectificativeon the SAF-T options). - Include Stocks — tick to generate the annual stocks file. The wizard then emits only the inventory sections.
- Include Assets — tick to generate the annual fixed-assets file. The wizard emits only the assets sections.
Leave both off to produce the regular monthly / quarterly transactional declaration.
- Rectificative — tick to mark the file as a corrective submission
(sets
-
Get Report — builds the XML. Internally the wizard:
- Opens the general-ledger report with a custom date range covering the wizard period.
- Computes the SAF-T required-sections list based on the variant
flags (
monthly/stocks/assets). - Calls
_l10n_ro_saft_prepare_report_values()and renders thel10n_ro_declaration_D406.saft_templateQWeb template with the prepared values. - Post-processes the rendered string with a regex pass that prepends
the
nsSAFT:prefix to every element tag and rewrites the root<AuditFile>to addxmlns:nsSAFT,xmlns:xsiandxsi:schemaLocationpointing atRo_SAFT_Schema_v249_2025.xsd. - Prepends the
<?xml version="1.0" encoding="UTF-8"?>declaration and attaches the file to the wizard for download.
-
Handling errors — if the SAF-T engine reports actionable errors (missing partner data, unbalanced moves, undistributed earnings, …) the wizard opens the standard
account.report.file.download.error.wizardlisting them next to the partial file. Fix the underlying records and regenerate. -
Validate with DUKIntegrator — D406 is large (hundreds of MB on year-end Assets files); run the validator with sufficient memory.
-
Sign with the digital signature (Sectigo / certSIGN / other token).
-
Upload to ANAF at the Depunere declarații portal under D406.
Generated XML — main sections
The output is a single <nsSAFT:AuditFile> containing:
- Header — taxpayer identification, software identification, tax accounting basis, currency, period start/end, declaration variant (monthly / quarterly / annual / corrective).
- MasterFiles — chart of accounts (with PCG RO codes), customers
and suppliers (each carrying
l10n_ro_saft_code), tax table, UoM table, products, owners, analysis types — depending on variant. - GeneralLedgerEntries — every journal entry posted in the period (monthly / quarterly variant only).
- SourceDocuments — sales invoices, purchase invoices, payments, movement of goods (monthly / quarterly variant only).
- Assets — fixed-assets register with acquisitions, disposals, depreciation by period (annual Assets variant only).
- Inventory — stock balance by warehouse, location, product (annual Stocks variant only).
File-size notes
Real D406 files range from a few MB for small taxpayers up to several
hundred MB for medium-sized companies and several GB for large ones.
The XML post-processing uses a regex over the rendered string instead
of lxml.etree.fromstring to keep memory and time linear in the
output size.
Versions
19.0.2.1.16 (2026-05-24)
- Changelog tracking starts at this release.
Discover the NextERP suite
Other modules from the same publisher, built to work together.
NextERP Romania
Odoo implementation, customization, Romanian localization and long-term support since 2018.
Odoo Proprietary License v1.0 This software and associated files (the "Software") may only be used (executed, modified, executed after modifications) if you have purchased a valid license from the authors, typically via Odoo Apps, or if you have received a written agreement from the authors of the Software (see the COPYRIGHT file). You may develop Odoo modules that use the Software as a library (typically by depending on it, importing it and using its resources), but without copying any source code or material from the Software. You may distribute those modules under the license of your choice, provided that this license is compatible with the terms of the Odoo Proprietary License (For example: LGPL, MIT, or proprietary licenses similar to this one). It is forbidden to publish, distribute, sublicense, or sell copies of the Software or modified copies of the Software. The above copyright notice and this permission notice must be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Please log in to comment on this module