Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Artificial Intelligence
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Property Management
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    • Referral Program
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

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

Subscriure's

Get notified when there's activity on this post

This question has been flagged
salesaccounting
2 Respostes
1999 Vistes
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
Descartar
Avatar
CandidRoot Solutions
Best Answer
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
Descartar
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Best Answer
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
Descartar
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrar-se
Related Posts Respostes Vistes Activitat
How can send / receive Peppol Invoices in Odoo? Is it free? Which App / module? Solved
sales accounting
Avatar
Avatar
Avatar
Avatar
Avatar
4
de juny 26
6649
feature request: Structured E-Invoicing (XRechnung / ZUGFeRD / EN 16931) in Odoo Online Free Plan
sales accounting
Avatar
Avatar
1
de febr. 26
1878
Warehouse on Product lines level
sales accounting
Avatar
Avatar
Avatar
2
d’oct. 25
2155
Confusion regarding Product Categories and E-commerce Categories
sales accounting
Avatar
Avatar
Avatar
3
d’oct. 25
2473
Can I use custom fields and Python to calculate Sales Tax? Solved
sales accounting
Avatar
Avatar
2
d’ag. 25
2729
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة 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 és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

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