Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
1557 Vistas

Hello Everyone, 

I have a model approve.base which is an AbstractModel, and it contains a many2one field workflow_config_id referencing the model workflow.config, which is a Model. 

class ApproveBase(models.AbstractModel):
_name = 'approve.base'

workflow_config_id = fields.Many2one('workflow.config', string='Workflow Config',copy=False, tracking=True)


class WorkflowConfig(models.Model):
_name = 'workflow.config'

active = fields.Boolean(string=_('Active'), default=True)
class ModelA(models.Model):
_name = "model.a"
_inherit = ['approve.base']


I then developed a functionality called model A that inherits approve.base. The error occurs when I create a record in model A, where the field workflow_config_id holds a record from workflow.config. Afterward, I use the deactivation function (in workflow.config, there is an active field) to deactivate the referenced record and create a similar record in workflow.config. Next, when I click on that record in model A, the following error occurs:


RPC_ERROR

Odoo Server Error

Traceback (most recent call last):

  File "/usr/lib/python3/dist-packages/odoo/models.py", line 128, in web_read

    vals = many2one_data[values[field_name]]

KeyError: 61


I checked and saw that the KeyError: 61 corresponds to the ID of the workflow.config record that I deactivated. I tried debugging the web_read function and noticed that the workflow_config_id value is now pointing to the new record that I created in the workflow.config model. 


If anyone knows what might be causing this and what the solution could be, please help me.

Regards,

Avatar
Descartar
Autor Mejor respuesta

This is an error caused by my handling, not issues related to the AbstractModel.

Avatar
Descartar

Could you please share what was the problem? I have pretty much the same issue - I think it's because of the usage of Many2one fields in the AbstractModel in Odoo 18, but am not sure.

Publicaciones relacionadas Respuestas Vistas Actividad
1
jun 15
3317
1
mar 15
5504
0
mar 15
8893
2
feb 25
5779
1
dic 24
1368