openerp7中的车队管理模块

时间:2015-03-12 15:12:43

标签: python python-2.7 openerp-7

我在车辆形式中包含了一个油箱容量字段,并且还希望在燃料记录中制作升,以便如果在记录燃料记录时输入的升数超过该车辆的油箱容量,则应该不允许。

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

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'])
]

0 个答案:

没有答案