← Back to team overview

c2c-oerpscenario team mailing list archive

[Bug 819872] Re: server actions of type "trigger" cause crashes

 

** Branch linked: lp:~openerp-dev/openobject-server/trunk-bug-819872

-- 
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to the OpenERP Project Group.
https://bugs.launchpad.net/bugs/819872

Title:
  server actions of type "trigger" cause crashes

Status in OpenERP Server:
  New

Bug description:
  Hi!

  I create two objects, A and B. A has a many2one field to B called
  B_id.

  A and B have an associated workflow each. I want a transition on B's
  workflow to be triggered by a modification on the workflow of A.

  Here is the server action I created for this purpose:

          <record id="ir_actions_server_confirmB" model="ir.actions.server">
              <field name="trigger_obj_id" ref="mymodule.field_mymodule_A_B_id"/>
              <field name="wkf_model_id" ref="mymodule.model_mymodule_B"/>
              <field name="state">trigger</field>
              <field name="type">ir.actions.server</field>
              <field name="model_id" ref="mymodule.model_mymodule_A"/>
              <field name="trigger_name">mymodule.B</field>
              <field name="condition">True</field>
              <field name="name">Confirm B</field>
          </record>

  
  Remark: the line <field name="trigger_name">mymodule.B</field> already seems strange, but I have no choice (and it was generated like that by the module recorder); see infra for details.

  
  Then I add this in the definition of one of the activities of A's workflow (call it "A_Act"):

              <field name="action_id" model="ir.actions.server"
                     ref="ir_actions_server_confirmB"/>

  Then I run the server. I create a record of type "A". Its "B_id" field references a B record already created; for the sake of the example, let us assume that this record has the id "2" and its field "name" has the value "B_Name".
  In summary :
     A instance: {"B_id":2}
     B instance: {"id":9 , "name":"B_Name"}

  I trigger the transitions on A's workflow until the moment I reach the
  activity "A_Act".

  At this moment I get the following error:

  TypeError: int() argument must be a string or a number, not 'tuple'
  > /home/fde/repository/openobject-server_trunk/openerp/addons/base/ir/ir_actions.py(666)run()
  -> wf_service.trg_validate(uid, model, int(id), action.trigger_name, cr)
  (Pdb) model
  u'mymodule.B'
  (Pdb) id
  (2, u'B_Name')
  (Pdb)

  I managed to get no error when I modified  "int(id)" to "int(id[0])".

  However it still does not work because there is something wrong in the
  definition of the server action. That is the following function (line
  436):

  def _select_signals(self, cr, uid, context=None):
          cr.execute("SELECT distinct w.osv, t.signal FROM wkf w, wkf_activity a, wkf_transition t \
          WHERE w.id = a.wkf_id  AND t.act_from = a.id OR t.act_to = a.id AND t.signal!='' \
          AND t.signal NOT IN (null, NULL)")
          result = cr.fetchall() or []
          res = []
          for rs in result:
              if rs[0] is not None and rs[1] is not None:
                  line = rs[0], "%s - (%s)" % (rs[1], rs[0])
                  res.append(line)
          return res

  And the field "trigger_name" is defined as follows:

  'trigger_name': fields.selection(_select_signals, ...........

  Of course, the value of the selection will be something like [('osv object','signal')] but it should be the opposite!!! The signal is not
   "mymodule.B" but well something like "signal_confirm_B".

  And indeed, I confirm it works if I write "SELECT distinct
  t.signal,w.osv..." instead. Of course, I also changed my server
  action:

              <field name="trigger_name">signal_name</field>

  instead of
              <field name="trigger_name">mymodule.B</field>


  trunk rev 3524

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-server/+bug/819872/+subscriptions


References