signals - Activate a workflow transition from wizard in OpenERP 7.0 -


i've set wizard in openerp 7.0 updating fields correctly , working fine. send signal workflow wizard after user submits information check if there transition taken.

my wizard code following:

from openerp.osv import osv openerp.osv import fields openerp.tools.translate import _  class ref_generic_request(osv.osv_memory):     _name='ref.generic.request'      _columns = {         'reformulation_info': fields.text('reformulation instructions', help='instructions requestor justification reformulation needs'),             }       def save_info(self, cr, uid, ids, context=none):         if 'active_id' in context:             info=self.browse(cr,uid,ids)[0].reformulation_info             self.pool.get('generic.request').write(cr,uid,context['active_id'],{'reformulation_info' : info, 'needs_reformulation': 1})         return {                 'type': 'ir.actions.act_window_close',          } ref_generic_request() 

and in particular case signal function in generic.request object:

def req_reformulate_request(self, cr, uid, ids, context=none):     req = self.browse(cr, uid, ids, context=context)     goto = req[0].state     if goto:         self.write(cr, uid, ids, {'goto': goto, 'state': 'req_reformulation', 'needs_reformulation': true} )     else:         self.write(cr, uid, ids, {'state': 'req_reformulation', 'needs_reformulation': true})     self.insert_trace(cr, uid, ids, context)     return true 

how should that?

do have call function inside def save_info()? (i've tried call self.pool.get('generic.request').req_reformulate_request(cr, uid, context['active_id'], context) throws many errors, gave approach)

do have return 'signal': 'generic.request.req_reformulate_request' ? since didn't find information on this, i'm lost here, appreciated!

thanks!

here workflow definition:

<?xml version="1.0"?> <openerp>     <data>         <record model="workflow" id="wkf_request">             <field name="name">request.wkf</field>             <field name="osv">generic.request</field>             <field name="on_create">true</field>         </record>          <!-- actividades -->         <record model="workflow.activity" id="act_draft">             <field name="wkf_id" ref="wkf_request" />             <field name="flow_start">true</field>             <field name="name">request_draft</field>             <field name="kind">function</field>             <field name="action">request_draft()</field>         </record>          <record model="workflow.activity" id="act_submit">             <field name="wkf_id" ref="wkf_request" />             <field name="name">request_submitted</field>             <field name="kind">function</field>             <field name="action">submit_request()</field>         </record>          <record model="workflow.activity" id="act_confirm">             <field name="wkf_id" ref="wkf_request" />             <field name="name">request_confirmed</field>             <field name="kind">function</field>             <field name="action">confirm_request()</field>         </record>          <record model="workflow.activity" id="act_closed_nconf">             <field name="wkf_id" ref="wkf_request" />             <field name="name">request_closed_nconf</field>             <field name="action_id" ref="ir_actions_server_send_email_when_closed_nconf"/>             <field name="kind">function</field>             <field name="action">close_nconf_request()</field>             <field name="flow_stop">true</field>         </record>          <record model="workflow.activity" id="act_req_reformulate">             <field name="wkf_id" ref="wkf_request" />             <field name="name">request_reformulation</field>             <field name="kind">function</field>             <field name="action">req_reformulate_request()</field>         </record>          <record model="workflow.activity" id="act_treatment">             <field name="wkf_id" ref="wkf_request" />             <field name="name">request_treatment</field>             <field name="kind">function</field>             <field name="action">treat_request()</field>         </record>          <record model="workflow.activity" id="act_taken">             <field name="wkf_id" ref="wkf_request" />             <field name="name">request_take</field>             <field name="kind">function</field>             <field name="action">take_request()</field>         </record>          <record model="workflow.activity" id="act_given">             <field name="wkf_id" ref="wkf_request" />             <field name="name">request_give</field>             <field name="kind">function</field>             <field name="action">give_request()</field>         </record>          <record model="workflow.activity" id="act_closed">             <field name="wkf_id" ref="wkf_request" />             <field name="name">request_closed</field>             <field name="kind">function</field>             <field name="action">close_request()</field>             <field name="flow_stop">true</field>         </record>          <record model="workflow.activity" id="act_awaiting_auth">             <field name="wkf_id" ref="wkf_request" />             <field name="name">request_awaiting_authorization</field>             <field name="kind">function</field>             <field name="action">wait_auth_request()</field>         </record>          <record model="workflow.activity" id="act_closed_ref">             <field name="wkf_id" ref="wkf_request" />             <field name="name">request_closed_ref</field>             <field name="kind">function</field>             <field name="action">close_ref_request()</field>             <field name="flow_stop">true</field>         </record>          <record model="workflow.activity" id="act_awaiting_appr">             <field name="wkf_id" ref="wkf_request" />             <field name="name">request_awainting_approval</field>             <field name="kind">function</field>             <field name="action">wait_appr_request()</field>         </record>          <record model="workflow.activity" id="act_closed_disappr">             <field name="wkf_id" ref="wkf_request" />             <field name="name">request_closed_disappr</field>             <field name="kind">function</field>             <field name="action">close_disappr_request()</field>             <field name="flow_stop">true</field>         </record>         <!-- transições -->         <record model="workflow.transition" id="request_t1">             <field name="act_from" ref="act_draft" />             <field name="act_to" ref="act_submit" />             <field name="signal">submit_request</field>         </record>         <!--         <record model="workflow.transition" id="request_t101">             <field name="act_from" ref="act_draft" />             <field name="act_to" ref="act_confirm" />             <field name="signal">submit_request</field>             <field name="condition">check_responsible()</field>         </record>         -->          <record model="workflow.transition" id="request_t102">             <field name="act_from" ref="act_submit" />             <field name="act_to" ref="act_confirm" />             <field name="condition">check_responsible()</field>         </record>          <record model="workflow.transition" id="request_t2">             <field name="act_from" ref="act_submit" />             <field name="act_to" ref="act_req_reformulate" />             <field name="signal">req_reformulate_request</field>         </record>          <record model="workflow.transition" id="request_t3">             <field name="act_from" ref="act_req_reformulate" />             <field name="act_to" ref="act_submit" />             <field name="signal">submit_request</field>         </record>          <record model="workflow.transition" id="request_t1001">             <field name="act_from" ref="act_submit" />             <field name="act_to" ref="act_confirm" />             <field name="condition">ref_goto_confirmed()</field>         </record>          <record model="workflow.transition" id="request_t1002">             <field name="act_from" ref="act_submit" />             <field name="act_to" ref="act_treatment" />             <field name="condition">ref_goto_treatment()</field>         </record>           <record model="workflow.transition" id="request_t4">             <field name="act_from" ref="act_submit" />             <field name="act_to" ref="act_confirm" />             <field name="signal">confirm_request</field>         </record>          <record model="workflow.transition" id="request_t5">             <field name="act_from" ref="act_submit" />             <field name="act_to" ref="act_closed_nconf" />             <field name="signal">close_nconf_request</field>         </record>          <record model="workflow.transition" id="request_t6">             <field name="act_from" ref="act_confirm" />             <field name="act_to" ref="act_treatment" />             <field name="signal">treat_request</field>         </record>          <record model="workflow.transition" id="request_t7">             <field name="act_from" ref="act_treatment" />             <field name="act_to" ref="act_closed" />             <field name="signal">close_request</field>         </record>          <record model="workflow.transition" id="request_t7011">             <field name="act_from" ref="act_treatment" />             <field name="act_to" ref="act_taken" />             <field name="signal">take_request</field>         </record>          <record model="workflow.transition" id="request_t7012">             <field name="act_from" ref="act_taken" />             <field name="act_to" ref="act_treatment" />         </record>          <record model="workflow.transition" id="request_t7021">             <field name="act_from" ref="act_treatment" />             <field name="act_to" ref="act_given" />             <field name="signal">give_request</field>         </record>          <record model="workflow.transition" id="request_t7022">             <field name="act_from" ref="act_given" />             <field name="act_to" ref="act_treatment" />         </record>          <record model="workflow.transition" id="request_t8">             <field name="act_from" ref="act_treatment" />             <field name="act_to" ref="act_awaiting_auth" />             <field name="signal">wait_auth_request</field>         </record>          <record model="workflow.transition" id="request_t9">             <field name="act_from" ref="act_awaiting_auth" />             <field name="act_to" ref="act_closed_ref" />             <field name="signal">close_ref_request</field>         </record>          <record model="workflow.transition" id="request_t10">             <field name="act_from" ref="act_awaiting_auth" />             <field name="act_to" ref="act_treatment" />             <field name="signal">auth_send_processing</field>         </record>          <record model="workflow.transition" id="request_t11">             <field name="act_from" ref="act_treatment" />             <field name="act_to" ref="act_req_reformulate" />             <field name="signal">req_reformulate_request</field>         </record>          <record model="workflow.transition" id="request_t12">             <field name="act_from" ref="act_treatment" />             <field name="act_to" ref="act_awaiting_appr" />             <field name="signal">wait_appr_request</field>         </record>          <record model="workflow.transition" id="request_t13">             <field name="act_from" ref="act_awaiting_appr" />             <field name="act_to" ref="act_closed_disappr" />             <field name="signal">close_disappr_request</field>         </record>          <record model="workflow.transition" id="request_t14">             <field name="act_from" ref="act_awaiting_appr" />             <field name="act_to" ref="act_treatment" />             <field name="signal">appr_send_processing</field>         </record>      </data> </openerp> 

the transition want trigger in particular case 1 id="request_t2"

<record model="workflow.transition" id="request_t2">     <field name="act_from" ref="act_submit" />     <field name="act_to" ref="act_req_reformulate" />     <field name="signal">req_reformulate_request</field> </record> 

and here screenshot of workflow, highlighted transition 1 want trigger. enter image description here

i finaly found answer. i'll leave here modified python code made it!

from openerp.osv import osv openerp.osv import fields openerp.tools.translate import _ import netsvc  class ref_generic_request(osv.osv_memory):     _name='ref.generic.request'      _columns = {         'reformulation_info': fields.text('reformulation instructions', help='instructions requestor justification reformulation needs'),             }       def save_info(self, cr, uid, ids, context=none):         if 'active_id' in context:             info=self.browse(cr,uid,ids)[0].reformulation_info             self.pool.get('generic.request').write(cr,uid,context['active_id'],{'reformulation_info' : info, 'needs_reformulation': 1})             wf_service = netsvc.localservice('workflow')             wf_service.trg_validate(uid,'generic.request',context['active_id'],'req_reformulate_request',cr)             return {                 'type': 'ir.actions.act_window_close',           }  ref_generic_request() 

so, resuming, had add 3 lines code: import netsvc

and, after saving info, invoked workflow these two:

wf_service = netsvc.localservice('workflow') wf_service.trg_validate(uid,'generic.request',context['active_id'],'req_reformulate_request',cr) 

hope someone! :)


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -