添加发布前校验数据
This commit is contained in:
@@ -232,6 +232,8 @@ class QualityCheck(models.Model):
|
|||||||
def do_publish(self):
|
def do_publish(self):
|
||||||
"""发布出厂检验报告"""
|
"""发布出厂检验报告"""
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
|
self._check_measure_line()
|
||||||
|
self._check_check_qty_and_total_qty()
|
||||||
|
|
||||||
# 1. 获取报告动作
|
# 1. 获取报告动作
|
||||||
report_action = self.env.ref('sf_quality.action_report_quality_inspection')
|
report_action = self.env.ref('sf_quality.action_report_quality_inspection')
|
||||||
@@ -294,6 +296,26 @@ class QualityCheck(models.Model):
|
|||||||
# 返回成功消息
|
# 返回成功消息
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
# 发布前校验明细行列均非空
|
||||||
|
def _check_measure_line(self):
|
||||||
|
for record in self:
|
||||||
|
if not record.measure_line_ids:
|
||||||
|
raise UserError(_('请先添加测量明细'))
|
||||||
|
for line in record.measure_line_ids:
|
||||||
|
if not line.measure_item:
|
||||||
|
raise UserError(_('有检测项目值为空'))
|
||||||
|
for i in range(1, record.column_nums + 1):
|
||||||
|
if not getattr(line, f'measure_value{i}'):
|
||||||
|
raise UserError(_('有测量值为空'))
|
||||||
|
|
||||||
|
|
||||||
|
# 发布前校验检验数与总数量、检验数与测量件数(即测量列数)
|
||||||
|
def _check_check_qty_and_total_qty(self):
|
||||||
|
for record in self:
|
||||||
|
if int(record.check_qty) <= int(record.total_qty):
|
||||||
|
raise UserError(_('检验数不可超过总数量'))
|
||||||
|
if int(record.column_nums) >= int(record.check_qty):
|
||||||
|
raise UserError(_('测量件数不可超过检验数'))
|
||||||
|
|
||||||
def do_cancel_publish(self):
|
def do_cancel_publish(self):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user