跳至内容
菜单
此问题已终结
1 回复
2538 查看

Hi,
I would like to know how can I customize the label from many2many_tags please ?


Currently, on the view Episode (listing), I have this on the column Diffusion, and I would like to show the date_diffusion​ field from slot_diffusion model, not content_slot.slot_diffusion,x:

content.slot_diffusion,3
content.slot_diffusion,4


# Episode
from odoo import fields, models
class ContentEpisode(models.Model):
_name ="content.episode"  

​slot_diffusion_ids = fields.One2many(comodel_name="content.slot_diffusion", inverse_name="episode_id")


# Slot diffusion
from odoo import fields, models
class ContentSlotDiffusion(models.Model):
​​_name ="content.slot_diffusion"
​​
​date_diffusion = fields.Datetime(string="Date de diffusion", required=True)

​​episode_id = fields.Many2one(comodel_name="content.episode")


On the view, I have this:


---
fieldname="slot_diffusion_ids" string="Diffusion" widget="many2many_tags" optional="show"

---

I tried to embed, but I have an error TypeError: Cannot read properties of undefined (reading 'relation'):


---
fieldname="slot_diffusion_ids" string="Diffusion" widget="many2many_tags" optional="show"

tree

​fieldname="content.slot_diffusion.slot_diffusion_id" string="date_diffusion"

tree

field
---





形象
丢弃
最佳答案

use "rec_name"

i am making a slight change in your code. Copy these changes in your code and retry.
If you want to show date_diffusion field in your many2many_tags you should 'date_diffusion' in your _rec_name and if you want to use some other field you cane type it in your rec_name.

# Slot diffusion
from odoo import fields, models
class ContentSlotDiffusion(models.Model):
​​_name ="content.slot_diffusion"
_rec_name = 'date_diffusion'​​
​date_diffusion = fields.Datetime(string="Date de diffusion", required=True)

​​episode_id = fields.Many2one(comodel_name="content.episode")


形象
丢弃
相关帖文 回复 查看 活动
1
6月 21
4174
1
1月 19
6072
2
9月 23
8902
0
4月 20
4509
0
3月 19
3589