Odoo Help

1

1
5 Answers
3
Avatar

Axel Mendoza

--Axel Mendoza--
13613
| 8 8 10
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full-time employee trying to understand what to do and how

Reach me at aekroft@gmail.com

Axel Mendoza
09/09/15 04.25

Yes this could be done in a form, like this:

<div class="oe_right oe_button_box" name="buttons">
    <button class="oe_inline oe_stat_button" type="object" name="open_inbox" icon="fa-envelope" context="{'partner_id': partner_id}">
        <field string="Unread" name="unread_count" widget="statinfo"/>
    </button>
</div>

With that code in your form view you will see a button that show the number of unread messages in your inbox using the field unread_count that you need to implement as a function field for return the integer number. Also you need to implement a method open_inbox that returns the action view definition, or you could directly define your button type="action" and the name="%(action_record_id)d"

This code is using ir.actions.client because that is the type of action for the inbox

def open_inbox(self, cr, uid, ids, context=None):
    mod_obj = self.pool.get('ir.model.data')
    act_obj = self.pool.get('ir.actions.client')
    res_id = mod_obj.xmlid_to_res_id(cr, uid, 'mail.action_mail_inbox_feeds', raise_if_not_found=True)
    result = act_obj.read(cr, uid, [res_id], context=context)[0]
    return result
3
Prasanth ks
10/09/15 03.43

Try this function:- I write this function to get the messages for my own purpose, you just make the code as your needs,

def inbox_tree_view(self, cr, uid, ids, context):
project_obj=self.pool.get('project.project')
msg_obj=self.pool.get('mail.message')
data=self.browse(cr,uid,ids[0])
matter_name=data.name

message_ids = msg_obj.search(cr, uid, [])
domain_id_list=[]
for message_id in message_ids:
matter_name_messahe=msg_obj.browse(cr,uid,message_id).parent_id.record_name
if matter_name==matter_name_messahe:
domain_id_list.append(message_id)


print'domain_id_list-----------',domain_id_list
domain = [('id','in', domain_id_list)]
res_id = ids and ids[0] or False
print"ppppppppppppppppppp", res_id
return {
'name': _('Inbox Messages'),
'domain': domain,
'res_model': 'mail.message',
'type': 'ir.actions.act_window',
'view_id': False,
'view_mode': 'tree,form',
'view_type': 'form',
'limit': 80,
'context': "{'default_res_model': '%s','default_res_id': %d}" % (self._name, res_id)
}

Ask a Question
Writer
Keep Informed
2 follower(s)
About This Community

This platform 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.

Register
Odoo Training Center

Access to our eLearning platform and experience all Odoo Apps through learning videos, use cases and quizzes.

Test it now