Hi everyone!
I have this error:
psycopg2.errors.DatatypeMismatch: foreign key constraint "project_project_laboratorio_fkey" cannot be implemented DETAIL: Key columns "laboratorio" and "id" are of incompatible types: character varying and integer.
I have created a model "areas" (Table in database) to use it in a many2one field in a "project.project" inherited custom module I made. I loaded registers in my "areas" module in the python file.
@api.model
def init(self):
default_data = [
{'area_ejecutante': 'lie', 'laboratorio': 'lide'},
{'area_ejecutante': 'ima', 'laboratorio': 'pintura'},
{'area_ejecutante': 'lie', 'laboratorio': 'laie'},
{'area_ejecutante': 'ima', 'laboratorio': 'mecanica'},
]
for data in default_data:
# Ensure no duplicates
if not self.search([('area_ejecutante', '=', data['area_ejecutante']),
('laboratorio', '=', data['laboratorio'])]):
self.create(data)
Now I commented all the code and unlinked the "areas" model in the __init__.py .
And I have this error.
Any idea how can I fix it?
Thanks in advance, Nicolás
Many2one use _rec_name property and you need to have _compute_display_name method
P/s: can you mark my answer as best one please, thank in advance