콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
6 답글
31942 화면

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
7631
0
3월 15
7095
3
2월 25
57785
2
11월 22
2273
1
3월 15
6084