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.

0

How to change unit of events duration ?

By
Anne-Sylvie Burri
on 9/30/13, 6:58 AM 822 views

Hello,

I want to change the display of the duration of an event in the tree view of crm.meeting . Currently the duration is displayed in hours and i want it to be displayed in days.

Any help is appreciated.

0
Anne-Sylvie Burri
On 9/30/13, 10:01 AM

Find it.

I use a functional field "duration_in_day" whose the value is equal to the duration field's / 24.

Here is my code :

class crm_meeting(osv.osv): 
    def compute_duration_in_day(self, cr, uid, ids, field_name, field_value, arg, context=None):
        records = self.browse(cr, uid, ids)
        result = {}
        for r in records:
            flt = 0.0
            if r.duration: flt = r.duration / 24
            result[r.id] = flt
        return result

    _inherit = 'crm.meeting'
    _name = 'crm.meeting'
    _columns = {
        'duration_in_day': fields.function(compute_duration_in_day, type='float', string='Durée en jours'),
    }

crm_meeting()

However i don't think it's optimised.

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)

Stats

Asked: 9/30/13, 6:58 AM
Seen: 822 times
Last updated: 3/16/15, 8:10 AM