Hi,
I was trying to do a new object similar to calendar.event but keeping the original. I try like this in mymodule/mymodule.py:
class radar_eventos(osv.osv):
""" Model for Events """
_name = 'radar.eventos'
_description = "Events"
_inherit = "calendar.event"
_columns = {
'eventotipo_ids': fields.many2many('radar.eventos.tipo', 'radar_tipo_eventos_rel',
'evento_id','tipo_id','Tipo de Evento'),
}
radar_eventos()
In mymodule/mymodule_view.xml:
<menuitem id="menu_eventos" name="Eventos" parent="menu_gestao_ideias"></menuitem>
<!-- Form View para os Eventos herdada do base_calendar-->
<record model="ir.ui.view" id="view_radar_eventos_form">
<field name="name">Eventos Form</field>
<field name="model">radar.eventos</field>
<field name="inherit_id" ref="base_calendar.event_form_view" />
<field name="arch" type="xml">
<xpath expr="/form/header/field[@name='state']" position="replace">
<field name="state" widget="statusbar"
statusbar_visible="novo,agendado,emcurso,realizado,cancelado"/>
</xpath>
<xpath expr="/form/sheet/group" position="before">
<group>
<group>
<field name="id_evento"/>
</group>
<group>
<field name="registo_id"/>
</group>
</group>
</xpath>
<xpath expr="/form/sheet/notebook/page/group[@col='6']" position="replace">
<group col="4" >
<group col="2" colspan="2">
<separator string="Visibility" colspan="2"/>
<group>
<field name="user_id" string="Responsible User"/>
<field name="show_as" string="Show Time as"/>
<field name="class" string="Privacy"/>
<field name="recurrent_id_date" invisible="1"/>
<field name="recurrent_id" invisible="1"/>
</group>
</group>
<group col="2" colspan="2">
<separator string="Informação" colspan="2"/>
<group>
<field name="eventotipo_ids" widget="many2many_tags" style="width: 50%%"/>
</group>
</group>
</group>
</xpath>
<xpath expr="/form/sheet/notebook/page/field[@name='description']" position="replace">
<field name="description" placeholder="Descrição..."/>
<separator string="Objectivos"/>
<field name="objectivos" placeholder="Objectivos..."/>
</xpath>
<xpath expr="/form/sheet/notebook/page[@string='Invitation Detail']" position="after">
<page string="Ideias">
<separator string="Informação sobre as ideias ...."/>
<field name="ideias_id"/>
</page>
<page string="Acções e Tarefas">
<separator string="Informação sobre as tarefas ...."/>
<field name="accoes_tarefas_id"/>
</page>
</xpath>
</field>
</record>
<!-- Tree View para os Eventos herdada do base_calendar-->
<record model="ir.ui.view" id="view_radar_eventos_tree">
<field name="name">Eventos Tree</field>
<field name="model">radar.eventos</field>
<field name="inherit_id" ref="base_calendar.event_tree_view" />
<field name="arch" type="xml">
<xpath expr="/tree/field[@name='name']" position="before">
<field name="id_evento"/>
<field name="registo_id" string="Reg. Vigilância"/>
</xpath>
<xpath expr="/tree/field[@name='name']" position="after">
<field name="eventotipo_ids"/>
<field name="description" string="Descrição"/>
<field name="objectivos"/>
</xpath>
<xpath expr="/tree/field[@name='state']" position="replace">
<field name="user_id" string="Responsável"/>
<field name="state"/>
</xpath>
</field>
</record>
<!-- Calendar View para os Eventos herdada do base_calendar-->
<record model="ir.ui.view" id="view_radar_eventos_calendar">
<field name="name">Eventos Calendar</field>
<field name="model">radar.eventos</field>
<field name="priority" eval="2"/>
<field name="inherit_id" ref="base_calendar.event_calendar_view" />
<field name="arch" type="xml">
<xpath expr="/calendar" position="replace">
<calendar string="Events" date_start="date" color="user_id" date_delay="duration">
<field name="name"/>
<field name="class"/>
<field name="show_as"/>
</calendar>
</xpath>
</field>
</record>
<!-- search View para os Eventos herdada do base_calendar-->
<record id="view_radar_eventos_search" model="ir.ui.view">
<field name="name">Eventos Search</field>
<field name="model">radar.eventos</field>
<field name="inherit_id" ref="base_calendar.view_calendar_event_filter" />
<field name="arch" type="xml">
<xpath expr="/search/field[@name='name']" position="after">
<field name="eventotipo_ids"/>
<field name="id_evento"/>
<field name="registo_id"/>
</xpath>
</field>
</record>
<!-- Action View para os Eventos herdada do base_calendar-->
<record id="action_radar_eventos" model="ir.actions.act_window">
<field name="name">Eventos</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">radar.eventos</field>
<field name="view_type">form</field>
<!--<field name="view_mode">tree,form</field>-->
<field name="view_mode">calendar,tree,form</field>
<field name="search_view_id" ref="view_radar_eventos_search"/>
</record>
<record model="ir.actions.act_window.view" id="action_radar_eventos_calendar">
<field name="act_window_id" ref="action_radar_eventos"/>
<field name="sequence" eval="1"/>
<field name="view_mode">calendar</field>
<field name="view_id" ref="view_radar_eventos_calendar"/>
</record>
<record model="ir.actions.act_window.view" id="action_radar_eventos_tree">
<field name="act_window_id" ref="action_radar_eventos"/>
<field name="sequence" eval="2"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_radar_eventos_tree"/>
</record>
<record model="ir.actions.act_window.view" id="action_radar_eventos_form">
<field name="act_window_id" ref="action_radar_eventos"/>
<field name="sequence" eval="3"/>
<field name="view_mode">form</field>
<field name="view_id" ref="view_radar_eventos_form"/>
</record>
<menuitem id="menu_eventos_action" name="Eventos" parent="menu_eventos" action="action_radar_eventos"></menuitem>
With this code I don't have erros but the view is disorganized, like if I didn't have defined a view.
But if I change the name of the model to "calendar.event" everything works fine.... I really want to keep the original and create my calendar based on the calendar of openerp, someone knows what I'm doing wrong ?
Thanks
UPDATE:
With this last code the view it's ok when I go through the menu, but when I use the field in a relation view (in a view of an object that it is related to my new object radar.eventos) the view of radar.eventos is like it doesn't have any view defined. Do I forget some action view ?
Thanks