Skip to Content
Menu
This question has been flagged
6 Replies
31387 Views

I need run a wizard from python code or as a return of a python function. I need that when finish a production order skip automatically one wizard but does nothing, only print the wizard_id. Any idea? It's possible?

class mrp_production_workcenter_line(osv.osv):

    _inherit = 'mrp.production.workcenter.line'

    def show_wizard(self, cr, uid, ids):

        qc_id = self.pool.get('mrp.production.workcenter.line').browse(cr,uid,ids[0]).qc_id.id
        context={
                 'qc_id':qc_id,
                 'operation_id':ids[0]
                 }       
        wizard_id = self.pool.get("kms.qc.name.wiz").create(cr,uid,{}, context=dict(context, active_ids=ids))

        print 'wizard_id : ', wizard_id

        return {
            'name':_("Quality Control"),
            'view_mode': 'form',
            'view_type': 'form',
            'view_id': False,
            #'model': 'kms.qc.name.wiz',
            'res_model': 'kms.qc.name.wiz',
            'res_id':wizard_id,
            'type': 'ir.actions.act_window',
            'nodestroy': True,
            'target': 'new',
            'domain': '[]',
            'context': dict(context, active_ids=ids)
        }


    def action_done(self, cr, uid, ids):
        """ Sets state to done, writes finish date and calculates delay.
        @return: True
        """
        super(mrp_production_workcenter_line,self).action_done(cr, uid, ids)
        return self.show_wizard(cr,uid,ids)


mrp_production_workcenter_line()
Avatar
Discard

Did you find the answer?

Best Answer

Do this with Proper Return

  #first fatch wizard view id 
  dummy, view_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'your_model', 'your_wizard_view_id') #in model name replace . with _ Example sale.order become sale_order


  return {
        'name':_("Display Name"),#Name You want to display on wizard
        'view_mode': 'form',
        'view_id': view_id
        'view_type': 'form',
        'res_model': 'object name',# With . Example sale.order
        'type': 'ir.actions.act_window',
        'target': 'new',
        'domain': '[if you need]',
        'context': {'if you need'}
    }

Hope this will help

Avatar
Discard
Author

Thanks but does nothing. If I put a button on the tree of mrp -> mrp.production.workcenter.line.tree and I pass in the context the qc_id and click them, the wizard displays correctly but I can't get it to display automatically when the operation switches to "done". I don't understand why not it show and no show any error.

can you post the view in xml please!

Author Best Answer

Thanks but does nothing. If I put a button on the tree of mrp -> mrp.production.workcenter.line.tree and I pass in the context the qc_id and click them, the wizard displays correctly but I can't get it to display automatically when the operation switches to "done". I don't understand why not it show and no show any error.

Avatar
Discard
Best Answer

It's possible to return a wizard in create method.

@api.model

def create(self, vals):

   if condition:

        return action_wizard


Thanks.

Avatar
Discard
Related Posts Replies Views Activity
2
Mar 15
7135
0
Mar 15
6412
3
Feb 25
57038
2
Nov 22
1801
1
Mar 15
5555