Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Intelligence artificielle
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Supermarché
    • Quincaillerie
    • Magasin de jouets
    Restauration & Hôtellerie
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brasserie
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Commerce
    • Homme à tout faire
    • Matériel informatique & support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Parcourir toutes les industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenir partenaire
    • Services pour partenaires
    • Enregistrer votre cabinet comptable
    • Referral Program
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

KeyError: 'company_id' after database migration from 16.0 to 17.0 CE (related to Analytic Plans)

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
salesaccounting
2 Réponses
2007 Vues
Avatar
Manish Kumar

I just migrated my db from odoo16 to odoo17 community edition

While addling line items in sales documents like sales order or Invoices it's giving the below error

RPC_ERROR
Odoo Server Error
Traceback (most recent call last):
  File "/opt/odoo/odoo/odoo/http.py", line 1984, in _serve_db
    return service_model.retrying(self._serve_ir_http, self.env)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/odoo/odoo/odoo/service/model.py", line 152, in retrying
    result = func()
             ^^^^^^
  File "/opt/odoo/odoo/odoo/http.py", line 2012, in _serve_ir_http
    response = self.dispatcher.dispatch(rule.endpoint, args)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/odoo/odoo/odoo/http.py", line 2216, in dispatch
    result = self.request.registry['ir.http']._dispatch(endpoint)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/odoo/odoo/addons/website/models/ir_http.py", line 235, in _dispatch
    response = super()._dispatch(endpoint)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/odoo/odoo/odoo/addons/base/models/ir_http.py", line 221, in _dispatch
    result = endpoint(**request.params)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/odoo/odoo/odoo/http.py", line 799, in route_wrapper
    result = endpoint(self, *args, **params_ok)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/odoo/odoo/addons/web/controllers/dataset.py", line 25, in call_kw
    return self._call_kw(model, method, args, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/odoo/odoo/addons/web/controllers/dataset.py", line 21, in _call_kw
    return call_kw(Model, method, args, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/odoo/odoo/odoo/api.py", line 480, in call_kw
    result = _call_kw_model(method, model, args, kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/odoo/odoo/odoo/api.py", line 451, in _call_kw_model
    result = method(recs, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/odoo/odoo/addons/analytic/models/analytic_plan.py", line 212, in get_relevant_plans
    root_plans = (project_plan + other_plans).filtered(lambda p: (
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/odoo/odoo/odoo/models.py", line 6166, in filtered
    return self.browse([rec.id for rec in self if func(rec)])
                                                  ^^^^^^^^^
  File "/opt/odoo/odoo/addons/analytic/models/analytic_plan.py", line 215, in <lambda>
    and p._get_applicability(**kwargs) != 'unavailable'
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/odoo/odoo/addons/analytic/models/analytic_plan.py", line 242, in _get_applicability
    for applicability_rule in self.applicability_ids.filtered(
                              ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/odoo/odoo/odoo/fields.py", line 4471, in __get__
    return super().__get__(records, owner)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/odoo/odoo/odoo/fields.py", line 2933, in __get__
    return super().__get__(records, owner)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/odoo/odoo/odoo/fields.py", line 1182, in __get__
    recs._fetch_field(self)
  File "/opt/odoo/odoo/odoo/models.py", line 3824, in _fetch_field
    self.fetch(fnames)
  File "/opt/odoo/odoo/odoo/models.py", line 3863, in fetch
    self.check_access_rule('read')
  File "/opt/odoo/odoo/odoo/models.py", line 4162, in check_access_rule
    invalid = self - self._filter_access_rules_python(operation)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/odoo/odoo/odoo/models.py", line 4214, in _filter_access_rules_python
    return self.sudo().filtered_domain(dom or [])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/odoo/odoo/odoo/models.py", line 6240, in filtered_domain
    field = model._fields[fname]
            ~~~~~~~~~~~~~^^^^^^^
KeyError: 'company_id'

The above server error caused the following client error:
OwlError: An error occured in the owl lifecycle (see this Error's "cause" property)
    Error: An error occured in the owl lifecycle (see this Error's "cause" property)
        at handleError (https://apps.technians.com/web/assets/eea476b/web.assets_web.min.js:938:101)
        at App.handleError (https://apps.technians.com/web/assets/eea476b/web.assets_web.min.js:1596:29)
        at ComponentNode.initiateRender (https://apps.technians.com/web/assets/eea476b/web.assets_web.min.js:1030:19)

Caused by: RPC_ERROR: Odoo Server Error
    RPC_ERROR
        at makeErrorFromResponse (https://apps.technians.com/web/assets/eea476b/web.assets_web.min.js:2956:163)

        at XMLHttpRequest.<anonymous> (https://apps.technians.com/web/assets/eea476b/web.assets_web.min.js:2960:13)

0
Avatar
Ignorer
Avatar
CandidRoot Solutions
Meilleure réponse
Hey Manish

This issue is caused by incomplete analytic data after migration
from Odoo 16 to Odoo 17.

In Odoo 17, Analytic Plans and their Applicability Rules are
multi-company aware and require a company_id.

During migration, some analytic.plan or analytic applicability
rule records may have company_id set to NULL.
When adding a sales or invoice line, Odoo tries to evaluate
analytic applicability and crashes with:

KeyError: 'company_id'

How to fix:

1) UI-based check (Recommended)
   - Go to Accounting > Configuration > Analytic Plans
   - Open each Analytic Plan
   - Ensure Company is set
   - Check Applicability Rules and assign Company if missing

2) SQL fix (Quick fix – use carefully)
   - Identify analytic plans with company_id IS NULL
   - Assign the correct company_id
   - Restart Odoo service after update

Once all Analytic Plans and related rules have a valid company,
the error disappears.

This is a data consistency issue caused by migration,
not a standard Odoo bug.


After migrating to Odoo 17, analytic plans without company_id cause this error; assigning a company to all analytic plans and rules fixes the issue.

If this helped, kindly upvote.

Best Reagards,


CandidRoot Solutions Pvt. Ltd.
Mobile: (+91) 8849036209
Whatapp: (+91) 8849036209
Email: info@candidroot.com
Web: https://www.candidroot.com
2
Avatar
Ignorer
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Meilleure réponse
Hi,

After migrating from Odoo 16 to Odoo 17 Community, this error is caused by broken analytic plans. Odoo 17 requires analytic plans and their rules to have a company_id, and some migrated records are missing it, triggering the crash when adding sales or invoice lines.

The fix is to ensure all Analytic Plans and Applicability Rules have a company set, or quickly correct them via SQL by assigning a company to plans with company_id = NULL. Once analytics data is fixed, the error disappears.

Hope it helps

-1
Avatar
Ignorer
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
How can send / receive Peppol Invoices in Odoo? Is it free? Which App / module? Résolu
sales accounting
Avatar
Avatar
Avatar
Avatar
Avatar
4
juin 26
6652
feature request: Structured E-Invoicing (XRechnung / ZUGFeRD / EN 16931) in Odoo Online Free Plan
sales accounting
Avatar
Avatar
1
févr. 26
1882
Warehouse on Product lines level
sales accounting
Avatar
Avatar
Avatar
2
oct. 25
2156
Confusion regarding Product Categories and E-commerce Categories
sales accounting
Avatar
Avatar
Avatar
3
oct. 25
2475
Can I use custom fields and Python to calculate Sales Tax? Résolu
sales accounting
Avatar
Avatar
2
août 25
2729
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenir partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk Slovenščina Español (América Latina) Español Svenska ภาษาไทย Türkçe українська Tiếng Việt

Odoo est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now