Odoo Help


How to delete current record in server action?

on 5/12/15, 4:51 AM 1,981 views

I have installed crm_helpdesk and it's working great, when a new emai arrives it creates the help desk ticket correctly. Now i want to check the email_from field for check if the address is in a list. If the address is in a list i want to delete the help-desk record.

I tried to make a action server with the next python code:

# Available locals:
# - time, datetime, dateutil: Python libraries
# - env: Odoo Environement
# - model: Model of the record on which the action is triggered
# - object: Record on which the action is triggered if there is one, otherwise None
# - workflow: Workflow engine
# - Warning: Warning Exception to use with raise
# To return an action, assign: action = {...}
# Search if the field "object.email_from" contains the string in items of spam[]
# Note: object.email_from can be: "Example" <members@news.thisisspam.com> is for this
# reason that we use find method while iterating all elements. In spam we store only
# mail addresses and object.email contains the name (Example) and addresses are
# enclosed in "<>"

spam = ["members@news.thisisspam.com"]
for item in spam:   
    if item.find(object.email_from) != -1:
         self.search([('ID', '=', object.id)]).unlink()

but this seems don't work....i changed the last line for object.unlink() with no result, the tickets from these addresses are always created .

It's possible delete the record from the action server code?

Any suggestions to debug the server action code are too appreciated

Thanks in advance.


Jérémy Kersten (jke)

--Jérémy Kersten (jke)--

| 3 3 5
Jodoigne, Belgium
--Jérémy Kersten (jke)--

Jérémy is a member of the core R&D team since september 2013. He developed several projects for OpenERP version 8 including the eCommerce, the Google Calendar synchronization and the new product variants/configurator. Now, he manages Odoo website and themes for saas.

Jérémy Kersten (jke)
On 5/12/15, 12:59 PM


why not simply:

if object.email_from in spam: 

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)


Asked: 5/12/15, 4:51 AM
Seen: 1981 times
Last updated: 5/15/15, 7:54 PM