如何更改Odoo中关系字段的显示值

来源:互联网 发布:php调用百度日历api 编辑:程序博客网 时间:2024/05/18 03:17

How to change displayed value for relational field in Odoo

If you want to change the displayed value for a relational field in Odoo, the simplest way to do that is to define the “_rec_name” model’s attribute with the name of the field that you want to show.

For example, if you want to add new field “description” in the hr.employee.category model and you want that field to be shown as value for this model the code should look like:

class Employee(models.Model):    _inherit = 'hr.employee.category'    _rec_name = 'description'    description = fields.Char()

Now when you try to search for a new employee tag in the hr.employee view it will search by and display the description of the hr.employee.category model.

简而言之,简单的改变关系字段的显示,只需要将对应关系字段的model中_rec_name修改成需要显示的字段即可,这样之后的字段显示就是该字段的值。

From:http://www.odooninja.com/change-displayed-value-relational-field-odoo/


原创粉丝点击