Sari la conținut
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Artificial Intelligence
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Property Management
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Toate postările Oameni Insigne
Etichete (Vezi tot)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Toate postările Oameni Insigne
Etichete (Vezi tot)
odoo accounting v14 pos v15
Despre acest forum
Suport

Circular Dependency Error

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
pythonrelationshipdependenciesm2omanifestodoo17
2214 Vizualizări
Imagine profil
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
Imagine profil
Abandonează
Îți place discuția? Nu doar citi, alătură-te!

Creează-ți un cont astăzi pentru a beneficia de funcții exclusive și a interacționa cu minunata noastră comunitate!

Înscrie-te
Postări similare Răspunsuri Vizualizări Activitate
Error trying to run Odoo 17 with Python 3.12.
python postgresql odoo17
Imagine profil
Imagine profil
Imagine profil
2
nov. 25
5087
Log out session Odoo 17
community python odoo17
Imagine profil
Imagine profil
Imagine profil
2
iun. 25
5170
Model Relations
product relationship odoo17
Imagine profil
0
sept. 24
1721
Openerp 7 Python Related error
python external dependencies
Imagine profil
Imagine profil
1
mar. 15
5628
Issue with Access Rules for Attachments / odoo 17 Rezolvat
security python xml odoo17
Imagine profil
Imagine profil
Imagine profil
Imagine profil
Imagine profil
4
iun. 25
5721
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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