我有很多这样的字段
state = fields.Many2one ("ags.traffic.operation.state")
州有以下字段
name = fields.Char
sequence = fields.Integer
type = fields.Selection
在我看来我有
<field name = "state" widget = "statusbar" clickable = "True" / >
如何访问这些字段以设置默认值?
答案 0 :(得分:0)
if you want to define the field that gets shown in the drop-down in your view in your model define _rec_name
this tells odoo to display that field (in a drop down or in a many2many tag field) when a many2one or one2one relationship is created between that model and another model. for example if you want the sequence number to display in the drop down just set
_recname = 'sequence'
but by default odoo checks the model's field and if it finds a name field (just like you have defined in your model). it uses that as the default display name.
if you want to search records in odoo you can use the search
method. please see the documentation for more information about the odoo ORM
https://www.odoo.com/documentation/8.0/reference/orm.html#openerp.models.Model.browse
search(args[, offset=0][, limit=None][, order=None][, count=False])
but a typical example is
search_records = self.env['your.model'].search([('id', 'in', ids)])