跳至内容
菜单
此问题已终结

Hi guys,

I've created a custom module with two classes in one file. The first class inherits a model and adds fields, the second class creates a new model:

# -*- coding: utf-8 -*-
from openerp import models, fields, api
class aa_custom_module(models.Model):
    _inherit = 'fleet.vehicle'
    NumberPlate2 = fields.Char('Second number plate')
    SoortOpleggerIds = fields.Many2many('fleet.vehicle.oplegger.soort', 'fleet_soort_oplegger_rel', 'oplegger_oplegger_id', 'oplegger_id', 'Soort Oplegger', required=True)

class fleet_oplegger_tag(models.Model):
    _name = 'fleet.vehicle.oplegger.soort'
    _description = 'Soort van oplegger'
    Name = fields.Char('Name', required=True, translate=True) 

SoortOpleggerIds is a Many2many field which is defined as a widget for tags in the view:

<field name="SoortOpleggerIds" widget="many2many_tags"/> 

The problem is that when I now want to create/add a new record to the Many2many SoortOpleggerIds I will get the following error:

 2015-05-04 08:44:25,357 19326 WARNING test-db openerp.models: Cannot execute name_search, no _rec_name defined on fleet.vehicle.oplegger.soort
So, why am I getting this error? What have I done wrong?

Thanks,
Yenthe

形象
丢弃
编写者 最佳答案

Hi guys,

Turns out you need to have a field named 'name', exactly 'name'. No capitals, nothing else. So this fixed it:

 class fleet_oplegger_tag(models.Model):
    _name = 'fleet.vehicle.oplegger.soort'
    _description = 'Soort van oplegger'
    name = fields.Char('Name', required=True, translate=True)
形象
丢弃
相关帖文 回复 查看 活动
2
12月 24
25089
2
10月 21
4724
1
4月 17
5924
2
4月 23
29156
3
8月 20
9516