コード例 #1
0
    def menu(self, active=None, next=None):
        from openerp.widgets import tree_view
        
        try:
            id = int(active)
        except:
            id = False
            form.Form().reset_notebooks()
        ctx = rpc.session.context.copy()
        menus = rpc.RPCProxy("ir.ui.menu")

        domain = [('parent_id', '=', False)]
        user_menu_action_id = rpc.RPCProxy("res.users").read([rpc.session.uid], ['menu_id'], ctx)[0]['menu_id']
        if user_menu_action_id:
            act = rpc.RPCProxy('ir.actions.act_window').read([user_menu_action_id[0]], ['res_model', 'domain'], ctx)[0]
            if act['res_model'] == 'ir.ui.menu' and act['domain']:
                domain = literal_eval(act['domain'])

        ids = menus.search(domain, 0, 0, 0, ctx)
        parents = menus.read(ids, ['name', 'action', 'web_icon_data', 'web_icon_hover_data'], ctx)

        for parent in parents:
            if parent['id'] == id:
                parent['active'] = 'active'
                if parent.get('action') and not next:
                    next = url('/openerp/custom_action', action=id)
            # If only the hover image exists, use it as regular image as well
            if parent['web_icon_hover_data'] and not parent['web_icon_data']:
                parent['web_icon_data'] = parent['web_icon_hover_data']

        if next or active:
            if not id and ids:
                id = ids[0] 
            ids = menus.search([('parent_id', '=', id)], 0, 0, 0, ctx)
            tools = menus.read(ids, ['name', 'action'], ctx)
            #searching id for the hierarchycal tree view of ir.ui.menu 
            view_id = rpc.RPCProxy('ir.ui.view').search([('model','=','ir.ui.menu'),('type','=','tree')],0,0,'id')[0]
            view = cache.fields_view_get('ir.ui.menu', view_id, 'tree', {})
            fields = cache.fields_get(view['model'], False, ctx)
            
            for tool in tools:
                tid = tool['id']
                tool['tree'] = tree = tree_view.ViewTree(view, 'ir.ui.menu', tid,
                                        domain=[('parent_id', '=', tid)],
                                        context=ctx, action="/openerp/tree/action", fields=fields)
                tree._name = "tree_%s" %(tid)
                tree.tree.onselection = None
                tree.tree.onheaderclick = None
                tree.tree.showheaders = 0
        else:
            # display home action
            tools = None

        return dict(parents=parents, tools=tools, load_content=(next and next or ''),
                    welcome_messages=rpc.RPCProxy('publisher_warranty.contract').get_last_user_messages(_MAXIMUM_NUMBER_WELCOME_MESSAGES),
                    show_close_btn=rpc.session.uid == 1,
                    widgets=openobject.pooler.get_pool()\
                                      .get_controller('/openerp/widgets')\
                                      .user_home_widgets(ctx))
コード例 #2
0
    def create(self, params):
        view_id = (params.view_ids or False) and params.view_ids[0]
        domain = params.domain
        context = params.context
        ctx = dict(context, **rpc.session.context)

        res_id = params.ids or 0
        model = params.model

        if view_id:
            view_base = rpc.session.execute('object', 'execute', 'ir.ui.view',
                                            'read', [view_id],
                                            ['model', 'type'], context)[0]
            model = view_base['model']
            view = cache.fields_view_get(model, view_id, view_base['type'],
                                         context)
        else:
            view = cache.fields_view_get(model, False, 'tree', context)
        fields = cache.fields_get(view['model'], False, context)

        tree = tree_view.ViewTree(view,
                                  model,
                                  res_id,
                                  domain=domain,
                                  context=context,
                                  action="/tree/action",
                                  fields=fields)
        if tree.toolbar:
            proxy = rpc.RPCProxy(model)

            for tool in tree.toolbar:
                if tool.get('icon'):
                    tool['icon'] = icons.get_icon(tool['icon'])
                else:
                    tool['icon'] = False
                id = tool['id']
                ids = proxy.read([id], [tree.field_parent],
                                 ctx)[0][tree.field_parent]
                tool['ids'] = ids

        can_shortcut = self.can_shortcut_create()
        shortcut_ids = []

        for sc in cherrypy.session.get('terp_shortcuts') or []:
            if isinstance(sc['res_id'], tuple):
                shortcut_ids.append(sc['res_id'][0])
            else:
                shortcut_ids.append(sc['res_id'])

        return {
            'tree': tree,
            'model': model,
            'can_shortcut': can_shortcut,
            'shortcut_ids': shortcut_ids
        }
コード例 #3
0
ファイル: viewed.py プロジェクト: hectord/unifield
def _get_field_attrs(node, parent_model):

    if node.localName != 'field':
        return {}

    model = _get_model(node, parent_model)

    name = node.getAttribute('name')
    field = cache.fields_get(model, [name], rpc.session.context)

    if field:
         field = field[name]

    return field
コード例 #4
0
def _get_field_attrs(node, parent_model):

    if node.localName != 'field':
        return {}

    model = _get_model(node, parent_model)

    name = node.getAttribute('name')
    field = cache.fields_get(model, [name], rpc.session.context)

    if field:
        field = field[name]

    return field
コード例 #5
0
    def gantt_reorder(self, **kw):
        params, data = TinyDict.split(kw)

        id = params.id
        ids = params.ids or []
        model = params.model
        level = params.level
        level_value = params.level_value

        fields = cache.fields_get(model, [], rpc.get_session().context)

        proxy = rpc.RPCProxy(model)
        if id and level and level_value:
            try:
                proxy.write([id], {level['link']: level_value})
            except Exception, e:
                return dict(error=ustr(e))
コード例 #6
0
    def gantt_reorder(self, **kw):
        params, data = TinyDict.split(kw)

        id = params.id
        ids = params.ids or []
        model = params.model
        level = params.level
        level_value = params.level_value

        fields = cache.fields_get(model, [], rpc.session.context)

        proxy = rpc.RPCProxy(model)
        if id and level and level_value:
            try:
                proxy.write([id], {level['link']: level_value})
            except Exception, e:
                return dict(error=ustr(e))
コード例 #7
0
    def edit(self, view_id, xpath_expr):
        view_id = int(view_id)

        proxy = rpc.RPCProxy('ir.ui.view')
        res = proxy.read([view_id], ['model', 'arch'])[0]

        doc = xml.dom.minidom.parseString(res['arch'].encode('utf-8'))
        field = utils.xml_locate(xpath_expr, doc)[0]

        attrs = utils.node_attributes(field)
        editors = []

        properties = _PROPERTIES.get(field.localName, [])
        if field.localName == 'field':
            kind = 'char'
            try:
                model = _get_model(field, parent_model=res['model'])
                attrs2 = cache.fields_get(model, [attrs['name']],
                                          rpc.session.context)[attrs['name']]

                attrs2.update(attrs)

                if attrs2.get('widget', False):
                    if attrs2['widget'] == 'one2many_list':
                        attrs2['widget'] = 'one2many'
                    attrs2['type'] = attrs2['widget']

                kind = attrs2.get('type', kind)
            except:
                pass
            properties = _PROPERTIES_FIELDS.get(kind) or properties
        properties = properties[:]
        properties.extend(list(set(attrs.keys()) - set(properties)))

        for prop in properties:
            if field.localName == 'action' and prop == 'name':
                ed = ActionProperty(prop, attrs.get(prop))
            elif field.localName == 'button' and prop in _PROPERTY_WIDGETS_BUTTON:
                ed = _PROPERTY_WIDGETS_BUTTON[prop](prop, attrs.get(prop))
            else:
                ed = get_property_widget(prop, attrs.get(prop))

            ed.label = prop
            editors.append(ed)

        return dict(view_id=view_id, xpath_expr=xpath_expr, editors=editors)
コード例 #8
0
ファイル: viewed.py プロジェクト: hectord/unifield
    def edit(self, view_id, xpath_expr):
        view_id = int(view_id)

        proxy = rpc.RPCProxy('ir.ui.view')
        res = proxy.read([view_id], ['model', 'arch'])[0]

        doc = xml.dom.minidom.parseString(res['arch'].encode('utf-8'))
        field = utils.xml_locate(xpath_expr, doc)[0]

        attrs = utils.node_attributes(field)
        editors = []

        properties = _PROPERTIES.get(field.localName, [])
        if field.localName == 'field':
            kind = 'char'
            try:
                model = _get_model(field, parent_model=res['model'])
                attrs2 = cache.fields_get(model, [attrs['name']], rpc.session.context)[attrs['name']]

                attrs2.update(attrs)

                if attrs2.get('widget', False):
                    if attrs2['widget']=='one2many_list':
                        attrs2['widget']='one2many'
                    attrs2['type'] = attrs2['widget']

                kind = attrs2.get('type', kind)
            except:
                pass
            properties = _PROPERTIES_FIELDS.get(kind) or properties
        properties = properties[:]
        properties.extend(list(set(attrs.keys()) - set(properties)))

        for prop in properties:
            if field.localName == 'action' and prop == 'name':
                ed = ActionProperty(prop, attrs.get(prop))
            elif field.localName == 'button' and prop in _PROPERTY_WIDGETS_BUTTON:
                ed = _PROPERTY_WIDGETS_BUTTON[prop](prop, attrs.get(prop))
            else:
                ed = get_property_widget(prop, attrs.get(prop))

            ed.label = prop
            editors.append(ed)

        return dict(view_id=view_id, xpath_expr=xpath_expr, editors=editors)
コード例 #9
0
ファイル: tree.py プロジェクト: gisce/openobject-client-web
    def create(self, params):
        view_id = (params.view_ids or False) and params.view_ids[0]
        domain = params.domain
        context = params.context
        ctx = dict(context,
                   **rpc.session.context)

        res_id = params.ids or 0
        model = params.model

        if view_id:
            view_base =  rpc.session.execute(
                    'object', 'execute', 'ir.ui.view', 'read', [view_id],
                    ['model', 'type'], context)[0]
            model = view_base['model']
            view = cache.fields_view_get(model, view_id, view_base['type'], context)
        else:
            view = cache.fields_view_get(model, False, 'tree', context)
        fields = cache.fields_get(view['model'], False, context)
            
        tree = tree_view.ViewTree(view, model, res_id, domain=domain, context=context, action="/tree/action", fields=fields)
        if tree.toolbar:
            proxy = rpc.RPCProxy(model)

            for tool in tree.toolbar:
                if tool.get('icon'):
                    tool['icon'] = icons.get_icon(tool['icon'])
                else:
                    tool['icon'] = False
                id = tool['id']
                ids = proxy.read([id], [tree.field_parent], ctx)[0][tree.field_parent]
                tool['ids'] = ids
            
        can_shortcut = self.can_shortcut_create()
        shortcut_ids = []

        for sc in cherrypy.session.get('terp_shortcuts') or []:
            if isinstance(sc['res_id'], tuple):
                shortcut_ids.append(sc['res_id'][0])
            else:
                shortcut_ids.append(sc['res_id'])
        
        return {'tree': tree, 'model': model, 'can_shortcut': can_shortcut, 'shortcut_ids': shortcut_ids}
コード例 #10
0
    def __init__(self, source, model, domain=None, context=None, values={}, filter_domain=None, search_view=None, group_by_ctx=[], **kw):
        super(Search, self).__init__(model=model)

        self.domain = copy.deepcopy(domain) or []
        self.listof_domain = domain or []
        self.filter_domain = filter_domain or []
        self.custom_filter_domain = []
        self.context = context or {}
        self.search_view = search_view or "{}"
        self.model = model
        self.groupby = []
        self.source = source
        if kw.get('clear'):
            self.source = None
        if group_by_ctx and isinstance(group_by_ctx, basestring):
            self.groupby += group_by_ctx.split(',')
        else:
            self.groupby = group_by_ctx

        if values == "undefined":
            values = {}

        ctx = dict(rpc.session.context, **self.context)
        if not self.groupby and (values and values.get('group_by_ctx')):
            self.groupby = values['group_by_ctx']
        
        if isinstance (self.search_view, basestring):
            self.search_view = eval(self.search_view)

        if not self.search_view:
            view_id = kw.get('search_view_id')\
                        or ctx.get('search_view')
            self.search_view = cache.fields_view_get(
                self.model, view_id or False, 'search', ctx, True)

        fields = self.search_view['fields']

        self.domain = convert_date_format_in_domain(domain, fields, self.context)
        self.listof_domain = self.domain

        try:
            dom = xml.dom.minidom.parseString(self.search_view['arch'])
        except:
            dom = xml.dom.minidom.parseString(self.search_view['arch'].encode('utf-8'))

        self.view_type = dom.firstChild.localName
        self.string = dom.documentElement.getAttribute('string')

        self.fields_type = {}

        all_fields = cache.fields_get(model, [], rpc.session.context)

        self.fields = dict(all_fields, **fields)

        self.fields_list = [
            (field_name, ustr(field['string']), field['type'])
            for field_name, field in self.fields.iteritems()
            if field['type'] != 'binary'
            if field.get('selectable')
        ]

        if self.fields_list:
            self.fields_list.sort(lambda x, y: cmp(x[1], y[1]))

        self.frame = self.parse(model, dom, self.fields, values)
        if self.frame:
            self.frame = self.frame[0]

        my_acts = rpc.session.execute('object', 'execute', 'ir.filters', 'get_filters', model)

        sorted_filters = []
        for act in my_acts:
            action = [act['domain'], act['name']]
            act_ctx = eval(act['context'])
            if act_ctx and act_ctx.get('group_by'):
                action.append(ustr(act_ctx['group_by']))
            else:
                action.append("[]")
            action.append(act['id'])

            sorted_filters.append(action)
        sorted_filters.sort(lambda x, y: cmp(x[1], y[1]))

        self.filters_list = sorted_filters

        self.operators_map = [
            ('ilike', _('contains')), ('not ilike', _('doesn\'t contain')),
            ('=', _('is equal to')), ('<>', _('is not equal to')),
            ('>', _('greater than')), ('<', _('less than')),
            ('in', _('in')), ('not in', _('not in'))]

        self.flt_domain = str(self.filter_domain).replace("(", "[").replace(')', ']')
        self.custom_filter_domain = self.filter_domain
コード例 #11
0
    def __init__(self, model, view=False, view_id=False, ids=[], domain=[], view_mode=[], context={}, group_by=[]):

        ctx = {}
        ctx = rpc.get_session().context.copy()
        ctx.update(context)

        view = view or cache.fields_view_get(model, view_id, 'graph', ctx)
        fields = view['fields']
        dom = xml.dom.minidom.parseString(view['arch'].encode('utf-8'))
        root = dom.childNodes[0]
        attrs = node_attributes(root)

        self.view_mode = view_mode
        self.model = model
        self.string = attrs.get('string', 'Unknown')
        self.kind = attrs.get('type', '')
        self.orientation = attrs.get('orientation', 'vertical')
        self.values = []
        self.group_by = group_by
        add_grp_field = ''
        if self.group_by and not fields.has_key(self.group_by[0]):
            add_grp_field = cache.fields_get(self.model, [self.group_by[0]], rpc.get_session().context)
            fields.update(add_grp_field)
        axis, axis_data, axis_group = self.parse(root, fields)

        if  self.group_by:
            axis[0] = self.group_by[0]
            axis_data.update(add_grp_field)
        proxy = rpc.RPCProxy(model)

        ctx = rpc.get_session().context.copy()
        ctx.update(context)
        if ids is None:
            ids = proxy.search(domain, 0, 0, 0, ctx)

        rec_ids = []
        values = proxy.read(ids, fields.keys(), ctx)

        for value in values:
            res = {}
            rec_ids.append(value.get('id'))
            res['temp_id'] = value.get('id')

            for x in axis_data.keys():
                if fields[x]['type'] in ('many2one', 'char','time','text'):
                    res[x] = value[x]
                    if isinstance(res[x], (list, tuple)):
                        res[x] = res[x][-1]
                    res[x] = ustr(res[x])
                elif fields[x]['type'] in 'selection':
                    selection_mapping = dict(fields[x]['selection'])
                    res[x] = selection_mapping.get(value[x], False)
                elif fields[x]['type'] == 'date':
                    if value[x]:
                        date = time.strptime(value[x], DT_SERVER_FORMATS['date'])
                        date = tz_convert(date, 'parse')
                        res[x] = time.strftime(locale.nl_langinfo(locale.D_FMT).replace('%y', '%Y'), date)
                    else:
                        res[x] = ''
                elif fields[x]['type'] == 'datetime':
                    if value[x]:
                        date = time.strptime(value[x], DT_SERVER_FORMATS['datetime'])
                        date = tz_convert(date, 'parse')
                        res[x] = time.strftime(locale.nl_langinfo(locale.D_FMT).replace('%y', '%Y')+' %H:%M:%S', date)
                    else:
                        res[x] = ''
                else:
                    res[x] = value[x] and float(value[x]) or 0.0

            if axis and isinstance(value[axis[0]], (tuple, list)):
                res['id'] = value[axis[0]][0]
            elif axis:
                res['id'] = value[axis[0]]
            else:
                res['id'] = False

            res['rec_id'] = rec_ids

            self.values.append(res)

        self.axis = axis
        self.axis_data = axis_data
        self.axis_group_field = axis_group
コード例 #12
0
    def __init__(self,
                 source,
                 model,
                 domain=None,
                 context=None,
                 values={},
                 filter_domain=None,
                 search_view=None,
                 group_by_ctx=[],
                 **kw):
        super(Search, self).__init__(model=model)

        self.domain = copy.deepcopy(domain) or []
        self.listof_domain = domain or []
        self.filter_domain = filter_domain or []
        self.filter_status = {}
        self.custom_filter_domain = []
        self.context = context or {}
        self.search_view = search_view or "{}"
        self.model = model
        self.groupby = []
        self.source = source
        if kw.get('clear'):
            self.source = None
        if group_by_ctx and isinstance(group_by_ctx, basestring):
            self.groupby += group_by_ctx.split(',')
        else:
            self.groupby = group_by_ctx

        if values == "undefined":
            values = {}

        ctx = dict(rpc.session.context, **self.context)
        if not self.groupby and (values and values.get('group_by_ctx')):
            self.groupby = values['group_by_ctx']

        if not self.filter_status and (values and values.get('filter_status')):
            self.filter_status = values['filter_status']

        if isinstance(self.search_view, basestring):
            self.search_view = eval(self.search_view)

        if not self.search_view:
            view_id = kw.get('search_view_id')\
                        or ctx.get('search_view')
            self.search_view = cache.fields_view_get(self.model, view_id
                                                     or False, 'search', ctx,
                                                     True)

        fields = self.search_view['fields']

        self.domain = convert_date_format_in_domain(domain, fields,
                                                    self.context)
        self.listof_domain = self.domain

        try:
            dom = xml.dom.minidom.parseString(self.search_view['arch'])
        except:
            dom = xml.dom.minidom.parseString(
                self.search_view['arch'].encode('utf-8'))

        self.view_type = dom.firstChild.localName
        self.string = dom.documentElement.getAttribute('string')

        self.fields_type = {}

        all_fields = cache.fields_get(model, [], rpc.session.context)

        self.fields = dict(all_fields, **fields)

        self.fields_list = [(field_name, ustr(field['string']), field['type'])
                            for field_name, field in self.fields.iteritems()
                            if field['type'] != 'binary'
                            if field.get('selectable')]

        if self.fields_list:
            self.fields_list.sort(lambda x, y: cmp(x[1], y[1]))

        self.frame = self.parse(model, dom, self.fields, values)
        if self.frame:
            self.frame = self.frame[0]

        my_acts = rpc.session.execute('object', 'execute', 'ir.filters',
                                      'get_filters', model)

        sorted_filters = []
        for act in my_acts:
            action = [act['domain'], act['name']]
            act_ctx = eval(act['context'])
            if act_ctx and act_ctx.get('group_by'):
                action.append(ustr(act_ctx['group_by']))
            else:
                action.append("[]")
            action.append(act['id'])

            sorted_filters.append(action)
        sorted_filters.sort(lambda x, y: cmp(x[1], y[1]))

        self.filters_list = sorted_filters

        self.operators_map = [('ilike', _('contains')),
                              ('not ilike', _('doesn\'t contain')),
                              ('=', _('is equal to')),
                              ('<>', _('is not equal to')),
                              ('>', _('greater than')), ('<', _('less than')),
                              ('in', _('in')), ('not in', _('not in'))]

        self.flt_domain = str(self.filter_domain).replace("(", "[").replace(
            ')', ']')
        self.custom_filter_domain = self.filter_domain
コード例 #13
0
    def __init__(self, model, ids, view, domain=[], context={}, options=None):

        super(ICalendar, self).__init__()

        self.info_fields = []
        self.fields = {}

        self.events = []

        self.colors = {}
        self.color_values = []

        self.calendar_fields = {}
        self.concurrency_info = None

        self.ids = ids
        self.model = model
        self.domain = domain or []
        self.context = context or {}
        self.options = options

        self.date_format = format.get_datetime_format('date')
        self.use_search = (options or None) and options.use_search

        try:
            dt = parse_datetime(options.selected_day)
            self.selected_day = Day(dt.year, dt.month, dt.day)
        except:
            pass

        view_id = view.get('view_id', False)

        dom = xml.dom.minidom.parseString(view['arch'].encode('utf-8'))
        root = dom.childNodes[0]
        attrs = node_attributes(root)

        self.string = attrs.get('string', '')
        self.date_start = attrs.get('date_start')
        self.date_delay = attrs.get('date_delay')
        self.date_stop = attrs.get('date_stop')
        self.color_field = attrs.get('color')
        self.day_length = int(attrs.get('day_length', 24))

        if options and options.mode:
            self.mode = options.mode
        else:
            self.mode = attrs.get('mode') or self.mode or 'month'

        self.info_fields = self.parse(root, view['fields'])

        fields = view['fields']
        fields = fields.keys() + [
            self.date_start, self.date_stop, self.date_delay, self.color_field,
            'state'
        ]

        fields = list(set([x for x in fields if x]))

        self.fields = cache.fields_get(model, fields, rpc.session.context)

        if self.color_field and options and options.colors:
            self.colors = options.colors

        if self.color_field and options and options.color_values:
            self.color_values = options.color_values

        self.calendar_fields['date_start'] = dict(
            name=self.date_start, kind=self.fields[self.date_start]['type'])

        if self.date_delay:
            self.calendar_fields['date_delay'] = dict(
                name=self.date_delay,
                kind=self.fields[self.date_delay]['type'])

        if self.date_stop:
            self.calendar_fields['date_stop'] = dict(
                name=self.date_stop, kind=self.fields[self.date_stop]['type'])

        self.calendar_fields['day_length'] = self.day_length
コード例 #14
0
    def __init__(self, model, ids, view, domain=[], context={}, options=None):

        super(ICalendar, self).__init__()

        self.info_fields = []
        self.fields = {}

        self.events = []

        self.colors = {}
        self.color_values = []

        self.calendar_fields = {}
        self.concurrency_info = None

        self.ids = ids
        self.model = model
        self.domain = domain or []
        self.context = context or {}
        self.options = options

        self.date_format = format.get_datetime_format("date")
        self.use_search = (options or None) and options.use_search

        try:
            dt = parse_datetime(options.selected_day)
            self.selected_day = Day(dt.year, dt.month, dt.day)
        except:
            pass

        view_id = view.get("view_id", False)

        dom = xml.dom.minidom.parseString(view["arch"].encode("utf-8"))
        root = dom.childNodes[0]
        attrs = node_attributes(root)

        self.string = attrs.get("string", "")
        self.date_start = attrs.get("date_start")
        self.date_delay = attrs.get("date_delay")
        self.date_stop = attrs.get("date_stop")
        self.color_field = attrs.get("color")
        self.day_length = int(attrs.get("day_length", 8))

        if options and options.mode:
            self.mode = options.mode
        else:
            self.mode = attrs.get("mode") or self.mode or "month"

        self.info_fields = self.parse(root, view["fields"])

        fields = view["fields"]
        fields = fields.keys() + [self.date_start, self.date_stop, self.date_delay, self.color_field, "state"]

        fields = list(set([x for x in fields if x]))

        self.fields = cache.fields_get(model, fields, rpc.get_session().context)

        if self.color_field and options and options.colors:
            self.colors = options.colors

        if self.color_field and options and options.color_values:
            self.color_values = options.color_values

        self.calendar_fields["date_start"] = dict(name=self.date_start, kind=self.fields[self.date_start]["type"])

        if self.date_delay:
            self.calendar_fields["date_delay"] = dict(name=self.date_delay, kind=self.fields[self.date_delay]["type"])

        if self.date_stop:
            self.calendar_fields["date_stop"] = dict(name=self.date_stop, kind=self.fields[self.date_stop]["type"])

        self.calendar_fields["day_length"] = self.day_length
コード例 #15
0
ファイル: _base.py プロジェクト: gisce/openobject-client-web
    def __init__(self, model, ids, view, domain=[], context={}, options=None):

        super(ICalendar, self).__init__()

        self.info_fields = []
        self.fields = {}

        self.events = []

        self.colors = {}
        self.color_values = []

        self.calendar_fields = {}
        self.concurrency_info = None

        self.ids = ids
        self.model = model
        self.domain = domain or []
        self.context = context or {}
        self.options = options

        self.date_format = format.get_datetime_format('date')
        self.use_search = (options or None) and options.use_search

        try:
            dt = parse_datetime(options.selected_day)
            self.selected_day = Day(dt.year, dt.month, dt.day)
        except:
            pass

        view_id = view.get('view_id', False)

        dom = xml.dom.minidom.parseString(view['arch'].encode('utf-8'))
        root = dom.childNodes[0]
        attrs = node_attributes(root)

        self.string = attrs.get('string', '')
        self.date_start = attrs.get('date_start')
        self.date_delay = attrs.get('date_delay')
        self.date_stop = attrs.get('date_stop')
        self.color_field = attrs.get('color')
        self.day_length = int(attrs.get('day_length', 24))

        if options and options.mode:
            self.mode = options.mode
        else:
            self.mode = attrs.get('mode') or self.mode or 'month'

        self.info_fields = self.parse(root, view['fields'])

        fields = view['fields']
        fields = fields.keys() + [self.date_start, self.date_stop, self.date_delay, self.color_field, 'state']

        fields = list(set([x for x in fields if x]))

        self.fields = cache.fields_get(model, fields, rpc.session.context)

        if self.color_field and options and options.colors:
            self.colors = options.colors

        if self.color_field and options and options.color_values:
            self.color_values = options.color_values

        self.calendar_fields['date_start'] = dict(name=self.date_start,
                                                  kind=self.fields[self.date_start]['type'])

        if self.date_delay:
            self.calendar_fields['date_delay'] = dict(name=self.date_delay,
                                                      kind=self.fields[self.date_delay]['type'])

        if self.date_stop:
            self.calendar_fields['date_stop'] = dict(name=self.date_stop,
                                                         kind=self.fields[self.date_stop]['type'])

        self.calendar_fields['day_length'] = self.day_length