Compare commits
2 Commits
feature/66
...
feature/制造
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
65c67775fa | ||
|
|
8f2d214854 |
@@ -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()
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
'views/quality_check_view.xml',
|
||||
'views/quality_company.xml',
|
||||
'wizard/check_picking_wizard_view.xml',
|
||||
'wizard/confirmation_wizard_views.xml',
|
||||
],
|
||||
|
||||
'assets': {
|
||||
|
||||
@@ -74,5 +74,6 @@ access_quality_cnc_test_group_quality_director,quality_cnc_test_group_quality_di
|
||||
access_quality_cnc_test_group_sf_equipment_user,quality_cnc_test_group_sf_equipment_user,model_quality_cnc_test,sf_base.group_sf_equipment_user,1,1,0,0
|
||||
|
||||
access_picking_validate_check_wizard,access.picking_validate_check_wizard,model_picking_validate_check_wizard,quality.group_quality_user,1,1,1,0
|
||||
access_confirmation_wizard,access.confirmation.wizard,model_confirmation_wizard,quality.group_quality_user,1,1,1,0
|
||||
|
||||
|
||||
|
||||
|
@@ -1 +1,2 @@
|
||||
from . import check_picking_wizard
|
||||
from . import confirmation_wizard
|
||||
|
||||
32
sf_quality/wizard/confirmation_wizard.py
Normal file
32
sf_quality/wizard/confirmation_wizard.py
Normal file
@@ -0,0 +1,32 @@
|
||||
from odoo import models, fields, api
|
||||
|
||||
|
||||
class ConfirmationWizard(models.TransientModel):
|
||||
_name = 'confirmation.wizard'
|
||||
_description = '二次确认向导'
|
||||
|
||||
# 可根据需要传递上下文参数
|
||||
check_id = fields.Many2one('quality.check', string='质检单', required=True)
|
||||
picking_name = fields.Char(string='拣货单', related='check_id.picking_id.name', store=True)
|
||||
number = fields.Char(string='数量', related='check_id.total_qty', store=True)
|
||||
picking_num = fields.Integer(string='拣货数量', compute='_compute_picking_num', store=True)
|
||||
|
||||
@api.depends('check_id.picking_id')
|
||||
def _compute_picking_num(self):
|
||||
for record in self.check_id:
|
||||
if record.picking_id:
|
||||
for move in record.picking_id.move_ids_without_package:
|
||||
if move.product_id == record.product_id:
|
||||
self.picking_num = int(move.product_uom_qty)
|
||||
else:
|
||||
self.picking_num = 0
|
||||
|
||||
button_text = fields.Char(string='确认按钮文字')
|
||||
|
||||
def action_confirm(self):
|
||||
self.ensure_one()
|
||||
|
||||
# 获取原始记录
|
||||
check = self.env['quality.check'].browse(self.check_id.id)
|
||||
# 调用实际发布方法
|
||||
return check._do_actual_publish()
|
||||
19
sf_quality/wizard/confirmation_wizard_views.xml
Normal file
19
sf_quality/wizard/confirmation_wizard_views.xml
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="view_confirmation_wizard_form" model="ir.ui.view">
|
||||
<field name="name">confirmation.wizard.form</field>
|
||||
<field name="model">confirmation.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<div class="alert alert-warning">
|
||||
<p>拣货调拨单号<strong><field name="picking_name" class="oe_inline"/></strong>需求数量为<strong><field name="picking_num" class="oe_inline"/></strong>,当前质量检查单产品数量为<strong><field name="number" class="oe_inline"/></strong>,数量不一致,是否确认继续?</p>
|
||||
</div>
|
||||
<footer>
|
||||
<button name="action_confirm" string="确定" type="object" class="btn-primary"/>
|
||||
<button string="取消" class="btn-secondary" special="cancel"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user