Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

2

Run a wizard from python code or as a return of a function

By
Jose F
on 4/3/13, 7:18 AM 6,448 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()

Did you find the answer?

Versão Integral, Anabela Damas
on 2/4/14, 2:24 PM
4

Parth Gajjar

--Parth Gajjar--
1484
| 3 3 5
Ahmadabad, India
--Parth Gajjar--
Parth Gajjar
On 4/3/13, 8:11 AM

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.

Jose F
on 4/4/13, 8:10 AM

can you post the view in xml please!

voathnak lim
on 5/16/13, 7:18 AM
0
Omar OUHARI
On 4/17/16, 12:53 PM

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

@api.model

def create(self, vals):

   if condition:

        return action_wizard


Thanks.

0
Jose F
On 4/4/13, 8:10 AM

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.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

3 follower(s)

Stats

Asked: 4/3/13, 7:18 AM
Seen: 6448 times
Last updated: 4/17/16, 12:53 PM