[英]Could it be possible to create an list in the treeview? Odoo
它可以顯示Onemany
或Many2many
直接在樹上視野,但他們將只顯示的記錄數,而不是這些記錄的內容。
(2 records)
正如您在問題中所顯示的,沒有任何方法可以將每條記錄顯示在各自的行上。
您可能會使用計算出的“ Text
字段僅顯示在樹狀視圖上,如下所示。
注意:您尚未提供與您的情況相關的任何真實信息,因此我將使用一個示例。 假設您要查看銷售訂單的列表,並且想要在列表視圖中顯示該銷售訂單上每個產品的名稱。
Class SaleOrder(models.Model):
_inherit = 'sale.order'
# This is whatever field has the multiple records you want to display
order_line = fields.One2many('sale.order.line',
'order_id',
string='Order Lines', ...)
order_line_text = fields.Text('Order Lines (Text)',
compute='_compute_order_line_text',
store=True)
@api.multi
@api.depends('order_line')
def _compute_order_line_text(self):
for order in self:
product_names = [line.product_id.name for line in order.order_line]
# You may have to use a different line breaking character
# It depends what is rendered in the list view
order.order_line_text = "\n".join(product_names)
如果此解決方案無法按您希望的方式工作,則下一個選項是創建一個菜單,該菜單顯示x2many
字段的列表(在此示例中為order_line
)。
基本上,您將創建一個菜單和一個操作以顯示所有銷售訂單行的列表,然后您可以按銷售訂單分組,這將(至少非常類似於)您的問題示例。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.