Skip to content

Instantly share code, notes, and snippets.

@danypr92
Created September 4, 2018 11:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danypr92/d37c1eeefcc2907535bb3ef9e2739805 to your computer and use it in GitHub Desktop.
Save danypr92/d37c1eeefcc2907535bb3ef9e2739805 to your computer and use it in GitHub Desktop.
Pruebas con celery-tryton

Try celery-tryton 0.3

  • My tasks file:
  from celery import Celery
  from celery_tryton import TrytonTask
  from trytond.transaction import Transaction
  
  celery = Celery('tryton')
  celery.conf.TRYTON_DATABASE = 'tryton'                                                                                              
  
  
  @celery.task(base=TrytonTask)
  def create_ticket(client, contract, ticket_factory):
      ticket_create_rs = client.ticket_create(
          ticket=ticket_factory.build(),
          article=ticket_factory.build_article(),
          dynamic_fields=ticket_factory.build_dynamic_fields())
      if ticket_create_rs:
          econtract._save_ticket_number_ticket_id(ticket_create_rs)
  • Traceback:
Traceback (most recent call last):
  File "/opt/eticom/trytond/trytond/protocols/dispatcher.py", line 162, in dispatch
    result = rpc.result(meth(*c_args, **c_kwargs))
  File "/opt/eticom/trytond/trytond/model/modelview.py", line 617, in wrapper
    return func(cls, *args, **kwargs)
  File "/opt/eticom/trytond/trytond/model/workflow.py", line 33, in wrapper
    result = func(cls, filtered, *args, **kwargs)
  File "/opt/eticom/trytond/trytond/modules/eticom/eticom_contract.py", line 616, in done
    econtract.create_otrs_process_ticket()
  File "/opt/eticom/trytond/trytond/modules/eticom/eticom_contract.py", line 739, in create_otrs_process_ticket
    ticket_factory=ticket_factory)
  File "/home/tryton/.virtualenvs/tryton/local/lib/python2.7/site-packages/celery/local.py", line 191, in __call__
    return self._get_current_object()(*a, **kw)
  File "/home/tryton/.virtualenvs/tryton/local/lib/python2.7/site-packages/celery_tryton.py", line 71, in __call__
    with Transaction().start(database, 0):
  File "/opt/eticom/trytond/trytond/transaction.py", line 76, in start
    assert self.user is None
AssertionError
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment