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. Generic System Event
  3. Generic System Event v 13.0
  4. Sales Conditions FAQ

Generic System Event

by Center of Research and Development https://crnd.pro
Odoo

$ 34.68

v 13.0 Third Party 15
Apps purchases are linked to your Odoo account, please sign in or sign up first.
Availability
Odoo Online
Odoo.sh
On Premise
Community Apps Dependencies Show
• Generic M2O Widget
• Generic Mixin
Lines of code 3089
Technical Name generic_system_event
LicenseLGPL-3
Websitehttps://crnd.pro
Versions 12.0 13.0 14.0 15.0 16.0 17.0
You bought this module and need support? Click here!
Availability
Odoo Online
Odoo.sh
On Premise
Community Apps Dependencies Show
• Generic M2O Widget
• Generic Mixin
Lines of code 3089
Technical Name generic_system_event
LicenseLGPL-3
Websitehttps://crnd.pro
Versions 12.0 13.0 14.0 15.0 16.0 17.0

Generic System Event

License: OPL-1 CR&D


This module provides framework that allows to make odoo event-driven. Note, that in this case event means business event.

With this module, you can easily convert your model to event source, and then handle events from that model in any other place of odoo. With this module you may forget about again and again overriding ``write`` methods.

Why this is needed?

This module allows to step away from infinite overrides of write/create, or overriding other methods to add some logic. Instead, with this framework, you can think in event driven way: just trigger event with all needed data where it is needed. And handle this event in multiple places in multiple modules, in multiple related models.

For example, you can define event like Invoice Paid, and then handle it on Sale Order, In CRM, or in any other related object. The framework, will automatically call all registered handlers of this event. This way, it is possible to significantly simplify complex logic of handling events.

Also, because events are stored in database, you always have history of events related to specific record, which could help in debug, or in tracking what is going on in some cases.

How to use

  1. Create model for events

    At first, you have to create model to store events produced by your event source.

    You can define such model as following:

     python
                        
                            class MyEvent(models.Model):
                                _name = 'my.event'
                                _inherit = 'generic.system.event.data.mixin'
    
                                # You can add here fields specific to your events.
                                # For example:
                                my_param_old = fields.Char()
                                my_param_new = fields.Char()
                        
                    
  2. Create event source

    You have to inherit your model from ``generic.system.event.source.mixin`` to to make it event source, capable to generate events. For example, let's define simple model with one field ``param``, and trigger event any type this field changed.

    python
                    
                        from odoo.addons.generic_mixin import post_write
                        from odoo.addons.generic_system_event import on_event
    
                        class MyEventSource(models.Model):
                             _name = 'my.event.source'
                             _inherit = 'generic.system.event.source.mixin'
    
                             # This is needed to automatically register event source
                             # Other wise, you will need additionally to define
                             # event source in XML.
                             # Automatic event source will be generated with
                             # xmlid: your_module_name.system_event_source__my_event_source
                             _generic_system_event_source__auto_create = True
    
                             # name of data model for events from this event source
                             _generic_system_event_source__event_data_model = 'my.event'
    
                             # Next, we can define some data on this model
                             my_param = fields.Char()
    
                             # This field will be changed automatically by event handler.
                             counter = Integer
    
                             # Let's trigger event
                             @post_write('my_param')
                             def _after_my_param_changed_trigger_event(self, changes):
                                 # The line below triggers event
                                 self.trigger_event('my-param-changed', {
                                     'my_param_old': changes['my_param'].old_val,
                                     'my_param_new': changes['my_param'].new_val,
                                 })
    
                             # Next, we can define event handler:
                             @on_event('my-param-changed')
                             def _on_my_param_changed(self, event):
                                 self.counter += 1
                    
                
  3. Define event types

    Next, we have to define all event types in the XML.

    xml
                        
                            My Events
                            my-events
                            My Param Changed
                            my-param-changed
                        
                    
  4. Define views for events

    Next we have to define views for event data model (that model that is used to store events).

    xml
                        
                            my.event
                            primary
                                false
                                false
                            my.event
                            primary
                        
                    
  5. Add stat-button to show events on your view

    If needed, you can add stat-button on your form view of 'my.event.source' to show related events. All you need is to add following xml snippet.

    xml
                    

Note, that method ``action_show_related_system_events`` already implemented in ``generic.system.event.source.mixin``, thus, this xml-snipped is all you need.

Advanced usage

For advanced usage, look for documentation in the code. Basically, this framework, allows you to handle events triggered in context of one model (for example invoices), in context of another related model (for example sale order).

All you need for this, is to specify mapping in XML (see ``generic.system.event.source.handler.map`` model for more info). Also, in this case, you have to apply ``generic.system.event.handler.mixin`` to handler model to allow framework to automatically discover handlers.

Launch your own ITSM system in 60 seconds:

Create your own Bureaucrat ITSM database yodoo.systems

Maintainer

CR&D
Website Contact us Bug Requests
Blog Youtube Channel


This module is maintained by the Center of Research & Development company.

We can provide you further Odoo Support, Odoo implementation, Odoo customization, Odoo 3rd Party development and integration software, consulting services. Our main goal is to provide the best quality product for you.

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 or have a question related to your purchase, please use the support page.
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