Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
7087 Представления

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')

Аватар
Отменить
Related Posts Ответы Просмотры Активность
0
авг. 17
3712
1
апр. 24
6439
1
мар. 15
11241
1
нояб. 24
2117
3
дек. 23
5953