我正在使用 Odoo v10 执行某些任务,但出现此错误
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')
模型安装时的图片:
添加新报价时出错:
您在创建 Quotations_id
模型字段时遇到问题,反向名称非常错误。您不能将 name
指定为反向字段,因为它已经在销售订单中并且反向字段应该是 Many2one
所以要编辑您的字段定义必须像那样
Quotations_id = fields.One2many('sale.order', 'fleet_id', 'Quotation', required=True,help='select Quotation name')
并且您必须在 sale.order
模型中添加 fleet_id
字段作为 Many2one
关系,如下所示
class SaleOrder(models.Model):
_inherit= 'sale.order
fleet_id = fields.Many2one('fleet.vehicle.direction')
#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')
模型安装时的图片:
添加新报价时出错:
您在创建 Quotations_id
模型字段时遇到问题,反向名称非常错误。您不能将 name
指定为反向字段,因为它已经在销售订单中并且反向字段应该是 Many2one
所以要编辑您的字段定义必须像那样
Quotations_id = fields.One2many('sale.order', 'fleet_id', 'Quotation', required=True,help='select Quotation name')
并且您必须在 sale.order
模型中添加 fleet_id
字段作为 Many2one
关系,如下所示
class SaleOrder(models.Model):
_inherit= 'sale.order
fleet_id = fields.Many2one('fleet.vehicle.direction')