Skip to content

Commit

Permalink
[IMP] new-api-ify 'trigger' server action
Browse files Browse the repository at this point in the history
  • Loading branch information
xmo-odoo committed Oct 8, 2014
1 parent 8cfe731 commit 99d740a
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions openerp/addons/base/ir/ir_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from openerp import SUPERUSER_ID
from openerp import tools
from openerp import workflow
import openerp.api
from openerp.osv import fields, osv
from openerp.osv.orm import browse_record
import openerp.report.interface
Expand Down Expand Up @@ -860,21 +861,14 @@ def run_action_trigger(self, cr, uid, action, eval_context=None, context=None):
- `relational`: find the related model and object, using the relational
field, then target_model_pool.signal_workflow(cr, uid, target_id, <TRIGGER_NAME>)
"""
obj_pool = self.pool[action.model_id.model]
if action.use_relational_model == 'base':
target_id = context.get('active_id')
target_pool = obj_pool
else:
value = getattr(obj_pool.browse(cr, uid, context.get('active_id'), context=context), action.wkf_field_id.name)
if action.wkf_field_id.ttype == 'many2one':
target_id = value.id
else:
target_id = value
target_pool = self.pool[action.wkf_model_id.model]

trigger_name = action.wkf_transition_id.signal

workflow.trg_validate(uid, target_pool._name, target_id, trigger_name, cr)
# weird signature and calling -> no self.env, use action param's
record = action.env[action.model_id.model].browse(context['active_id'])
if action.use_relational_model == 'relational':
record = getattr(record, action.wkf_field_id.name)
if not isinstance(record, openerp.models.BaseModel):
record = action.env[action.wkf_model_id.model].browse(record)

record.signal_workflow(action.wkf_transition_id.signal)

def run_action_multi(self, cr, uid, action, eval_context=None, context=None):
res = False
Expand Down

0 comments on commit 99d740a

Please sign in to comment.