Search code examples
odooodoo-8openerp-8odoo-10

I am using Odoo v10 to do some task but this error is appearing


#model.py
# -*- coding: utf-8 -*-

from openerp import models, fields


class fleet_vehicle_direction(models.Model):

    _name = 'fleet.vehicle.direction'
    name = fields.Char(related='vehicle_id.name', string='vehicle name', store=True)
    vehicle_id = fields.Many2one('fleet.vehicle', 'select vehicle name', required=True, help='select vehicle name')
    Quotations_id = fields.One2many('sale.order', 'name', 'Quotation', required=True,help='select  Quotation name')

The image of model when install:

enter image description here

Error when add a new Quotation:

enter image description here


Solution

  • You have a problem in creating your model field which is Quotations_id,the inverse name is so wrong. you can't assign name as inverse field because it's already in the sale order and the inverse field should be Many2one so to edit that you your field definition must be like that

    Quotations_id = fields.One2many('sale.order', 'fleet_id', 'Quotation', required=True,help='select  Quotation name')
    

    And you have to add the fleet_id field in the sale.order model as Many2one relation like this

    class SaleOrder(models.Model):
         _inherit= 'sale.order
         fleet_id = fields.Many2one('fleet.vehicle.direction')