Skip to Content
Menu
This question has been flagged

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

Avatar
Discard
Author Best Answer

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)
Avatar
Discard
Related Posts Replies Views Activity
2
Dec 24
23101
2
Oct 21
3792
1
Apr 17
5107
2
Apr 23
28000
3
Aug 20
8848