Hi guys
I would love to be able to get all e-mails that are sent to Odoo (so incoming on Odoo) in a dropdown in the project view. I then want to create a dropdown where the user can see every title of an email, choose one and save it on a project. The idea is that the user can also directly click on the item and that it opens up the correct e-mail.
Is this possible and how should I do it?
I assume it is possible since you have the model 'mail.mail' which contains all e-mails and you can fetch them in the view?
What I tried so far is to add a new field on the form from project_view.xml (<record id="edit_project" model="ir.ui.view">) by doing so:
<group col="4">
<field name="user_id" string="Project Manager"
attrs="{'readonly':[('state','in',['close', 'cancelled'])]}"
context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'project.group_project_manager']}"/>
<newline/>
<field name="partner_id" on_change="onchange_partner_id(partner_id)" string="Customer"/>
<newline/>
<field name="email_id" on_change="onchange_email_id(email_id)" string="Emails"/>
</group>
I then created the new field email_id in project.py in the columns = {} under the class project like this:
fields = {
//Lots of irrelevant code'state': fields.selection([('template', 'Template'),
('draft','New'),
('open','In Progress'),
('cancelled', 'Cancelled'),
('pending','Pending'),
('close','Closed')],
'Status', required=True, copy=False),
'doc_count': fields.function(
_get_attached_docs, string="Number of documents attached", type='integer'
),
'email_id': fields.many2one(
'mail.mail', '??', help='This holds all e-mails that you recieved.'),
}
And finally in project.py I created an on_change function like this:
def onchange_email_id(self, cr, uid, ids, part=False, context=None):
email_obj = self.pool.get('mail.mail')
return {'value': email_obj}
Everything looks pretty good but I get one more error when I want to create / modify a project:


So what am I doing wrong or am I missing?
Yenthe