Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Property Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
      • Get a Tailored Demo
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +32 2 290 34 90
    • Get a Tailored Demo
  • Pricing
  • Help
  1. APPS
  2. Localizations
  3. KSeF 2.0 — National e-Invoice System Integration (Poland) v 19.0
  4. Sales Conditions FAQ

KSeF 2.0 — National e-Invoice System Integration (Poland)

by Aura Odoo Tech http://auraodoo.tech/
Odoo
v 19.0 Third Party 11
Download for v 19.0 Deploy on Odoo.sh
Apps purchases are linked to your Odoo account, please sign in or sign up first.
Availability
Odoo Online
Odoo.sh
On Premise
Odoo Apps Dependencies • Invoicing (account)
• Discuss (mail)
Lines of code 1401
Technical Name ksef_integration
LicenseOPL-1
Websitehttp://auraodoo.tech/
You bought this module and need support? Click here!
Availability
Odoo Online
Odoo.sh
On Premise
Odoo Apps Dependencies • Invoicing (account)
• Discuss (mail)
Lines of code 1401
Technical Name ksef_integration
LicenseOPL-1
Websitehttp://auraodoo.tech/
  • Description
  • License

🇵🇱 KSeF 2.0 Integration

Full integration with the Polish Krajowy System e-Faktur (KSeF 2.0) — National e-Invoice System operated by the Ministry of Finance.

Odoo 19.0 Version 19.0.2.0.0 OPL-1 License Accounting / Localizations Poland

Overview

This module seamlessly connects Odoo 19 with the Polish Government's KSeF 2.0 REST API. It lets you send, receive, and track e-invoices (FA-XML) directly from the Odoo accounting interface — both individually in real time and in bulk asynchronous batches.

📋 Note on FA-XML Generation The built-in XML builder produces a functional placeholder. For fully schema-compliant FA(2)/FA(3) output required in production, integrate the Aura Odoo Tech Invoice paid module and replace AccountMove._build_fa_xml() with the Aura Odoo Tech renderer.

Module Architecture & Data Flow

Odoo Invoice
(account.move)
➡
Wizard / Auto
Send / Batch
➡
KSeF Client
(services/ksef_client.py)
➡
KSeF API
mf.gov.pl
KSeF API
Response / KSeF ID
➡
ksef.invoice.log
Audit Trail
➡
account.move
Status & KSeF Ref#

The module is layered into four clear tiers:

Tier Files Responsibility
Models models/ ORM fields, computed values, business logic on invoices
Services services/ksef_client.py Low-level HTTP wrapper for the KSeF REST API (no Odoo ORM)
Wizards wizard/ Interactive UI dialogs for send / batch-send
Controllers controllers/main.py Inbound webhook endpoint (POST /ksef/webhook)

Key Features

🔑 Token Authentication

  • Challenge → SHA-256 hash → SessionToken flow
  • Supports Production, Demo, and Test environments
  • Automatic session creation & termination
  • Session tracked in ksef.session model

📤 Interactive Sending

  • Send one invoice at a time from the form view
  • Real-time status polling after submission
  • KSeF Reference Number written back automatically
  • FA-XML attached to invoice as a file

📦 Batch Sending

  • Multi-select invoices → pack into ZIP → upload
  • Asynchronous processing by KSeF
  • Batch ID logged per invoice
  • Poll batch status on demand

📋 Invoice Types

  • FA – Regular VAT invoices
  • FAK – Corrective invoices (credit notes)
  • FZA – Advance payment invoices
  • FRZ – Settlement (final) invoices

💱 Currency Support

  • PLN invoices — native direct submission
  • Foreign currencies (EUR, USD, …) supported
  • Exchange rate passed via KodWaluty FA-XML field

📊 Audit Trail

  • Every API interaction logged in ksef.invoice.log
  • Log visible on stat-button of each invoice
  • Stores raw JSON response & sent XML
  • Accessible from Accounting → KSeF → Log

⚙️ Auto-Send on Confirm

  • Optional automatic send when invoice is posted
  • Toggle in Accounting → Configuration → KSeF
  • Skips already accepted invoices automatically

🔗 Webhook Support

  • Inbound POST /ksef/webhook endpoint
  • Handles push notifications from KSeF middleware
  • Updates invoice status automatically on receipt

Models (Database Objects)

account.move — Invoice Extension

The core Odoo invoice model is extended with the following KSeF fields:

Field Type Description
ksef_state Selection Current KSeF status of the invoice (see status pills below)
ksef_reference_number Char Official KSeF ID assigned after acceptance
ksef_element_reference Char Temporary reference used for status polling
ksef_sent_at Datetime Timestamp when invoice was sent to KSeF
ksef_accepted_at Datetime Timestamp when KSeF confirmed acceptance
ksef_environment Selection Environment used during sending (test/demo/prod)
ksef_fa_type Selection FA invoice type (FA / FAK / FZA / FRZ) — auto computed
ksef_log_ids One2many Linked audit log entries

Invoice Status Values:

not_sent – Not Sent pending – Pending / Processing accepted – Accepted by KSeF rejected – Rejected error – Error received – Received from KSeF

ksef.invoice.log — Audit Log

Records every interaction between Odoo and KSeF per invoice.

Field Description
invoice_id Linked invoice (cascade delete)
operation send / batch_send / status_poll / download / receive
invoice_type FA type at time of operation
element_reference_number Temporary reference for polling
ksef_reference_number Official KSeF ID
batch_id Batch identifier if part of a batch send
state pending / processing / accepted / rejected / error / received

ksef.session — Session Tracker

Tracks each authenticated KSeF API session for audit and management.

Field Description
nip Polish Tax Identification Number (10 digits)
environment test / demo / prod
session_token Active session token from KSeF
state active / terminated / expired / error
terminated_at Session close timestamp

res.config.settings — Configuration Panel

Settings stored as system parameters (ir.config_parameter):

Parameter Key Default
KSeF Environment ksef.environment test
Taxpayer NIP ksef.nip —
API Token ksef.api_token —
Auto-send on Confirm ksef.auto_send false
Store KSeF XML ksef.store_xml true
API Timeout (sec) ksef.timeout 30

KSeF API Client (Services Layer)

services/ksef_client.py is a pure Python HTTP wrapper — no Odoo ORM dependency — making it fully testable in isolation.

Covered API Endpoints

Authentication

  • POST /api/online/Session/AuthorisationChallenge
  • POST /api/online/Session/Authorisation
  • GET /api/online/Session/Terminate

Interactive Invoice

  • POST /api/online/Invoice/Send
  • GET /api/online/Invoice/Status/{ElementRef}
  • GET /api/online/Invoice/Get/{KsefRef}

Batch Sending

  • POST /api/batch/Init
  • PUT /api/batch/Upload/{BatchId}/{PartName}
  • POST /api/batch/Finish/{BatchId}
  • GET /api/batch/Status/{BatchId}

Inbox (Received Invoices)

  • GET /api/online/Invoice/GetForSeller
  • GET /api/online/Invoice/GetForBuyer

Authentication Flow (Challenge–Response)

# 1. Request challenge (timestamp token) from KSeF
challenge = client.authorisation_challenge(nip="1234567890")

# 2. Hash: SHA-256( base64(api_token) + challenge_timestamp )
# 3. Send hashed credentials → receive SessionToken
client.authorise(nip, api_token, challenge)

# 4. All subsequent calls carry the SessionToken header
status = client.invoice_status(element_reference)

# 5. Terminate session when done
client.terminate_session()

Sending Workflows

1 — Interactive (Single Invoice)

1
Open Invoice

Navigate to a posted customer invoice (out_invoice / out_refund).

2
Click "Send to KSeF"

The KSeF Send Wizard opens, pre-filled with the current invoice.

3
Review & Confirm

Check environment, polling option, and whether to re-send already accepted invoices. Click Send.

4
Authentication

The wizard calls _ksef_authenticate() using NIP + API Token from settings.

5
Build FA-XML

_build_fa_xml() generates the invoice XML. A base64-encoded copy is attached if Store KSeF XML is enabled.

6
Submit to KSeF

POST /api/online/Invoice/Send — returns an ElementReferenceNumber.

7
Poll Status

If Poll Status After Sending is on, the wizard waits for KSeF to process and retrieve the official KSeF Reference Number.

8
Write Back

KSeF Ref#, status, and timestamps are saved on the invoice. A log entry is created in ksef.invoice.log.

2 — Batch (Multiple Invoices)

1
Multi-Select Invoices

In the invoice list view, tick multiple posted invoices.

2
Open Batch Wizard

Action → Send to KSeF (Batch). Optionally rename the batch label.

3
Build ZIP Archive

Each invoice's FA-XML is written into a .zip in memory (zipfile.ZipFile).

4
Init Batch

POST /api/batch/Init — receives batchId.

5
Upload ZIP

PUT /api/batch/Upload/{batchId}/part1.zip — uploads the entire archive.

6
Finish Batch

POST /api/batch/Finish/{batchId} — KSeF begins async processing.

7
Poll Later

Batch ID is stored per invoice. Use Accounting → KSeF → Transmission Log to poll GET /api/batch/Status/{batchId} and update statuses.

3 — Auto-Send on Invoice Confirmation

💡 How it works When Auto-send on invoice confirmation is enabled in settings, the module overrides action_post(). Immediately after a invoice is confirmed (posted), it automatically calls the interactive send flow without any user intervention. Already accepted invoices are always skipped.

Installation & Setup

1
Copy Module

Place the ksef_integration/ folder into your Odoo addons path.

2
Restart Odoo

Restart the server so the new module is detected: sudo systemctl restart odoo

3
Install Module

Go to Apps → (search) KSeF Integration → click Install.

4
Configure

Navigate to Accounting → Configuration → Settings → KSeF 2.0 and enter:
• Environment (Test / Demo / Production)
• Taxpayer NIP (10 digits)
• API Token (from KSeF portal)

5
Test Connection

Click Test KSeF Connection — the module runs a full challenge → auth → terminate cycle. A success notification confirms everything is working.

Menu & UI Navigation

Path What You Can Do
Accounting → KSeF → Dashboard Overview of KSeF activity
Accounting → KSeF → Transmission Log Full audit log of all KSeF API calls
Accounting → KSeF → Sessions View and terminate active KSeF sessions
Accounting → Configuration → Settings → KSeF 2.0 Environment, NIP, token, auto-send toggle
Invoice Form → "Send to KSeF" button Interactive send wizard for one invoice
Invoice List → Action → "Send to KSeF (Batch)" Batch send wizard for selected invoices
Invoice Form → KSeF Log stat-button Audit log entries for that specific invoice

Dependencies

Module Purpose Required?
account Base Odoo invoicing framework ✅ Yes
account_edi EDI framework / FA-XML rendering hooks ✅ Yes
base_setup Settings panel integration ✅ Yes
Aura Odoo Tech Invoice (paid) Production-grade FA(2)/FA(3) XML generation ⚠️ Recommended
⚠️ Production FA-XML The built-in _build_fa_xml() generates a functional placeholder XML. For production use, the FA(2)/FA(3) schema-compliant generation requires the Aura Odoo Tech Invoice module. Replace the placeholder method with the Aura Odoo Tech renderer before going live.

KSeF Environments

Environment Base URL Use For
Production https://ksef.mf.gov.pl Live legal invoices
Demo https://ksef-demo.mf.gov.pl Demos without legal effect
Test https://ksef-test.mf.gov.pl Development & testing

Invoice Type (FA Type) Mapping

FA Type Odoo move_type Description
FA out_invoice / in_invoice Regular VAT invoice
FAK out_refund / in_refund or debit origin Corrective invoice (credit note)
FZA out_invoice flagged manually Advance payment invoice
FRZ out_invoice flagged manually Settlement (final) invoice against FZA
Auto-Computation ksef_fa_type is computed automatically from move_type and debit_origin_id. FZA and FRZ types must be manually selected on the invoice when applicable.

Webhook Endpoint

The module exposes an HTTP controller at POST /ksef/webhook for receiving push notifications from a KSeF middleware or integration platform. When a POST is received:

  • The payload is parsed for a KSeF Reference Number or batch status update.
  • The matching account.move record is located and its status updated.
  • A new ksef.invoice.log entry with operation receive is created.

External References

📄 Official KSeF Resources

  • KSeF Portal — podatki.gov.pl
  • FA(2)/FA(3) Schema Documentation
  • Production API: ksef.mf.gov.pl
  • Test API: ksef-test.mf.gov.pl

🔧 Aura Odoo Tech Integration

  • Aura Odoo Tech KSeF 2.0 module info
  • Required for certified FA-XML output
  • Replace _build_fa_xml() with Aura Odoo Tech renderer

Module File Structure

ksef_integration/
├── __manifest__.py      # Module metadata, dependencies, version
├── __init__.py
├── models/
│   ├── account_move.py     # Invoice extension: fields, send logic, XML builder
│   ├── ksef_config.py      # Settings (res.config.settings extension)
│   ├── ksef_invoice_log.py # Audit log model
│   └── ksef_session.py     # Session tracker model
├── services/
│   └── ksef_client.py      # Pure HTTP wrapper for KSeF REST API
├── wizard/
│   ├── ksef_send_wizard.py   # Interactive send dialog
│   └── ksef_batch_wizard.py  # Batch send dialog
├── controllers/
│   └── main.py             # Webhook controller POST /ksef/webhook
├── views/
│   ├── ksef_menu.xml             # Menu items under Accounting → KSeF
│   ├── ksef_config_views.xml     # Settings panel
│   ├── account_move_ksef_views.xml # Invoice form button & stat-button
│   ├── ksef_invoice_log_views.xml # Log list & form views
│   ├── ksef_send_wizard_views.xml # Interactive send wizard view
│   └── ksef_batch_wizard_views.xml # Batch wizard view
├── data/
│   └── ksef_data.xml       # Default data / server actions
├── security/
│   └── ir.model.access.csv # Access rights for all KSeF models
└── static/description/
    └── index.html          # This page

KSeF 2.0 Integration  |  Odoo 19.0  |  Version 19.0.2.0.0  |  OPL-1 License

KSeF API: ksef.mf.gov.pl  |  Docs: podatki.gov.pl/ksef  |  Aura Odoo Tech: auraodoo.tech

Contact & Follow
Email: odooaura@gmail.com  |  YouTube  |  LinkedIn  |  Teams

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

  • The author can leave a single reply to each comment.
  • This section is meant to ask simple questions or leave a rating. Every report of a problem experienced while using the module should be addressed to the author directly (refer to the following point).
  • If you want to start a discussion with the author, please use the developer contact information. They can usually be found in the description.
Please choose a rating from 1 to 5 for this module.
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with