跳至内容
菜单
此问题已终结
6 回复
31837 查看

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()
形象
丢弃

Did you find the 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

形象
丢弃
编写者

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!

编写者 最佳答案

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.

形象
丢弃
最佳答案

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

@api.model

def create(self, vals):

   if condition:

        return action_wizard


Thanks.

形象
丢弃
相关帖文 回复 查看 活动
2
3月 15
7534
0
3月 15
6986
3
2月 25
57648
2
11月 22
2178
1
3月 15
5982