Skip to Content
Menu
This question has been flagged
2 Replies
1255 Views

I´m trying to create a new ticket, with information of a webhook, I verify that I just neet the field name to create, in logs I don't have any mistake. I saw this helpful video and I can create new contacts but I can't create the ticket https://www.youtube.com/watch?v=D3urHJ9rB2o

Payload

​Webhook #82 triggered with payload {'name': 'NAME OF HELPDESK TICKET FROM ​WEBHOOK'}


Python code
vals = {'name': payload.get('name')  }
env['helpdesk.ticket'].create(vals)


Target record field: []


Avatar
Discard
Best Answer

Hi,
Set target record as:  model.search([], limit=1) and model as automation rule and try.

Update:
there were a bug in the core and it has been resolved and now you will be able to create the ticket without any issues.

FIX: [FIX] base_automation: prevent crash when writing on tracked fields



Create record using webhook:  https://www.youtube.com/watch?v=D3urHJ9rB2o&t=34s


Thanks

Avatar
Discard
Author Best Answer

Yes i tried it, like the video, model is set as automation rule, but if i set target record as:  model.search([], limit=1), I have the following mistake in logs:

Webhook #82 failed with error:


Traceback (most recent call last):

  File "/home/odoo/src/odoo/17.0/odoo/models.py", line 5854, in ensure_one

    _id, = self._ids

ValueError: not enough values to unpack (expected 1, got 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "/home/odoo/src/odoo/17.0/odoo/tools/safe_eval.py", line 391, in safe_eval

    return unsafe_eval(c, globals_dict, locals_dict)

  File "ir.actions.server(1416,)", line 24, in

  File "", line 2, in create

  File "/home/odoo/src/odoo/17.0/odoo/api.py", line 414, in _model_create_multi

    return create(self, [arg])

  File "/home/odoo/src/enterprise/17.0/helpdesk_sms/models/helpdesk_ticket.py", line 17, in create

    tickets = super().create(vals_list)

  File "", line 2, in create

  File "/home/odoo/src/odoo/17.0/odoo/api.py", line 415, in _model_create_multi

    return create(self, arg)

  File "/home/odoo/src/enterprise/17.0/helpdesk/models/helpdesk_ticket.py", line 493, in create

    tickets = super(HelpdeskTicket, self).create(list_value)

  File "", line 2, in create

  File "/home/odoo/src/odoo/17.0/odoo/api.py", line 415, in _model_create_multi

    return create(self, arg)

  File "/home/odoo/src/odoo/17.0/addons/mail/models/mail_thread.py", line 285, in create

    thread.sudo().message_post(subtype_id=subtype.id, author_id=self.env.user.partner_id.id)

  File "/home/odoo/src/odoo/17.0/addons/sms/models/mail_thread.py", line 135, in message_post

    return super().message_post(*args, body=body, message_type=message_type, **kwargs)

  File "/home/odoo/src/odoo/17.0/addons/rating/models/mail_thread.py", line 178, in message_post

    message = super(MailThread, self).message_post(**kwargs)

  File "/home/odoo/src/odoo/17.0/addons/mail/models/mail_thread.py", line 2136, in message_post

    if self.env.user._is_public() and guest:

  File "/home/odoo/src/odoo/17.0/odoo/addons/base/models/res_users.py", line 1156, in _is_public

    self.ensure_one()

  File "/home/odoo/src/odoo/17.0/odoo/models.py", line 5857, in ensure_one

    raise ValueError("Expected singleton: %s" % self)

ValueError: Expected singleton: res.users()

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "/home/odoo/src/odoo/17.0/addons/base_automation/models/base_automation.py", line 509, in _execute_webhook

    return self._process(record)

  File "/home/odoo/src/odoo/17.0/addons/base_automation/models/base_automation.py", line 671, in _process

    action.with_context(**ctx).run()

  File "/home/odoo/src/odoo/17.0/odoo/addons/base/models/ir_actions.py", line 941, in run

    res = runner(run_self, eval_context=eval_context)

  File "/home/odoo/src/odoo/17.0/addons/website/models/ir_actions_server.py", line 61, in _run_action_code_multi

    res = super(ServerAction, self)._run_action_code_multi(eval_context)

  File "/home/odoo/src/odoo/17.0/odoo/addons/base/models/ir_actions.py", line 771, in _run_action_code_multi

    safz_eval(self.code.strip(), eval_context, mode="exec", nocopy=True, filename=str(self))  # nocopy allows to return 'action'

  File "/home/odoo/src/odoo/17.0/odoo/tools/safe_eval.py", line 405, in safe_eval

    raise ValueError('%s: "%s" while evaluating\n%r' % (ustr(type(e)), ustr(e), expr))

ValueError: : "Expected singleton: res.users()" while evaluating

"# Available variables:\n#  - env: environment on which the action is triggered\n#  - model: model of the record on which the action is triggered; is a void recordset\n#  - record: record on which the action is triggered; may be void\n#  - records: recordset of all records on which the action is triggered in multi-mode; may be void\n#  - time, datetime, dateutil, timezone: useful Python libraries\n#  - float_compare: utility function to compare floats based on specific precision\n#  - log: log(message, level='info'): logging function to record debug information in ir.logging table\n#  - _logger: _logger.info(message): logger to emit messages in server logs\n#  - UserError: exception class for raising user-facing warning messages\n#  - Command: x2many commands namespace\n# To return an action, assign: action = {...}\n\n\n# Datos del payload\nvals = {\n    'name': payload.get('name')  # Obtiene el nombre del payload\n    #'x_studio_selection_field_1ki_1hl8rqemp':'status1'\n\n}\n\n# Crea el ticket en el modelo helpdesk.ticket\n#env['helpdesk.ticket'].create(vals),\nenv['helpdesk.ticket'].create(vals)"

Avatar
Discard

resolved the issue in odoo and now all will be fine

Related Posts Replies Views Activity
0
Mar 25
331
0
Oct 24
532
1
Sep 24
665
1
Aug 24
802
1
Jul 24
718