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