微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

从向导传递上下文奥多14

如何解决从向导传递上下文奥多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 举报,一经查实,本站将立刻删除。