diff --git a/addons/pad/LICENSE b/addons/pad/LICENSE new file mode 100644 index 00000000000..cff5dae3a7b --- /dev/null +++ b/addons/pad/LICENSE @@ -0,0 +1,15 @@ +OpenERP, Open Source Management Solution +Copyright © 2010 OpenERP SA (). + +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 Lice +along with this program. If not, see . \ No newline at end of file diff --git a/addons/pad/__init__.py b/addons/pad/__init__.py new file mode 100644 index 00000000000..6a60bdb9799 --- /dev/null +++ b/addons/pad/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +import company_pad diff --git a/addons/pad/__openerp__.py b/addons/pad/__openerp__.py new file mode 100644 index 00000000000..4b5e3ca959e --- /dev/null +++ b/addons/pad/__openerp__.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +{ + 'name': 'Enhanced support for (Ether)Pad attachments', + 'version': '1.0', + 'category': 'Generic Modules/Others', + 'description': """ +Adds enhanced support for (Ether)Pad attachments in the web client, lets the +company customize which Pad installation should be used to link to new pads +(by default, pad.openerp.com) + """, + 'author': 'OpenERP SA', + 'website': 'http://openerp.com', + 'depends': ['base'], + 'update_xml': [ + 'company_pad.xml' + ], + 'installable': True, + 'active': False, + 'web': True, +} diff --git a/addons/pad/company_pad.py b/addons/pad/company_pad.py new file mode 100644 index 00000000000..1e687704eac --- /dev/null +++ b/addons/pad/company_pad.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +from osv import fields, osv + +class company_pad(osv.osv): + _inherit = 'res.company' + _columns = { + 'pad_index': fields.char('Pad root URL', size=64, required=True, + help="The root URL of the company's pad " + "instance"), + } + _defaults = { + 'pad_index': 'http://pad.openerp.com' + } + +company_pad() diff --git a/addons/pad/company_pad.xml b/addons/pad/company_pad.xml new file mode 100644 index 00000000000..754776715d7 --- /dev/null +++ b/addons/pad/company_pad.xml @@ -0,0 +1,16 @@ + + + + res.company.form.pad + res.company + form + + + + + + + + + + diff --git a/addons/pad/web/__init__.py b/addons/pad/web/__init__.py new file mode 100644 index 00000000000..95542e91e3e --- /dev/null +++ b/addons/pad/web/__init__.py @@ -0,0 +1,2 @@ +import controllers +import editors diff --git a/addons/pad/web/controllers.py b/addons/pad/web/controllers.py new file mode 100644 index 00000000000..faa5d0ad54b --- /dev/null +++ b/addons/pad/web/controllers.py @@ -0,0 +1,34 @@ +import urlparse + +import cherrypy + +from openobject.tools import expose + +import openerp.controllers +from openerp.utils import rpc, TinyDict + +class Piratepad(openerp.controllers.SecuredController): + _cp_path = "/piratepad" + + def get_root(self): + return rpc.RPCProxy('res.company').read( + [rpc.session.company_id], ['pad_index'])[0]['pad_index'] + + def make_url(self, pad_name): + return urlparse.urljoin( + self.get_root(), '-'.join(pad_name.split()) + ) + + @expose('json', methods=('POST',)) + def link(self, pad_name): + params, data = TinyDict.split(cherrypy.session['params']) + ctx = dict(rpc.session.context, + default_res_model=params.model, default_res_id=params.id, + active_id=False, active_ids=[]) + + pad_link = self.make_url(pad_name) + attachment_id = rpc.RPCProxy('ir.attachment').create({ + 'name': pad_name, + 'url': pad_link, + }, ctx) + return {'id': attachment_id, 'name': pad_name, 'url': pad_link} diff --git a/addons/pad/web/editors.py b/addons/pad/web/editors.py new file mode 100644 index 00000000000..62ff426a623 --- /dev/null +++ b/addons/pad/web/editors.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +import openobject.templating + +class SidebarTemplateEditor(openobject.templating.TemplateEditor): + templates = ['/openerp/widgets/templates/sidebar.mako'] + ADD_ATTACHMENT_BUTTON = u'id="add-attachment"' + BINARY_ATTACHMENTS_FORM = u'
${_("Pad")}\n''' + \ + output[form_opener_insertion:] + return output + + def edit(self, template, template_text): + output = super(SidebarTemplateEditor, self).edit(template, template_text) + + output = self.insert_pad_link(output) + + form_insertion_point = output.index(self.BINARY_ATTACHMENTS_FORM) + return output[:form_insertion_point] + ''' + + + + +
+ + ''' + output[form_insertion_point:] diff --git a/addons/profile_tools/installer.py b/addons/profile_tools/installer.py index 6ea024aebbe..fac23e8299d 100644 --- a/addons/profile_tools/installer.py +++ b/addons/profile_tools/installer.py @@ -31,6 +31,11 @@ class misc_tools_installer(osv.osv_memory): 'idea':fields.boolean('Ideas Box',help='Promote ideas of the employees, votes and discussion on best ideas.'), 'share':fields.boolean('Share Data / Portals',help='This module allows you to easily give restricted access of any filtered list of objects to any customer or supplier.' \ 'Just click on the share icon to give access to your customers on their project\'s tasks, support requests, invoices, etc.'), + 'pad': fields.boolean('Native pad integration', + help="This module creates a tighter integration between a Pad " + "instance of your choosing and your OpenERP Web Client by " + "letting you easily link pads to OpenERP objects via " + "OpenERP attachments."), } _defaults = { } diff --git a/addons/profile_tools/misc_tools_installer.xml b/addons/profile_tools/misc_tools_installer.xml index d81936756a6..b3d343d8c30 100644 --- a/addons/profile_tools/misc_tools_installer.xml +++ b/addons/profile_tools/misc_tools_installer.xml @@ -30,6 +30,7 @@ +