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

Hello,i'll describe problem in the detail.The main problem is that i can't save 'res_model' field in 'ir.attachment' table. I use odoo v12.0.


Budget model​

```

class AccountBudget(models.Model):
_name = "account.budget"

attachment_ids = fields.One2many('ir.attachment', 'id', string='Attachments')
```

Budget view

```

<field name="attachment_ids" context="{'default_res_model': 'account.budget',
'default_file_type': 'document'}">

</field>

```

As you can see, i set context wit default res_model. But when i click save button it doesn't save res_model.
File type work greatly.

This behavior only with One2Many relation. If i set 'attachment_ids' Many2Many all works fine.
But with Many2Many field i have one layer, that displayed all files, i don't need that.

How can i save attachment for certain res_model?

아바타
취소
베스트 답변

Have you fixed the issue ? 

아바타
취소
베스트 답변

Read the documentation on how to define the One2man relational field.
https://www.odoo.com/documentation/12.0/reference/orm.html#relational-fields
See definition inverse name:
inverse_name – name of the inverse Many2one field in comodel_name
Your inverse_name = id is not good.

Example:
invoice_line_ids = fields.One2many('account.invoice.line', 'invoice_id', string='Invoice Lines')

아바타
취소
관련 게시물 답글 화면 활동
0
8월 17
3823
1
4월 24
6563
1
3월 15
11346
1
11월 24
2329
3
12월 23
6140