I need to store the values of three columns in one column But the tree view does not allow me to transform or change it in any way What can I do in this case? My module: 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)
CodePudding user response:
If i understood correctly you want to do 2 things, first is combine 3 fields into one, which can be done with a computed field.
The second is changing the tree view to show the new field instead of the other 3 which you can do by replacing the view: Example:
<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>