[IMP] improved function to open attachments.
bzr revid: tpa@tinyerp.com-20131224133813-5pbsd3jxbj1ypxk1
This commit is contained in:
parent
b3c535806f
commit
1b3f2f1a71
|
@ -561,21 +561,13 @@ class hr_job(osv.osv):
|
|||
action['context'] = str({'search_default_job_id': [job.id], 'default_job_id': job.id, 'default_user_id': job.user_id.id})
|
||||
return action
|
||||
|
||||
def attachment_tree_view(self, cr, uid, ids, context):
|
||||
def open_attachments(self, cr, uid, ids, context):
|
||||
#open attachments of job and related applicantions.
|
||||
model, action_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'base','action_attachment')
|
||||
action = self.pool.get(model).read(cr, uid, action_id, context=context)
|
||||
applicant_ids = self.pool.get('hr.applicant').search(cr, uid, [('job_id', 'in', ids)], context=context)
|
||||
domain = ['|', '&', ('res_model', '=', 'hr.job'), ('res_id', 'in', ids), '&',('res_model', '=', 'hr.applicant'), ('res_id', 'in', applicant_ids)]
|
||||
res_id = ids and ids[0] or False
|
||||
return {
|
||||
'name': _('Attachments'),
|
||||
'domain': domain,
|
||||
'res_model': 'ir.attachment',
|
||||
'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)
|
||||
}
|
||||
action['domain'] = str(['|', '&', ('res_model', '=', 'hr.job'), ('res_id', 'in', ids), '&',('res_model', '=', 'hr.applicant'), ('res_id', 'in', applicant_ids)])
|
||||
return action
|
||||
|
||||
class applicant_category(osv.osv):
|
||||
""" Category of applicant """
|
||||
|
|
|
@ -365,7 +365,7 @@
|
|||
</xpath>
|
||||
<div name="buttons" position="inside">
|
||||
<button string="Applications" name="%(action_hr_job_applications)d" context="{'default_user_id': user_id}" type="action"/>
|
||||
<button name="attachment_tree_view" string="Documents" type="object"/>
|
||||
<button name="open_attachments" string="Documents" type="object"/>
|
||||
</div>
|
||||
</field>
|
||||
</record>
|
||||
|
@ -430,7 +430,7 @@
|
|||
<span t-if="record.application_ids.raw_value.length lt 2"><t t-esc="record.application_ids.raw_value.length"/> Application</span>
|
||||
</a>
|
||||
<br/>
|
||||
<a t-if="record.document_ids.raw_value.length gt 0" name="attachment_tree_view" type="object">
|
||||
<a t-if="record.document_ids.raw_value.length gt 0" name="open_attachments" type="object">
|
||||
<span t-if="record.document_ids.raw_value.length gt 1"><t t-esc="record.document_ids.raw_value.length"/> Documents</span>
|
||||
<span t-if="record.document_ids.raw_value.length lt 2"><t t-esc="record.document_ids.raw_value.length"/> Document</span>
|
||||
</a>
|
||||
|
|
Loading…
Reference in New Issue