콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
1897 화면

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.

관련 게시물 답글 화면 활동
1
6월 15
3625
1
3월 15
5866
0
3월 15
9279
3
9월 25
1775
0
9월 25
458