Email actions sends outdated data

Bug #801540 reported by Yann Papouin
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Released
Low
OpenERP R&D Addons Team 1

Bug Description

With OpenERP 6.0.2 and automated actions from CRM module.

I planned to automatically send an email after each record changes.
When i click on "Save" an email is sent with my object data at state "n-1".

For example with a crm.helpdesk object named "Record number one"
I change its name property with "Record number two" and click on "Save" then an email is sent, and in this one the [[object]] is always at the "n" state so the [[object.name]] property shows "Record number one".

It looks like the mail is sent before the database update.

Related branches

Revision history for this message
Amit Parik (amit-parik) wrote :

Hello Yann,

I have checked your bug report. But I did not get totally it.

How you configure your base action rule?

So would you please provide me a proper steps on this or provide me a more information.

Thanks and waiting for your reply!

Changed in openobject-addons:
status: New → Incomplete
Revision history for this message
Yann Papouin (yann-papouin) wrote :

Install CRM Modules + Helpdesk

Create a new automated action and just fill following fields

1 - Tab "Conditions"
  Rule name : "My game, my rules"
  Object : "Helpdesk"

2 - Tab "Email Actions"
  Email From : "<email address hidden>" (nb: double quotes are mandatory here)
  Email To : "<email address hidden>" (nb: double quotes are mandatory here)
  Body : Fill text data with keywords

3 - Create a new helpdesk report with query text set to "My request 001"
  Check your mail box, you should receive an email with data of the object (state n)

4 - Edit the same helpdesk and change the query text to "My request 002"
  Check your mail box, you should receive an email with OLD data of the object (My request 001) (state n-1)

5 - Edit the same helpdesk and just press SAVE
  Check your mail box, you should receive an email with OLD data of the object (My request 002) (state n-1)

Revision history for this message
Yann Papouin (yann-papouin) wrote :

Ok I found the problem, the old_write method was called after the action one, that's why data were outdated in WRITE and not in CREATE.

See attachment!

Changed in openobject-addons:
status: Incomplete → Confirmed
Revision history for this message
Amit Parik (amit-parik) wrote :

Hello Yann,

Thanks for your reply and good explanation.

Now I have faced the same problem at my end So I am confirming this issue also I have faced one another issue in trunk only.

@RD Team:

Would you please check the following issue also.

When I have set a email form or email to without "" or '' and then I am trying to change the state of the helpdesk like open the helpdesk I have faced the following trace-back on server side.

Traceback (most recent call last):
  File "/home/amp/workspace/trunk6/server/openerp/osv/osv.py", line 118, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/home/amp/workspace/trunk6/server/openerp/osv/osv.py", line 172, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/home/amp/workspace/trunk6/server/openerp/osv/osv.py", line 163, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/home/amp/workspace/trunk6/addons/crm/crm.py", line 431, in case_close
    'date_closed': time.strftime('%Y-%m-%d %H:%M:%S'),
  File "/home/amp/workspace/trunk6/addons/base_action_rule/base_action_rule.py", line 187, in make_call_old
    self.pre_action(cr, uid, ids, model, context=context)
  File "/home/amp/workspace/trunk6/addons/base_action_rule/base_action_rule.py", line 165, in pre_action
    self._action(cr, uid, [rule_id], obj.browse(cr, uid, ids, context=context), context=context)
  File "/home/amp/workspace/trunk6/addons/base_action_rule/base_action_rule.py", line 459, in _action
    self.do_action(cr, uid, action, model_obj, obj, context)
  File "/home/amp/workspace/trunk6/addons/crm/crm_action_rule.py", line 105, in do_action
    res = super(base_action_rule, self).do_action(cr, uid, action, model_obj, obj, context=context)
  File "/home/amp/workspace/trunk6/addons/base_action_rule/base_action_rule.py", line 421, in do_action
    emails.append(safe_eval(action.act_email_to, {}, locals_for_emails))
  File "/home/amp/workspace/trunk6/server/openerp/tools/safe_eval.py", line 286, in safe_eval
    return eval(test_expr(expr,_SAFE_OPCODES, mode=mode), globals_dict, locals_dict)
  File "/home/amp/workspace/trunk6/server/openerp/tools/safe_eval.py", line 105, in test_expr
    code_obj = compile(expr, "", mode)
  File "<string>", line 1
     <email address hidden>
        ^
 SyntaxError: invalid syntax

So would you please also check this issue also as well as above posted issue.

Thanks.

Changed in openobject-addons:
assignee: nobody → OpenERP R&D Addons Team 1 (openerp-dev-addons1)
importance: Undecided → Low
Revision history for this message
Yann Papouin (yann-papouin) wrote :

Look at my last comment in bug#689576:

The message error (SyntaxError: invalid syntax) appeared because you have to embed all emails with double quotes:

Changed in openobject-addons:
status: Confirmed → In Progress
Revision history for this message
DBR (OpenERP) (dbr-openerp) wrote :

Hello Yann,

Thanks for the Patch.
Its fixed in lp:~openerp-dev/openobject-addons/trunk-bug-801540-dbr
branch. It will be merge soon with trunk addons.

Revision ID : 4900 <email address hidden>
Revision No: 4900

Thanks.

Changed in openobject-addons:
status: In Progress → Fix Committed
Revision history for this message
Yann Papouin (yann-papouin) wrote :

Hello,

Why didn't you removed the context part like I did in the patch? I think that this code is useless because already executed before the def:

  if context is None:
    context = {}

Revision history for this message
Vo Minh Thu (thu) wrote :

The fix is available in trunk. Thanks a lot for the explanation and the bug report!
revno: 5673
revision-id: <email address hidden>

Changed in openobject-addons:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.