openerp7中的车队管理模块

2024-04-26 07:49:53 发布

您现在位置:Python中文网/ 问答频道 /正文

我在车辆表单中包含了一个油箱容量字段,并且还希望在燃油日志中设置升,以便在记录燃油日志时输入的升数大于所选车辆的油箱容量时不允许这样做。你知道吗

这是我的代码,但不起作用:

def check_tank_capacity(self, cr, uid,ids, context=None):
    fleet_vehicle = self.browse(cr,uid,ids, context)[0]
    liter = fleet_vehicle.tank_capacity
    if fleet_vehicle_log_fuel.liter > fleet_vehicle.tank_capacity:
        raise osv.except_osv(('Tank Capacity!'),('Ensure that the liter you entered is not greater than the tank capacity of this vehicle'))
    return True


_constraints =[
    (check_tank_capacity, "Ensure that the liter is not greater than the tank capacity of this vehicle",['Tank Capacity'])
]

Tags: theselfidsuidcheckcr容量capacity