This question has been flagged
2 Replies
3937 Views

Hi,

I'm trying to get the mail address from the object "user_id" in Odoo V12 inside the HelpDesk section - unfortunately without success.

My object:

field: user_id
object: helpdesk.ticket
type: many2one
domain: [["groups_id,"in",<int>]]
by changes 1
relation: res.users

I need the mail address from the user which you can see as highlighted in this screenshot:

https://imgur.com/g1aSDQu
(sorry don't know how or if its possible anyway to embed images)

I have tried to get the mail address with this kind of parameter:

${object.user_id.email}​

Can anybody please help me?
Thanks.

EDIT: 

I have found that ${object.user_id.email} is "working" as it should, but I'm facing the issue, that it's not happening within the context by which actual ticket the automated task is triggered.

So in detail it's not defined which ticket should be used and therefore just always the first ticket which suits the requirements is used.

Can may someone explain me how to pass this kind of context data to the automated task which is triggering the mail?


Avatar
Discard
Author Best Answer

@Paresh Wagh,

thanks for the answer. I'm trying to test it, but I'm receiving another issue right now. I have only deleted an old ticket from which the automation has always collected the data, so I wanted to try what's happening if this ticket do not exist anymore (to see if just the next ticket with the next ID will be catched).

So now I'm getting this error message (if I try to create a new ticket or by trying to change the assignment from an existing ticket):

Fehler beim Erstellen der Vorlage <Template memory:7f43f8709fd0> mit den Werten {'format_date': <function MailTemplate._render_template.<locals>.<lambda> at 0x7f43f82cbae8>, 'format_tz': <function MailTemplate._render_template.<locals>.<lambda> at 0x7f43f82cb510>, 'format_amount': <function MailTemplate._render_template.<locals>.<lambda> at 0x7f43f82cb268>, 'user': res.users(2,), 'ctx': {'lang': 'de_DE', 'tz': 'Europe/Berlin', 'uid': 2, 'active_model': 'helpdesk.ticket', 'active_id': 5, 'active_ids': [5], 'search_default_team_id': 5, 'search_disable_custom_filters': True, 'default_team_id': 5, 'onchange_self': helpdesk.ticket(<odoo.models.NewId object at 0x7f43f74f5228>,), 'mail_notify_force_send': False, 'safe': True}, 'object': helpdesk.ticket(5,)}  

Avatar
Discard
Best Answer

Hi Lukas:

You need to get the email from the related partner record in this case.

Try this instead: 

${object.user_id.partner_id.email}​


Avatar
Discard