Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
1 Відповісти
1604 Переглядів

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,

Аватар
Відмінити
Автор Найкраща відповідь

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

Аватар
Відмінити

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.

Related Posts Відповіді Переглядів Дія
1
черв. 15
3375
1
бер. 15
5582
0
бер. 15
8934
2
лют. 25
5899
1
груд. 24
1450