质检单数量约束
This commit is contained in:
@@ -155,4 +155,32 @@ class QualityCheck(models.Model):
|
||||
qty_line = fields.Float('数量', store=True)
|
||||
qty_test_failed = fields.Float('不合格数')
|
||||
qty_to_test = fields.Float('应检', store=True)
|
||||
qty_tested = fields.Float('已检')
|
||||
qty_tested = fields.Float('已检')
|
||||
|
||||
@api.onchange('qty_line', 'qty_test_failed', 'qty_to_test', 'qty_tested')
|
||||
def _onchage_qty(self):
|
||||
for record in self:
|
||||
if record.qty_line and record.qty_to_test and record.qty_to_test > record.qty_line:
|
||||
record.qty_to_test = record.qty_line
|
||||
return {
|
||||
'warning': {
|
||||
'title': '警告',
|
||||
'message': '待检数量不能超过总数量'
|
||||
}
|
||||
}
|
||||
if record.qty_to_test and record.qty_tested and record.qty_tested > record.qty_to_test:
|
||||
record.qty_tested = record.qty_to_test
|
||||
return {
|
||||
'warning': {
|
||||
'title': '警告',
|
||||
'message': '已检数量不能超过待检数量'
|
||||
}
|
||||
}
|
||||
if record.qty_tested and record.qty_test_failed and record.qty_test_failed > record.qty_tested:
|
||||
record.qty_test_failed = record.qty_tested
|
||||
return {
|
||||
'warning': {
|
||||
'title': '警告',
|
||||
'message': '不合格数量不能超过已检数量'
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user