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
    • Validacions
    • 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
    Real Estate
    • Real Estate Agency
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consulting
    • Accounting Firm
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Furnitures
    • Food
    • 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
    • Solar Energy Systems
    • Shoe Maker
    • Serveis de neteja
    • HVAC Services
    Others
    • 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

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
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

odoo 13: inverse name in comodel

Subscriure's

Get notified when there's activity on this post

This question has been flagged
odoo13CE
3 Respostes
5104 Vistes
Avatar
luna_22

Hello, I am totally new to odoo and I am stuck with this problem: I have a module named "comite technique" that has a one2many field with the "promoteurs" model in on other module, so I had to add a many2one field to the "promoteurs" model to make it work, when I added the many2one field, the promoteurs works pretty fine here is the code of models.py in the promoteurs module:

class promoteurinitiative(models.Model):
    _name = 'initiative.promoteur'
    _rec_name = 'prenom'

    civilite = fields.Many2one('res.partner.title')
    nom = fields.Char(string="Nom", required=True)
    prenom = fields.Char(string="Prénom", required=True)
    date = fields.Date(string="Date de naissance", required=True)
    email = fields.Char()
    country_id = fields.Many2one('res.country', string='Country', ondelete='restrict')
    tel = fields.Char(string="Tél", required=True)
    contract_count = fields.Integer()
    comite_id = fields.Many2one('initiative.comitetechnique', string="Comité technique")

But whenever I add the one2many field in the "comite technique" ,change its view, restart odoo server and try to upgrade the module, I get this error:

(...)
  File "/home/asma/odoo/odoo/modules/registry.py", line 261, in setup_models
    model._setup_fields()
  File "/home/asma/odoo/odoo/models.py", line 2748, in _setup_fields
    field.setup_full(self)
  File "/home/asma/odoo/odoo/fields.py", line 431, in setup_full
    self._setup_regular_full(model)
  File "/home/asma/odoo/odoo/fields.py", line 2981, in _setup_regular_full
    invf = comodel._fields[self.inverse_name]
KeyError: 'comite_id'

Here is the code in models.py of the "comite technique" module:

class comitetechniqueinitiative(models.Model):
    _name = 'initiative.comitetechnique'
    _rec_name = 'date'
    _description = 'comitetechniqueinitiative'

    date = fields.Date(default=fields.Date.today, string="Date de la comité technique", required=True)
    jour = fields.Char( string='Jour')
    pro = fields.One2many('initiative.promoteur','comite_id')


    @api.onchange('date')
    def _get_day_of_date(self):
        for r in self:
            if r.date :
                selected = fields.Datetime.from_string(r.date)
                r.jour = calendar.day_name[selected.weekday()]

I will be grateful if you can help find a solution to this problem. Thank you 


0
Avatar
Descartar
Avatar
Niyas Raphy (Walnut Software Solutions)
Best Answer

Hi,

If the both models are defined in same module there wont be issues. Reading the question i understood that you have defined the models in separate modules right ? correct me if i am wrong.

So either you have to make these models in the same module, or give the dependency between module properly and adjust the code.


Thanks

0
Avatar
Descartar
Avatar
luna_22
Autor Best Answer

yes @Niyas Raphy, the models are defined in separate modules, how can give the dependency between the modules properly and make it work, please, I will be thankful if you can help me with this. Thank you (Sorry I can't comment so I am writing here in the response)

0
Avatar
Descartar
Avatar
jjjaberi0n
Best Answer

Hi, you are affecting two modules: 'comite technique' and the module that has "promoteurs" model. So when starting Odoo server, you need to update both of them, try './odoo-bin -u all'. This command will update all of your modules and start the server.

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
how can i set a field default value on a form depends on the active company Solved
odoo13CE
Avatar
Avatar
Avatar
2
de set. 23
4656
Field `state` does not exist
odoo13CE
Avatar
Avatar
1
de des. 22
2718
Contacts visible to all users in a multi-company setup Odoo 13 CE Solved
odoo13CE
Avatar
Avatar
1
de nov. 22
5381
how to Hide edit button on specific state of a record for specific user groups Solved
odoo13CE
Avatar
Avatar
1
de maig 22
4582
Tab index, not tabbing over readonly field
odoo13CE
Avatar
0
de febr. 22
2902
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 ภาษาไทย 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