跳至內容
選單
此問題已被標幟
2 回覆
6968 瀏覽次數

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
3677
1
4月 24
6368
1
3月 15
11181
1
11月 24
2006
3
12月 23
5845