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
    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

Circular Dependency Error

Subscriure's

Get notified when there's activity on this post

This question has been flagged
pythonrelationshipdependenciesm2omanifestodoo17
2095 Vistes
Avatar
Trishan Fernando

I have 2 modules let's call them module_a and the module_b
and i want to use m2o relationships between these 2 models but for both sides and here is the sample code that shows what i am trying to do is 


module_a/models/model_a.py

from odoo import models, fields, api


class module_a(models.Model):

_name = 'module_a.module_a'

_description = 'module_a.module_a'


name = fields.Char()

value = fields.Integer()

value2 = fields.Float(compute="_value_pc", store=True)

description = fields.Text()

module_b_id = fields.Many2one('module_b.module_b')


@api.depends('value')

def _value_pc(self):

for record in self:

record.value2 = float(record.value) / 100



 module_a/__manifest__.py

{

'name': "module_a",

'summary': "Short (1 phrase/line) summary of the module's purpose",

'description': """

Long description of module's purpose

""",

'author': "My Company",

'website': "https://www.yourcompany.com",

'category': 'Uncategorized',

'version': '0.1',

'depends': ['base'],

'data': [

'security/ir.model.access.csv',

'views/views.xml',

],

}



this is the module_b
module_a/models/model_b.py

from odoo import models, fields, api


class module_b(models.Model):

_name = 'module_b.module_b'

_description = 'module_b.module_b'


name = fields.Char()

value = fields.Integer()

value2 = fields.Float(compute="_value_pc", store=True)

description = fields.Text()

module_a_id = fields.Many2one('module_a.module_a')

module_a_value = fields.Integer(compute='_compute_module_a_id_value')


@api.depends('value')

def _value_pc(self):

for record in self:

record.value2 = float(record.value) / 100


@api.depends('module_a_id')

def _compute_module_a_id_value(self):

for rec in self:

rec.module_a_value =rec.module_a_id.value if rec.module_a_id else False

 module_b/__manifest__.py

{

'name': "module_b",

'summary': "Short (1 phrase/line) summary of the module's purpose",

'description': """

Long description of module's purpose

""",

'author': "My Company",

'website': "https://www.yourcompany.com",

'category': 'Uncategorized',

'version': '0.1',

'depends': ['base','module_a'],

'data': [

'security/ir.model.access.csv',

'views/views.xml',

],

}


ERROR


RPC_ERROR
Odoo Server Error
Traceback (most recent call last):
  File "/home/trishan/crede/odoo/odoo/http.py", line 1788, in _serve_db
    return service_model.retrying(self._serve_ir_http, self.env)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/trishan/crede/odoo/odoo/service/model.py", line 152, in retrying
    result = func()
             ^^^^^^
  File "/home/trishan/crede/odoo/odoo/http.py", line 1816, in _serve_ir_http
    response = self.dispatcher.dispatch(rule.endpoint, args)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/trishan/crede/odoo/odoo/http.py", line 2020, in dispatch
    result = self.request.registry['ir.http']._dispatch(endpoint)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/trishan/crede/odoo/odoo/addons/base/models/ir_http.py", line 221, in _dispatch
    result = endpoint(**request.params)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/trishan/crede/odoo/odoo/http.py", line 757, in route_wrapper
    result = endpoint(self, *args, **params_ok)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/trishan/crede/odoo/addons/web/controllers/dataset.py", line 25, in call_kw
    return self._call_kw(model, method, args, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/trishan/crede/odoo/addons/web/controllers/dataset.py", line 21, in _call_kw
    return call_kw(Model, method, args, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/trishan/crede/odoo/odoo/api.py", line 480, in call_kw
    result = _call_kw_model(method, model, args, kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/trishan/crede/odoo/odoo/api.py", line 451, in _call_kw_model
    result = method(recs, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/trishan/crede/odoo/addons/web/models/models.py", line 47, in web_search_read
    values_records = records.web_read(specification)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/trishan/crede/odoo/addons/web/models/models.py", line 86, in web_read
    values_list: List[Dict] = self.read(fields_to_read, load=None)
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/trishan/crede/odoo/odoo/models.py", line 3577, in read
    return self._read_format(fnames=fields, load=load)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/trishan/crede/odoo/odoo/models.py", line 3790, in _read_format
    vals[name] = convert(record[name], record, use_display_name)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/trishan/crede/odoo/odoo/fields.py", line 3126, in convert_to_read
    return value.id
           ^^^^^^^^
AttributeError: '_unknown' object has no attribute '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 (http://localhost:8069/web/assets/9d44c3b/web.assets_web.min.js:925:101)
        at App.handleError (http://localhost:8069/web/assets/9d44c3b/web.assets_web.min.js:1576:29)
        at ComponentNode.initiateRender (http://localhost:8069/web/assets/9d44c3b/web.assets_web.min.js:1017:19)

Caused by: RPC_ERROR: Odoo Server Error
    RPC_ERROR
        at makeErrorFromResponse (http://localhost:8069/web/assets/9d44c3b/web.assets_web.min.js:2929:163)
        at XMLHttpRequest.<anonymous> (http://localhost:8069/web/assets/9d44c3b/web.assets_web.min.js:2933:13)

In case , I have used the related field also instead of using the compute to get value to the model_a_id_value and it is also not working , also I put the module_b as a depends in module_a , it also throw the keyerror as this and i think it cause of the circular dependencies , 
KeyError: 'module_b.module_b'


so what should i do ? is there are fix for this ? 
I want to use m2o relationships with module_a and module_b for both sides ? 


0
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
Error trying to run Odoo 17 with Python 3.12.
python postgresql odoo17
Avatar
Avatar
Avatar
2
de nov. 25
4772
Log out session Odoo 17
community python odoo17
Avatar
Avatar
Avatar
2
de juny 25
4902
Model Relations
product relationship odoo17
Avatar
0
de set. 24
1636
Openerp 7 Python Related error
python external dependencies
Avatar
Avatar
1
de març 15
5467
Issue with Access Rules for Attachments / odoo 17 Solved
security python xml odoo17
Avatar
Avatar
Avatar
Avatar
Avatar
4
de juny 25
5483
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