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
    • Artificial Intelligence
    • 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
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

Circular Dependency Error

Subscribe

Get notified when there's activity on this post

This question has been flagged
pythonrelationshipdependenciesm2omanifestodoo17
2097 Views
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
Discard
Enjoying the discussion? Don't just read, join in!

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

Sign up
Related Posts Replies Views Activity
Error trying to run Odoo 17 with Python 3.12.
python postgresql odoo17
Avatar
Avatar
Avatar
2
Nov 25
4775
Log out session Odoo 17
community python odoo17
Avatar
Avatar
Avatar
2
Jun 25
4906
Model Relations
product relationship odoo17
Avatar
0
Sep 24
1636
Openerp 7 Python Related error
python external dependencies
Avatar
Avatar
1
Mar 15
5467
Issue with Access Rules for Attachments / odoo 17 Solved
security python xml odoo17
Avatar
Avatar
Avatar
Avatar
Avatar
4
Jun 25
5485
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
الْعَرَبيّة 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 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

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