[IMP] Project: documents button should open only it's own attachment, rather than whole ir.attachment object
bzr revid: rgaopenerp-20121030072656-8jxtkcbvkuxl17la
This commit is contained in:
parent
0678a45307
commit
01c00da9c8
|
@ -189,7 +189,24 @@ class project(osv.osv):
|
|||
def _get_alias_models(self, cr, uid, context=None):
|
||||
"""Overriden in project_issue to offer more options"""
|
||||
return [('project.task', "Tasks")]
|
||||
|
||||
def attachment_tree_view(self, cr, uid, ids, context):
|
||||
attachment = self.pool.get('ir.attachment')
|
||||
project_attachments = attachment.search(cr, uid, [('res_model', '=', 'project.project'), ('res_id', 'in', ids)], context=context)
|
||||
task_ids = self.pool.get('project.task').search(cr, uid, [('project_id', 'in', ids)])
|
||||
task_attachments = attachment.search(cr, uid, [('res_model', '=', 'project.task'), ('res_id', 'in', task_ids)], context=context)
|
||||
all_attachment = project_attachments + task_attachments
|
||||
|
||||
return {
|
||||
'name': _('Attachments'),
|
||||
'domain': [('id','in', all_attachment)],
|
||||
'res_model': 'ir.attachment',
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_id': False,
|
||||
'view_mode': 'tree,form',
|
||||
'view_type': 'form',
|
||||
'limit': 80,
|
||||
}
|
||||
# Lambda indirection method to avoid passing a copy of the overridable method when declaring the field
|
||||
_alias_models = lambda self, *args, **kwargs: self._get_alias_models(*args, **kwargs)
|
||||
_columns = {
|
||||
|
|
|
@ -88,7 +88,7 @@
|
|||
<div class="oe_right oe_button_box" name="buttons">
|
||||
<button name="%(act_project_project_2_project_task_all)d" string="Tasks"
|
||||
type="action" attrs="{'invisible':[('use_tasks','=', 0)]}"/>
|
||||
<button name="%(base.action_attachment)d" string="Documents" type="action"/>
|
||||
<button name="attachment_tree_view" string="Documents" type="object"/>
|
||||
</div>
|
||||
<group>
|
||||
<group>
|
||||
|
|
Loading…
Reference in New Issue