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 inherit calendar.event

By
Bonnet Denis
on 5/13/13, 2:36 PM 807 views

I've already create a custom module and use inheritance successfully.

I add to my personal module a piece of code to fix a bug but this code is don't read by openERP.

class calendar_event(osv.osv):
    _name = 'calendar.event'
    _inherit = 'calendar.event'

    def read(self, cr, uid, ids, fields=None, context=None, load='_classic_read'):
        _logger.debug('"""""""""""""""""""""XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX""""""""""""""""""""')
        if context is None:
            context = {}
        fields2 = fields and fields[:] or None

        EXTRAFIELDS = ('class','user_id','duration')
        for f in EXTRAFIELDS:
            if fields and (f not in fields):
                fields2.append(f)

        # FIXME This whole id mangling has to go!
        if isinstance(ids, (str, int, long)):
            select = [ids]
        else:
            select = ids

        select = map(lambda x: (x, base_calendar_id2real_id(x)), select)
        result = []

        real_data = super(calendar_event, self).read(cr, uid,
                    [real_id for base_calendar_id, real_id in select],
                    fields=fields2, context=context, load=load)
        real_data = dict(zip([x['id'] for x in real_data], real_data))

        for base_calendar_id, real_id in select:
            res = real_data[real_id].copy()
            ls = base_calendar_id2real_id(base_calendar_id, with_date=res and res.get('duration', 0) or 0)
            if not isinstance(ls, (str, int, long)) and len(ls) >= 2:
                res['date'] = ls[1]
                res['date_deadline'] = ls[2]
            res['id'] = base_calendar_id

            result.append(res)

        for r in result:
            if r['user_id']:
                user_id = type(r['user_id']) in (tuple,list) and r['user_id'][0] or r['user_id']
                if user_id==uid:
                    continue
            if r['class']=='private':
                for f in r.keys():
                    if f not in ('id','date','date_deadline','duration','user_id','state','interval','count'):
                        if isinstance(r[f], list):
                            r[f] = []
                        else:
                            r[f] = False
                    if f=='name':
                        r[f] = _('Busy')

        for r in result:
            for k in EXTRAFIELDS:
                if (k in r) and (fields and (k not in fields)):
                    del r[k]
        if isinstance(ids, (str, int, long)):
            return result and result[0] or False
        return result

When I use this method I don't see this text in log file : _logger.debug('"""""""""""""""""""""XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX""""""""""""""""""""')

I modify the function like here:https://code.launchpad.net/~openerp-dev/openobject-addons/7.0-opw-586451-pna/+merge/149266

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: 5/13/13, 2:36 PM
Seen: 807 times
Last updated: 3/16/15, 8:10 AM