Odoo Help

Welcome!

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.

1

How to change "track_visibility" for existing fields without overwriting?

By
Travis Waelbroeck
on 5/9/16, 10:39 AM 628 views

I want to add track_visibility = 'onchange' for many fields, particularly existing fields in the product model.

These fields are written with V7 API, but I am using Odoo 8.


I know that I can override the entire field definition, like:

'name': fields.char('Name', required=True, translate=True, select=True, track_visibility='onchange'),


But this seems quite sloppy.

What if the field definition changes in an update? My minor tracking modification could break the module's functionality.


Trying to just add tracking (like below) will cause the field Name, etc. to be undefined, because it overwrites, rather than inheriting.

# Overrides instead of inheriting

'name': fields.char(track_visibility='onchange'),


Is there a way to do this more cleanly? Either in V7 or V8 API.


1
Krupesh Laiya
On 6/27/16, 5:46 AM

Hi,

You must have to override using copy field from base file and add(append) the track_visibility='onchange' 

to the fields this is the only way.


Ok, that's what I thought. Seems like a lot of overhead to just change the tracking. There are a lot of default fields which we would like to monitor in this way. Thanks for your input, Krupesh.

Htm-Mbs, Travis Waelbroeck
on 6/27/16, 12:02 PM

most welcome.

Krupesh Laiya
on 6/29/16, 2:57 AM
0
Royal Administrator
On 8/28/16, 12:28 AM

In the big comment atop class Field in fields.py, I noticed "For instance, the second class below only adds a tooltip on the field...."  I wanted to see the lead names, aka subject lines, in the lead notifications, and I was successful like this:

from openerp import models, fields

class crm_lead(models.Model):
     _inherit = 'crm.lead'
    name = fields.Char(track_visibility='onchange')

You do need the overhead of getting the datatype correct for the field.
Then the track_visibility attribute can be changed free of further overhead.

So only whatever I define in my inherited field definition will be changed? I can define only track_visibility without affecting other field attributes?

Htm-Mbs, Travis Waelbroeck
on 8/28/16, 12:52 AM

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

1 follower(s)

Stats

Asked: 5/9/16, 10:39 AM
Seen: 628 times
Last updated: 8/28/16, 12:28 AM