调整数据类型

This commit is contained in:
mgw
2025-03-17 09:12:44 +08:00
parent 71e79502f9
commit 561b515242
2 changed files with 7 additions and 5 deletions

View File

@@ -157,7 +157,7 @@ class QualityCheck(models.Model):
record.total_qty = ''
# 检验数
check_qty = fields.Char('检验数', default=lambda self: self._get_default_check_qty())
check_qty = fields.Integer('检验数', default=lambda self: self._get_default_check_qty())
def _get_default_check_qty(self):
"""根据条件设置检验数的默认值"""
@@ -173,9 +173,9 @@ class QualityCheck(models.Model):
def _onchange_check_qty(self):
"""当测试类型或测量对象变化时,更新检验数"""
if self.measure_on == 'product' and self.test_type_id.name == '出厂检验报告':
self.check_qty = ''
self.check_qty = 0
elif self.measure_on == 'product':
self.check_qty = '1'
self.check_qty = 1
# 出厂检验报告编号
report_number_id = fields.Many2one('documents.document', string='出厂检验报告编号', readonly=True)
@@ -364,9 +364,9 @@ class QualityCheck(models.Model):
raise UserError(_('请先输入检验数'))
if not record.total_qty:
raise UserError(_('总数量不能为空'))
if int(record.check_qty) <= int(record.total_qty):
if record.check_qty <= int(record.total_qty):
raise UserError(_('检验数不可超过总数量'))
if int(record.column_nums) >= int(record.check_qty):
if record.column_nums >= record.check_qty:
raise UserError(_('测量件数不可超过检验数'))
def do_cancel_publish(self):