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

Programming error when trying to relate a custom module to crm.lead

By
Eric Geens
on 7/10/14, 6:11 PM 521 views

I created a simple module crm.notesattach (related to crm.lead) with the following model :

------

class crm_notesattach(osv.Model) :

    _name = 'crm.notesattach'
    _description = 'Notes and Attachments'
    _rec_name = 'subject'
    _columns = {
         'subject': fields.char('Summary', size = 255),
         'note_date': fields.datetime('Date'),
        'opportunity_id': fields.many2one('crm.lead', 'ID', readonly = True),
        'partner_id': fields.many2one('res.partner', 'Customer'),
        'user_id' : fields.many2one('res.users', 'Owner'),
        'type': fields.selection([('meeting','Meeting minutes'),('intern','Internal note'),('back','Background info'),('comment','Additional comments'),('other','Other')], 'Type'),
        'body': fields.html('Contents'),
        'has_attach': fields.boolean('Include attachment'),
        'attach':fields.binary('Attachment'),
#        'attachments_ids': fields.many2many('ir.attachment', string="Add an attachment"),
    }
    _defaults={
        'note_date': fields.datetime.now,
        'user_id': lambda self,cr,uid,ctx: uid,
    }
        
crm_notesattach()

----

When I install the module, I get the following error :

Programming Error : There is no reference field 'id' found for 'crm.notesattach'

When I change the 'opportunity_id' to 'id' (as in crm.lead), then the module installs but when I try to save the lines, I'll get another error :

ProgrammingError: column specified more than once LINE 1: ...rm_notesattach" (id,"user_id","has_attach","type","id","note...

I've been looking around on various forums but didn't find any answer... Has anyone an idea ? Maybe I'm just overlooking something.

Thanks for any suggestion to solve this.

0
Eric Geens
On 7/10/14, 6:59 PM

Sorry, I've got it working.

It was caused by conflicting 'id's...

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

1 follower(s)

Stats

Asked: 7/10/14, 6:11 PM
Seen: 521 times
Last updated: 3/16/15, 8:10 AM