33 lines
1.3 KiB
Python
33 lines
1.3 KiB
Python
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()
|