本文介绍了如何为单个类中的两个many2one字段在odoo中获得两个_rec_name?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下代码,我想要这两个字段asset_catg_id
和folio_num
.这些应该可用于many2one两个字段.如何为一个类写2个_rec_name?
I have following code I want this two fields asset_catg_id
and folio_num
. These should be available for many2one two fields. How to write 2 _rec_name for a single class?
class asset_asset(osv.osv):
_inherit = "asset.asset"
#_name = "asset_asset"
_rec_name= "folio_num"
#_rec_name = "assetmodelid_add"
_columns = {
'name': fields.char('Asset Name', size=64),
'company_id1': fields.many2one('res.company', 'Substation', required=True),
#'place1': fields.many2one('asset.parentlocation', 'Location'),
'asset_catg_id' : fields.many2one('asset.catg', 'Asset Catg Selection',select=True, required=True),
'area_id' : fields.many2one('asset.name', 'Asset Name Selection', domain="[('asset_catg_id', '=', asset_catg_id)]", select=True, required=True),
'assetmodelid_add' : fields.many2one('agile.portfolio1','Asset Model Code',domain="[('area_id', '=', area_id)]",),
'folio_num' : fields.char('Folio No',),
'asse_line':fields.one2many('asset.line','emp_id','Name Plate'),
'asse_line2':fields.one2many('asset.part','emp_id1','Parts'),
#'assed_modelid':fields.many2one('agile.portfolio1','Asset Model ID',select=True, required=True),
'quantity': fields.char('Quantity',size=64),
'uom': fields.char('Uinit of Measure',size=64),
'model_no' : fields.char('Model', size=64),
#'asset_id':fields.many2one('agile.portfolio','Asset ID'),
}
推荐答案
要做的就是覆盖模型asset.asset
的方法_name_get
.
What do you have to do to manage that is to overwrite the method _name_get
of the model asset.asset
.
@api.multi
def name_get(self):
res = []
for asset in self:
display_name = []
res.append((asset.id,
asset.folionum + ' ' + asset.assetmodelid_add.name))
return res
这篇关于如何为单个类中的两个many2one字段在odoo中获得两个_rec_name?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!