从向导传递上下文奥多14

问题描述

添加一个带有 2 个按钮“取消”和“确认”的向导模型;在“stock.picking”模型的“button_validate”函数中,如果quantity_done > product_uom_qty,我想生成这个向导,函数cancel将执行button_validate。 单击确认按钮时,我想继续执行“button_validate”功能的其余部分,我该如何使用上下文来执行此操作?有什么帮助吗?

class Wizard(models.TransientModel):
    _name = 'wizard.wizard'

    def confirm(self):
        active_id = self.env['stock.picking'].browse(self.env.context.get('active_id',False))

    def cancel(self):
        picking_id = self.env['stock.picking'].browse(self.env.context.get('active_id',False))
        picking_id.button_validate




class Picking(models.Model):
    _inherit = "stock.picking"

    def button_validate(self,is_active_id=False):
        # Clean-up the context key at validation to avoid forcing the creation of immediate
        # transfers.
        ctx = dict(self.env.context)
        ctx.pop('default_immediate_transfer',None)
        self = self.with_context(ctx)

        # Sanity checks.
        pickings_without_moves = self.browse()
        pickings_without_quantities = self.browse()
        pickings_without_lots = self.browse()
        products_without_lots = self.env['product.product']
        for picking in self:


            for move in picking.move_ids_without_package:
                if move.quantity_done > move.product_uom_qty:
                    action = self.env["ir.actions.actions"]._for_xml_id("my_module.action_of_my_wizard")
                    return action



            if not picking.move_lines and not picking.move_line_ids:
                pickings_without_moves |= picking

            picking.message_subscribe([self.env.user.partner_id.id])
            picking_type = picking.picking_type_id
               ........

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)