-3
#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')

安装时的模型图像:

在此处输入图像描述

添加新报价时出错:

在此处输入图像描述

4

1 回答 1

0

您在创建模型字段时遇到问题 Quotations_id,即反向名称非常错误。您不能指定name为反向字段,因为它已经在销售订单中,并且反向字段应该Many2one如此编辑,您的字段定义必须是这样的

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

而且您必须将模型中的fleet_id字段添加为这样的关系sale.orderMany2one

class SaleOrder(models.Model):
     _inherit= 'sale.order
     fleet_id = fields.Many2one('fleet.vehicle.direction')
于 2017-01-11T20:33:01.003 回答