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.