[ADD] l10n_fr_einvoicing_directory_import: maintain directory lines v… - #31
Open
njeudy wants to merge 9 commits into
Open
[ADD] l10n_fr_einvoicing_directory_import: maintain directory lines v…#31njeudy wants to merge 9 commits into
njeudy wants to merge 9 commits into
Conversation
njeudy
force-pushed
the
18.0-add-directory-import
branch
3 times, most recently
from
July 27, 2026 08:13
aae9f9b to
ff844c3
Compare
…ia CSV When the AFNOR directory API is not activated, this module lets users export the SIREN list to deposit on the official directory (headerless, one SIREN per line) and import the returned CSV (Chorus Pro format) to create/update fr.directory.line records. One CSV row maps to one directory line, matched to its partner by SIREN and disambiguated by SIRET when several companies share a SIREN. The line type (siren/siret/routing_code/suffix) is derived from the electronic address structure. A wizard exposes both steps. Annuaire: https://facturation.chorus-pro.gouv.fr/annuaire/
njeudy
force-pushed
the
18.0-add-directory-import
branch
from
July 27, 2026 08:15
ff844c3 to
73df28b
Compare
…panies After an import, collect the partners whose directory lines were created or updated and expose a button on the wizard to open them in a list view.
Author
…-registered The native API sync fills partner-level directory fields; the CSV import now does the same (fr_directory_entity_type=private by default, siren/siret, last sync date) so the directory section and default line selector show up on the partner and BT-49 can resolve.
… active match After a directory return import, when a partner ends up with exactly one active directory line and no default routing line, set it as the default (BT-49 source). The field is a manual selector natively, so this saves a per-partner pick when the annuaire confirms a single billing address.
Member
|
Could you give an example of underlying scenario ? I understand that you are not using a regular PA with AFNOR-API (otherwise, you would not need this), but use an external tool to send invoice ? |
A real directory return holds one row per company (7000+ on a mid-sized database). The import did one search and one write per row, and every write re-triggered the stored computes on res.partner, so the request hit the server time limit and was killed before committing anything. The import now works in two passes: rows are parsed and matched to partners first, existing lines are pre-loaded in a single query indexed by (partner, identifier), then writes are grouped by identical values and creations issued in one call. Partner marking is grouped the same way. Tracking is disabled during the import so it no longer posts one chatter message per line.
…ial_partner_id Resolving the directory status of a company walks its invoices, so the CSV import issues one such query per company. Odoo leaves that column unindexed, making every lookup a sequential scan of account_move — 877k rows on the FPV database, tens of seconds each. The import was killed by the server time limit before writing anything, whatever the batching applied on the Odoo side. Indexing the column also speeds up every partner-centric accounting view.
…update `index=True` on the inherited field is enough on a clean database, but any module redefining commercial_partner_id without it would silently drop the index. Recreating it in `init()` makes the module self-healing: Odoo's `create_index` is a no-op when the index is already there.
…tches Marking a partner as present in the directory invalidates the stored fr_einvoicing_required on account.move, which depends on the partner entity type. Importing a whole directory return in one transaction therefore made Odoo recompute that field across the partners' entire invoice history at flush time: on a production database (877k moves) the worker ran out of memory before committing anything. Partners are now processed in batches of 200, each committed on its own, and the cache is dropped between batches so recomputes stay bounded. Progress is logged batch by batch. The import is no longer atomic; this is deliberate. A directory return is idempotent — lines are upserted by (partner, identifier) — so re-running it after a failure resumes where it stopped.
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.

…ia CSV
When the AFNOR directory API is not activated, this module lets users export the SIREN list to deposit on the official directory (headerless, one SIREN per line) and import the returned CSV (Chorus Pro format) to create/update fr.directory.line records. One CSV row maps to one directory line, matched to its partner by SIREN and disambiguated by SIRET when several companies share a SIREN. The line type (siren/siret/routing_code/suffix) is derived from the electronic address structure. A wizard exposes both steps.
Annuaire: https://facturation.chorus-pro.gouv.fr/annuaire/