[ADD] attachment_edit

This commit is contained in:
Holger Brunn
2015-05-05 15:11:48 +02:00
parent e438d7c7a0
commit ab62d11f54
11 changed files with 310 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

@@ -0,0 +1,22 @@
.openerp .oe_sidebar .oe_dropdown_menu li .oe-sidebar-attachment-edit
{
position: absolute;
right: 32px;
top: 0px;
display: none;
}
.openerp .oe_sidebar .oe_dropdown_menu li:hover .oe-sidebar-attachment-edit
{
display: inherit;
}
.openerp .oe_sidebar .oe_dropdown_menu li .oe-sidebar-attachment-edit:hover
{
text-decoration: none;
color: white;
background: #8786b7;
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.4);
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
border-radius: 2px;
}

View File

@@ -0,0 +1,52 @@
//-*- coding: utf-8 -*-
//############################################################################
//
// OpenERP, Open Source Management Solution
// This module copyright (C) 2015 Therp BV <http://therp.nl>.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
//############################################################################
openerp.attachment_edit = function(instance)
{
instance.web.Sidebar.include(
{
on_attachments_loaded: function(attachments)
{
var result = this._super.apply(this, arguments);
this.$el.find('.oe-sidebar-attachment-edit')
.click(this.on_attachment_edit);
return result;
},
on_attachment_edit: function(e)
{
var $target = jQuery(e.currentTarget),
attachment_id = parseInt($target.attr('data-id')),
title = $target.attr('title');
e.preventDefault();
e.stopPropagation();
this.do_action({
type: 'ir_actions.act_window',
name: title,
views: [[false, 'form']],
res_model: 'ir.attachment',
res_id: attachment_id,
flags: {
initial_mode: 'edit',
},
});
},
})
}

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates>
<t t-extend="Sidebar">
<t t-jquery="a.oe_sidebar_delete_item" t-operation="before">
<a t-if="section.name == 'files' and !item.callback and item.url" href="#" class="oe-sidebar-attachment-edit" t-att-data-id="item.id" t-attf-title="Edit #{item.name}">
<img t-att-src='_s + "/web/static/src/img/pencil.gif"' width="12" height="12" border="0"/>
</a>
</t>
</t>
</templates>