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

I am currently working on a custom app in Odoo and I am trying to implement a domain filter widget that dynamically updates based on the selection of another field. Specifically, I have a `model_id` field (a Many2one relation to `ir.model`) and I want the domain filter to use the model selected in `model_id`.

Here is the relevant part of my code:

```python

class MyCustomModel(models.Model):

_name = 'my.custom.model'

_description = 'My Custom Model'

model_id = fields.Many2one(

"ir.model",

string="Main Model",

required=True,

tracking=True,

ondelete="cascade",

)

domain = fields.Char(string="Domain Filter", tracking=True, default="[]")

model_name = fields.Char(related='model_id.model', string="Model Name", readonly=True)

```

In my XML view, I have the following fields:

```xml

<field name="model_id"/>

<field name="domain" widget="domain" options="{'model': model_id}" invisible="request_method == 'get'"/>

```

I also tried using the related field `model_name`:

```xml

<field name="model_id"/>

<field name="model_name" invisible="1"/>

<field name="domain" widget="domain" options="{'model': 'model_name'}" invisible="request_method == 'get'"/>

```

However, I am facing issues with passing the selected model to the domain filter widget. The domain filter expects a string, and I am unsure how to correctly reference the selected model from `model_id`.

Has anyone encountered a similar issue or can provide guidance on how to properly implement this functionality? Any help would be greatly appreciated!

Thank you in advance!

아바타
취소
관련 게시물 답글 화면 활동
0
7월 24
2115
1
5월 24
2822
0
11월 22
2745
1
11월 22
5158
2
7월 22
3902