我需要将三列的值存储在一列中但是树视图不允许我以任何方式转换或改变它在这种情况下我能做什么?我的模块:academy
<record id="view_academy_tree" model="ir.ui.view">
<field name="name">academy.tree</field>
<field name="model">academy</field>
<field name="arch" type="xml">
<tree>
<field name="name"/>
<field name="lastname"/>
<field name="age"/>
<field name="description"/>
<field name="date"/>
</tree>
</field>
</record>
from odoo import models, fields, api
class academy(models.Model):
_name = 'academy'
_description = 'academy'
name = fields.Char(string="Имя")
lastname = fields.Char(string="Фамилия")
age = fields.Integer(string="Возраст")
description = fields.Text(string="Дополнительно")
image = fields.Binary(string="Фотография")
def _default_my_date(self):
return fields.Date.context_today(self)
date = fields.Date(string="Дата", default=_default_my_date)
如果我理解正确的话你要做两件事,一是结合成一个3字段,这可以用一个计算字段。
第二个是改变树视图,以显示新的字段,而不是其他3,你可以通过替换视图来做到:例子:
<record model="ir.ui.view" id="custom_academy_tree">
<field name="name">academy.tree.inherit</field>
<field name="model">academy.tree</field>
<field name="inherit_id" ref="*the_form_id*"/>
<field name="arch" type="xml">
<field name="academy_tree" position="replace">
<tree>
<field name="old_field1"/>
<field name="old_field2"/>
<field name="new_field"/>
</tree>
</field>
</record>