Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
      • Get a Tailored Demo
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +32 2 290 34 90
    • Get a Tailored Demo
  • Pricing
  • Help
  1. APPS
  2. Extra Tools
  3. WebService Queue v 13.0
  4. Sales Conditions FAQ

WebService Queue

by Smile http://www.smile.fr
Odoo
v 13.0 Third Party 54
Download for v 13.0 Deploy on Odoo.sh
Apps purchases are linked to your Odoo account, please sign in or sign up first.
Availability
Odoo Online
Odoo.sh
On Premise
Odoo Apps Dependencies Discuss (mail)
Community Apps Dependencies Show
• Import / Export
• Logging in database
Lines of code 1151
Technical Name smile_wsqueue
LicenseAGPL-3
Websitehttp://www.smile.fr
Versions 13.0 17.0 18.0
You bought this module and need support? Click here!

WebService Queue

License: AGPL-3 Smile-SA/odoo_addons

This module adds helpers to implement a queue job.

This adds the mechanism of keeping jobs inside a queue, and treat them one at a time periodically, with a restart policy in case of failures.

You have to define your model with your own method, a cron to execute the jobs in queue, and define views to consult job history.

This module could be greatly improved, feel free to make it better via pull requests.

Table of contents

  • Usage
    • Define your model
    • Execution of queue
    • Consult jobs enqueued
  • Bug Tracker
  • Credits
    • Authors
    • Contributors
    • Maintainers

Usage

Define your model

You have to define a class inheriting from queue.job.

class MyModuleJob(models.Model):
   _name = 'my_module.job'
   _inherit = 'queue.job'

   method = fields.Selection([
      ('foo', 'Method doing foo'),
      ('bar', 'Method doing bar')
   ])

   def foo(self):
      """Execute the job `foo`.
      This could be a button method, a cron method, etc.
      """
      pass

   def bar(self):
      """Execute the job `bar`.
      This could be a button method, a cron method, etc.
      """
      pass

Execution of queue

You have to define a cron to check queue periodically, eg. each 5 minutes:

<record id="some_external_api_queue" model="ir.model.export.template">
   <field name="name">Some external API</field>
   <field name="model_id" ref="my_module.model_my_module_job" />
   <field name="method">execute_call</field>
   <field name="filter_type">method</field>
   <field name="filter_method">filter_jobs</field>
   <field name="unique" eval="False" />
   <field name="new_thread" eval="False" />
   <field name="one_at_a_time" eval="True" />
</record>

<record id="ir_cron_some_external_api_queue" model="ir.cron">
   <field name="name">Some external API - Manage queue</field>
   <field name="user_id" ref="base.user_root" />
   <field name="interval_number">5</field>
   <field name="interval_type">minutes</field>
   <field name="numbercall">-1</field>
   <field name="priority">10</field>
   <field name="nextcall" eval="time.strftime('%Y-%m-%d %H:00:00')" />
   <field name="model_id" ref="my_module.model_my_module_job" />
   <field name="code">model.execute_cron()</field>
   <field name="state">code</field>
</record>

<record id="some_external_api_queue" model="ir.model.export.template">
   <field name="cron_id" ref="ir_cron_some_external_api_queue" />
</record>

Consult jobs enqueued

You have to define views and actions to see your jobs.

Following code displays pending and error jobs by default:

<record id="view_job_form" model="ir.ui.view">
   <field name="name">my_module.job.form</field>
   <field name="model">my_module.job</field>
   <field name="arch" type="xml">
      <form>
         <header>
            <field name="state" widget="statusbar"/>
         </header>
         <sheet>
            <group col="1">
               <field name="method"/>
            </group>
            <group col="6">
               <field name="max_tries"/>
               <field name="tries"/>
               <field name="total_tries"/>
            </group>
            <group>
               <field name="status_code"/>
               <field name="result"/>
            </group>
         </sheet>
      </form>
   </field>
</record>

<record id="view_job_tree" model="ir.ui.view">
   <field name="name">my_module.job.tree</field>
   <field name="model">my_module.job</field>
   <field name="arch" type="xml">
      <tree string="Jobs" decoration-danger="state=='error'"
            decoration-success="state=='done'"
            decoration-muted="state=='canceled'">
         <field name="method" />
         <field name="state" />
         <field name="status_code" />
         <field name="create_date" />
         <field name="execute_date" />
         <field name="total_tries" />
      </tree>
   </field>
</record>

<record id="view_job_search" model="ir.ui.view">
   <field name="name">my_module.job.search</field>
   <field name="model">my_module.job</field>
   <field name="arch" type="xml">
      <search>
         <field name="method" />
         <filter name="filter_canceled" string="Canceled"
            domain="[('state', '=', 'canceled')]" />
         <filter name="filter_done" string="Done"
            domain="[('state', '=', 'done')]" />
         <filter name="filter_error" string="Error"
            domain="[('state', '=', 'error')]" />
         <filter name="filter_pending" string="Pending"
            domain="[('state', '=', 'pending')]" />
         <filter name="groupby_state" string="State"
            context="{'group_by': 'state'}" />
         <filter name="groupby_status_code" string="Status code"
            context="{'group_by': 'status_code'}" />
      </search>
   </field>
</record>

<record id="action_jobs_view" model="ir.actions.act_window">
   <field name="name">Some external API</field>
   <field name="type">ir.actions.act_window</field>
   <field name="res_model">my_mobule.job</field>
   <field name="view_mode">tree,form</field>
   <field name="context">{
      'search_default_filter_pending': 1,
      'search_default_filter_error': 1
   }</field>
</record>

<menuitem id="menu_wsqueue_jobs_some_external_api"
   action="action_jobs_view" parent="smile_wsqueue.menu_wsqueue_jobs" />

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed feedback.

Do not contact contributors directly about support or help with technical issues.

Credits

Authors

  • Smile SA

Contributors

  • Paul JOANNON
  • Isabelle RICHARD

Maintainers

This module is maintained by the Smile SA.

Since 1991 Smile has been a pioneer of technology and also the European expert in open source solutions.

Smile SA

This module is part of the odoo-addons project on GitHub.

You are welcome to contribute.

Please log in to comment on this module

  • The author can leave a single reply to each comment.
  • This section is meant to ask simple questions or leave a rating. Every report of a problem experienced while using the module should be addressed to the author directly (refer to the following point).
  • If you want to start a discussion with the author, please use the developer contact information. They can usually be found in the description.
Please choose a rating from 1 to 5 for this module.
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with