Hi there gurus!
I've developed a custom module (V8) following the new API syntax and I'l like to use the same functionality available in the Projects module which links the project form with the attachments form via a button. The method that achieves this in Projects follows the old syntax, so I'd like to know how to rewrite the following piece of code according to the new API:
def attachment_tree_view(self, cr, uid, ids, context):
domain = [ ('res_model', '=', 'project.project'), ('res_id', 'in', 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': 'kanban,tree,form',
'view_type': 'form',
'limit': 80,
'context': "{'default_res_model': '%s','default_res_id': %d}" % (self._name, res_id)
}
I would have thought it to be something like this, but unfortunatelly I don't get it to work:
@api.one
def attachment_tree_view(self):
domain = [ ('res_model', '=', 'project.project'), ('res_id', '=', self.id)]
res_id = self.id
return {
'name': _('Attachments'),
'domain': domain,
'res_model': 'ir.attachment',
'type': 'ir.actions.act_window',
'view_id': False,
'view_mode': 'kanban,tree,form',
'view_type': 'form',
'limit': 80,
'context': "{'default_res_model': '%s','default_res_id': %d}" % (self._name, res_id)
}
Any help will be much appreciated.