出厂检验报告发布时二次确认
This commit is contained in:
@@ -141,7 +141,7 @@ class QualityCheck(models.Model):
|
||||
# # 出厂检验报告编号
|
||||
# report_number = fields.Char('出厂检验报告编号', compute='_compute_report_number', readonly=True)
|
||||
# 总数量,值为调拨单_产品明细_数量
|
||||
total_qty = fields.Char('总数量', compute='_compute_total_qty')
|
||||
total_qty = fields.Char('总数量', compute='_compute_total_qty', readonly=False, store=True)
|
||||
|
||||
column_nums = fields.Integer('测量值列数', default=1)
|
||||
|
||||
@@ -281,7 +281,42 @@ class QualityCheck(models.Model):
|
||||
"""
|
||||
pass
|
||||
|
||||
def check_total_quality(self):
|
||||
"""
|
||||
校验总数量是否等于拣货数量
|
||||
"""
|
||||
for record in self:
|
||||
if record.picking_id:
|
||||
for move in record.picking_id.move_ids_without_package:
|
||||
if move.product_id == record.product_id:
|
||||
picking_qty = int(move.product_uom_qty)
|
||||
if int(record.total_qty) != picking_qty:
|
||||
return True
|
||||
return False
|
||||
|
||||
def do_publish(self):
|
||||
"""打开二次确认弹窗"""
|
||||
self.ensure_one()
|
||||
if self.check_total_quality():
|
||||
return self._show_confirmation_wizard()
|
||||
else:
|
||||
return self._do_actual_publish()
|
||||
|
||||
def _show_confirmation_wizard(self):
|
||||
"""显示确认向导的通用方法"""
|
||||
return {
|
||||
'name': _('发布确认'),
|
||||
'type': 'ir.actions.act_window',
|
||||
'res_model': 'quality.check.publish.wizard',
|
||||
'view_mode': 'form',
|
||||
'target': 'new',
|
||||
'context': {
|
||||
'default_check_id': self.id,
|
||||
# 其他默认字段...
|
||||
}
|
||||
}
|
||||
|
||||
def _do_actual_publish(self):
|
||||
"""发布出厂检验报告"""
|
||||
self.ensure_one()
|
||||
self._check_part_number()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from odoo import api, fields, models, _
|
||||
|
||||
|
||||
class QualityCheckPublishWizard(models.TransientModel):
|
||||
_name = 'quality.check.publish.wizard'
|
||||
_description = '质检报告发布确认'
|
||||
@@ -12,9 +13,10 @@ class QualityCheckPublishWizard(models.TransientModel):
|
||||
measure_count = fields.Integer('测量件数', readonly=True)
|
||||
item_count = fields.Integer('检验项目数', readonly=True)
|
||||
old_report_name = fields.Char('旧出厂检验报告编号', readonly=True)
|
||||
publish_status = fields.Selection([('draft', '草稿'), ('published', '已发布'), ('canceled', '已撤销')], string='发布状态', readonly=True)
|
||||
|
||||
publish_status = fields.Selection([('draft', '草稿'), ('published', '已发布'), ('canceled', '已撤销')], string='发布状态',
|
||||
readonly=True)
|
||||
|
||||
def action_confirm_publish(self):
|
||||
"""确认发布"""
|
||||
self.ensure_one()
|
||||
return self.check_id._do_publish_implementation()
|
||||
return self.check_id._do_publish_implementation()
|
||||
|
||||
Reference in New Issue
Block a user