_columns = {
'product_id': fields.many2one('ims.product', 'Product', required=True),
'qty' : fields.integer('Qty', required=True),
'cost': fields.float('Product Cost',digits=(12,2), required=True),
'total_cost': fields.float('Total Cost', digits=(12,2), required=True)
}
qty
字段必须接受最小值10和最大值100.我能如何实现它?
答案 0 :(得分:1)
定义一个函数_check_qty,它在min和max之间的qty时返回true
def _check_qty(self,cr,uid,ids):
for product in self.browse(cr, uid, ids):
min, max = 0,100
min = product.min
max = product.max
if not min <product.qty < max: return False
return True
_constraints = [(_check_qty, 'Please inter other qty !', ['qty'])]