Odoo Help


This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


_track with additional information

Andrius Laukavičius
on 2/25/14, 4:10 AM 1,080 views

Is it possible to add additional information when field is tracked? For example let say there are two fields:

_track = {
  'field1': {},
  'field2': {},

I need to track those fields if anything is changed in those fields. And that is ok, but the problem is that those fields labels are the same for example like this:

_columns = {
  'field1': fields.integer('Number'), 
   'field2': fields.integer('Number'),


I don't want to change it's name, because those names should be the same as they represent same thing but in different time. But is it possible to add aditional infor when tracking occurs, for example instead of just showing like this:

Number: 1 - > 2

It would show like this:

Number: 1 -> 2 "before field" #when field1 is changed

Number: 2 -> 3 "after field" #when field2 is changed

Ahmed Kordy
On 9/12/15, 12:49 PM

If you mean you already using the track_visibility and you want a more customized note messages, then you might need to hook into the write method.

The customized method would be ran each time the model writes to database, a comparison made between old and new records would track any changes to specific fields, if any then let's log a note.

Add this to your model class (change ClassName with your model class name, message body as you wish):

def write(self, vals):
old_field1 = self.field1
old_field2 = self.field2

super(ClassName, self).write(vals)

new_field1 = self.field1
new_field2 = self.field2

if old_field1 != new_field1:
self.message_post(body="<b>Field1 Title:</b> %s &#8594; %s" % (old_field1, new_field1))

if old_field2 != new_field2:
self.message_post(body="<b>Field2 Title:</b> %s &#8594; %s" % (old_field2, new_field2))

return True

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)


Asked: 2/25/14, 4:10 AM
Seen: 1080 times
Last updated: 9/12/15, 12:49 PM