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
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

What is the _track proprerty of mail.thread model used for ?

Subscribe

Get notified when there's activity on this post

This question has been flagged
followermailmessagingv7track
4 Replies
29665 Views
Avatar
Nicolas Bessi

In the mail.thread model _trackpropety is defined. It as the following doc `

# Automatic logging system if mail installed
# _track = {
#   'field': {
#       'module.subtype_xml': lambda self, cr, uid, obj, context=None: obj[state] == done,
#       'module.subtype_xml2': lambda self, cr, uid, obj, context=None: obj[state] != done,
#   },
#   'field2': {
#       ...
#   },
# }

`

But his puprose and usage is not really clear.

3
Avatar
Discard
Avatar
Sudhir Arya (ERP Harbor Consulting Services)
Best Answer

As per my knowledge it keeps track on state. When state is changed you can see message at bottom of your page.


Let's take Sale Order as example.

When you confirm Sale Quotation, you can see message Quotation confirmed in message list.

You can see _track in sale.py

_track = {
    'state': {
        'sale.mt_order_confirmed': lambda self, cr, uid, obj, ctx=None: obj['state'] in ['manual', 'progress'],
        'sale.mt_order_sent': lambda self, cr, uid, obj, ctx=None: obj['state'] in ['sent']
    },

Here, mt_order_confirmed & mt_order_sent is an ID of record of object mail.message.subtype in sale_data.xml

Correct me if I am wrong.

Thank you.

13
Avatar
Discard
Avatar
Andreas Brueckl
Best Answer

_track on the object is used to track events related to a document (an invoice has been paid, an opportunity is won, a task is blocked, ...). Users can follow events, represented by a mail.message.subtype, on any object.

It's different from the track_visibility attribute that you can define on a field which is used to track changes on this field. (e.g. Stage : Proposition -> Negociation)

Both _track and track_visibility produces messages on the document. Your object need to inherit from mail.thread.

If an object is inherited from 'mail.thread' then _track is used to send notifications. Therefore 'module.subtype_xml' is the related "Message Subtype". These subtypes have to be declared in XML. Here is an example:

<record id="subtype_xml" model="mail.message.subtype">
    <field name="name">Relevant Fields</field>
    <field name="res_model">project.issue</field>
    <field name="default" eval="True"/>
    <field name="description">The issue has been closed.</field>
</record>

Then whenever the field "field" is updated, all subtypes ("subtype_xml", "subtype_xml2") of this field are processed.

This means that the related method (in this example: lambda ...) is called and if the result is True, then for all users which follow this object and have checked the subtype a notification is created.

In the user preferences every user can choose whether he/she wants to be updated by email in case of new notifications.

You can also set a mail.message.subtype that depends on an other to act through a relation field. Here is an exemple from crm for Sales Teams crm.case.section using the section_id m2o in crm.lead:

    <record id="mt_lead_won" model="mail.message.subtype">
        <field name="name">Opportunity Won</field>
        <field name="res_model">crm.lead</field>
        <field name="default" eval="False"/>
        <field name="description">Opportunity won</field>
    </record>

    <record id="mt_salesteam_lead_won" model="mail.message.subtype">
        <field name="name">Opportunity Won</field>
        <field name="res_model">crm.case.section</field>
        <field name="parent_id" eval="ref('mt_lead_won')"/>
        <field name="relation_field">section_id</field>
    </record>

This allows a user to follow all "Opportunities Won" that are in a specific sales team. The user follow the event "Opportunity Won" on a sales team and he will become automatically follower of all leads/oppotunities of this sales team and _track event.

13
Avatar
Discard
Fabien Pinckaers (fp)

I merged several answers into this one (thanks Yannick Vaucher)

Soohoo

Hi Fabien can you tell me how to track the amount change

Avatar
Yannick Payot
Best Answer

To complete the answer from Andreas

You can also set a mail.message.subtype that depends on an other to act through a relation field. Here is an exemple from crm for Sales Teams crm.case.section using the section_id m2o in crm.lead:

    <record id="mt_lead_won" model="mail.message.subtype">
        <field name="name">Opportunity Won</field>
        <field name="res_model">crm.lead</field>
        <field name="default" eval="False"/>
        <field name="description">Opportunity won</field>
    </record>

    <record id="mt_salesteam_lead_won" model="mail.message.subtype">
        <field name="name">Opportunity Won</field>
        <field name="res_model">crm.case.section</field>
        <field name="parent_id" eval="ref('mt_lead_won')"/>
        <field name="relation_field">section_id</field>
    </record>
1
Avatar
Discard
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Related Posts Replies Views Activity
How auto subscribe to group?
follower mail messaging v7 track
Avatar
0
Mar 15
6865
How does notifications, Inbox, To:Me, and Todo mailboxes work? Solved
mail messaging v7
Avatar
1
Apr 23
27557
How can I manage my emails related to leads and opportunities?
mail messaging crm v7
Avatar
1
Mar 15
18815
How to be in a document's followers ? Solved
project follower mail messaging crm
Avatar
Avatar
3
Mar 16
12645
Which information is public in the messaging system on the bottom of documents?
security mail messaging public v7
Avatar
Avatar
1
Mar 15
6399
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
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

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

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now