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

Error saving record in model inherited from crm.meeting?

By
Anabela Damas
on 6/17/13, 5:17 PM 2,709 views

Hi, I've inherit the 'crm.meeting' and change the name to 'radar.eventos 'but now I can't save a record. I've this error :

   2013-06-17 19:06:56,060 27957 ERROR teste17junho openerp.netsvc: ValidateError
    The value "radar.eventos,4" for the field "calendar_attendee.ref" is not in the selection
    Traceback (most recent call last):
      File "/opt/openerp-7.0-20130516-231144/openerp/netsvc.py", line 292, in dispatch_rpc
        result = ExportService.getService(service_name).dispatch(method, params)
      File "/opt/openerp-7.0-20130516-231144/openerp/service/web_services.py", line 626, in dispatch
        res = fn(db, uid, *params)
      File "/opt/openerp-7.0-20130516-231144/openerp/osv/osv.py", line 188, in execute_kw
        return self.execute(db, uid, obj, method, *args, **kw or {})
      File "/opt/openerp-7.0-20130516-231144/openerp/osv/osv.py", line 144, in wrapper
        raise except_osv(inst.name, inst.value)
    except_osv: (u'ValidateError', u'The value "radar.eventos,4" for the field "calendar_attendee.ref" is not in the selection')

My code is: mymodule/mymodule.py

class radar_eventos(osv.osv):
    """ Model for Events """
    _name = 'radar.eventos'
    _description = "Events"
    _inherit = 'crm.meeting'
    _columns = {
        'state': fields.selection([
            ('novo', 'Novo'),
            ('cancelado', 'Cancelado'),
            ('agendado', 'Agendado'),
            ('emcurso', 'Em Curso'),
            ('realizado', 'Realizado'),
            ], 'Status', readonly=True),

        'eventotipo_ids': fields.many2many('radar.eventos.tipo', 'radar_tipo_eventos_rel',
            'evento_id','tipo_id','Tipo de Evento'),
        'id_evento': fields.char('Id Evento', size=64, readonly=True),
        'registo_id': fields.many2one('registos.vigilancia',u'Registo de Vigilância'),
        'accoes_tarefas_id': fields.one2many('accoes.tarefas','evento_id', u'Acções e Tarefas'),
        'ideias_id': fields.one2many('gestao.ideias','evento_id', u'Ideias'),
        'objectivos': fields.text('Objectivos'),

        #fields many2one - new tables
        'attendee_ids': fields.many2many('calendar.attendee', 'radar_attendee_rel', 'event_id', 'attendee_id', 'Attendees', states={'done': [('readonly', True)]}),

        'partner_ids': fields.many2many('res.partner', 'radar_partner_rel', 'meeting_id', 'partner_id',
            string='Attendees', states={'done': [('readonly', True)]}),

    }
    _defaults = {
            'state': 'novo',
    }

    def create(self, cr, uid, vals, context=None):
        if vals.get('id_evento') == None:
            vals['id_evento'] = self.pool.get('ir.sequence').get(cr, uid, 'radar.eventos.id_evento')
        return super(radar_eventos, self).create(cr, uid, vals, context)

    def copy(self, cr, uid, id, default=None, context=None):
        default.update({
            'id_evento': self.pool.get('ir.sequence').get(cr, uid, 'radar.eventos.id_evento'),
        })
        return super(radar_eventos, self).create(cr, uid, vals, context)
radar_eventos()

mymodule/mymodule_view.xml

    <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.view_crm_meeting_form" />
    <field name="arch" type="xml">
    <xpath expr="/form/field[@name='state']" position="replace">
        <header>
        <field name="state" widget="statusbar"
            statusbar_visible="novo,agendado,emcurso,realizado,cancelado"/>
       </header>
    </xpath>

    <xpath expr="/form/sheet/div" position="after">
        <group>
        <group>
            <field name="id_evento"/>
        </group>
        <group>
            <field name="registo_id"/>
        </group>
        </group>
    </xpath>

    <xpath expr="/form/sheet/notebook/page/group/group/field[@name='categ_ids']" position="replace">
        <field name="eventotipo_ids" widget="many2many_tags" style="width: 50%%"/>
    </xpath>

    <xpath expr="/form/sheet/notebook/page/label[@for='description']" position="replace">
    </xpath>
    <xpath expr="/form/sheet/notebook/page/field[@name='description']" position="replace">
        <separator string="Descrição"/>
        <field name="description" placeholder="Descrição..."/>
        <separator string="Objectivos"/>
        <field name="objectivos" placeholder="Objectivos..."/>
    </xpath>

    <xpath expr="/form/sheet/notebook/page[@string='Invitations']" 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 CRM Meeting -->

    <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.view_crm_meeting_tree" />
    <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='user_id']" position="replace">
        <field name="user_id" string="Responsável"/>
    </xpath>
    <xpath expr="/tree/field[@name='state']" position="replace">
        <field name="state"/>
    </xpath>
    </field>
</record> 

<!-- Calendar View para os Eventos herdada do CRM Meeting -->
<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.view_crm_meeting_calendar" />
    <field name="arch" type="xml">
    <xpath expr="/calendar" position="replace">
        <calendar string="Events" date_start="date" color="user_id" date_stop="date_deadline" date_delay="duration">
        <field name="name"/>
        <field name="user_id"/>
        <field name="eventotipo_ids"/>
        </calendar>
    </xpath>
    </field>
</record>

<!-- search View para os Eventos herdada do CRM Meeting -->


<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_crm_meeting_search" />
    <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 CRM Meeting -->

<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">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" name="Eventos" parent="menu_gestao_ideias"></menuitem>
    <menuitem id="menu_eventos_action" name="Eventos" parent="menu_eventos" action="action_radar_eventos"></menuitem>

I don't understand what am I doing wrong, can you please help me ?

I made a debug and in the function _links_get the res as this :

 [{'id': 1, 'name': u'Partner', 'object': u'res.partner'},
 {'id': 2, 'name': u'Product', 'object': u'product.product'},
 {'id': 3, 'name': u'Invoice', 'object': u'account.invoice'},
 {'id': 4, 'name': u'Voucher', 'object': u'account.voucher'},
 {'id': 5, 'name': u'Sales Order', 'object': u'sale.order'},
 {'id': 6, 'name': u'Event', 'object': u'calendar.event'},
 {'id': 7, 'name': u'Meeting', 'object': u'crm.meeting'},
 {'id': 8, 'name': u'Serial Number', 'object': u'stock.production.lot'},
 {'id': 9, 'name': u'Purchase Order', 'object': u'purchase.order'},
 {'id': 10, 'name': u'Project', 'object': u'project.project'},
 {'id': 11, 'name': u'Project task', 'object': u'project.task'}]

I think that I'm getting the error above because my module isn't in this list. I created my inherit with another name (radar.eventos) because I don't wanted to change the calendar of other modules, I wanted to keep the original in the other modules of Openerp and create a new one with new tables to my new module.

2

Sandeep

--Sandeep--
6083
| 6 5 8
Delhi, India
--Sandeep--
Python OpenERP Developer http://in.linkedin.com/pub/sandeep-rana/3b/a16/786/
Sandeep
On 6/18/13, 3:17 AM

Hi

the the class name always treated a table in openERP , if you are want use same object crm.meeting then you must

change the class name crm_meeting or object name crm.meeting

so plz be careful in this part

Thanks
Sandeep

Hi, I update my question above. If I understand what you told me to do, you told me to do like this :

_name = 'crm.meeting'
_inherit = 'crm.meeting'

But I wanted to create a new object with new tables, and keep the crm.meeting original to the other modules.

I made some debug and the res in the_links_get function doesn't have my module so it isn't in the seletion of field res in calendar.attendee... Do you know how to solve this ?

Versão Integral, Anabela Damas
on 6/18/13, 7:57 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

0 follower(s)

Stats

Asked: 6/17/13, 5:17 PM
Seen: 2709 times
Last updated: 3/16/15, 8:10 AM