diff options
| author | Rucha (Open ERP) <rpa@tinyerp.com> | 2011-11-02 10:58:27 +0530 |
|---|---|---|
| committer | Rucha (Open ERP) <rpa@tinyerp.com> | 2011-11-02 10:58:27 +0530 |
| commit | 2fdecf4717080ea98a514b67dedefc27d76c6727 (patch) | |
| tree | bb54dd0e81af0bbf999fee1110fecb9e507f51e1 /addons/share | |
| parent | 9fe0f6fa83b84d0806359bdc2a3ae31dfb7e997a (diff) | |
| parent | 3d22bb8b55d48e5ee8226f023555f003288b157a (diff) | |
[MERGE]: Merge with latest trunk
bzr revid: rpa@tinyerp.com-20111102052827-0bctjrhb4amyg6pl
Diffstat (limited to 'addons/share')
29 files changed, 192 insertions, 222 deletions
diff --git a/addons/share/__openerp__.py b/addons/share/__openerp__.py index f6a0c93285d..954f915c885 100644 --- a/addons/share/__openerp__.py +++ b/addons/share/__openerp__.py @@ -3,6 +3,7 @@ # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). +# Copyright (C) 2010-2011 OpenERP SA (<http://www.openerp.com>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -22,7 +23,7 @@ { "name" : "Web Share", - "version" : "1.5", + "version" : "2.0", "depends" : ["base", "mail"], "author" : "OpenERP SA", "category": 'Hidden', @@ -53,6 +54,8 @@ synchronization with other companies, etc. 'installable': True, 'web': True, 'certificate' : '001301246528927038493', + 'js': ['static/src/js/share.js'], + 'css': ['static/src/css/share.css'], 'images': ['images/share_wizard.jpeg','images/sharing_wizard_step1.jpeg', 'images/sharing_wizard_step2.jpeg'], } diff --git a/addons/share/i18n/bg.po b/addons/share/i18n/bg.po index e02d771b4a1..63e155565c1 100644 --- a/addons/share/i18n/bg.po +++ b/addons/share/i18n/bg.po @@ -14,8 +14,8 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2011-09-05 05:47+0000\n" -"X-Generator: Launchpad (build 13830)\n" +"X-Launchpad-Export-Date: 2011-10-19 05:40+0000\n" +"X-Generator: Launchpad (build 14157)\n" #. module: share #: code:addons/share/web/editors.py:15 diff --git a/addons/share/i18n/ca.po b/addons/share/i18n/ca.po index 0260df1ea3c..8ad55b62ba6 100644 --- a/addons/share/i18n/ca.po +++ b/addons/share/i18n/ca.po @@ -14,8 +14,8 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2011-09-05 05:47+0000\n" -"X-Generator: Launchpad (build 13830)\n" +"X-Launchpad-Export-Date: 2011-10-19 05:40+0000\n" +"X-Generator: Launchpad (build 14157)\n" #. module: share #: code:addons/share/web/editors.py:15 diff --git a/addons/share/i18n/cs.po b/addons/share/i18n/cs.po index 84b05baa483..af35439892c 100644 --- a/addons/share/i18n/cs.po +++ b/addons/share/i18n/cs.po @@ -14,8 +14,8 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2011-09-06 04:40+0000\n" -"X-Generator: Launchpad (build 13861)\n" +"X-Launchpad-Export-Date: 2011-10-19 05:40+0000\n" +"X-Generator: Launchpad (build 14157)\n" "X-Poedit-Language: Czech\n" #. module: share diff --git a/addons/share/i18n/da.po b/addons/share/i18n/da.po index d4839ed6e84..a0d9cfe2a03 100644 --- a/addons/share/i18n/da.po +++ b/addons/share/i18n/da.po @@ -14,8 +14,8 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2011-09-24 04:59+0000\n" -"X-Generator: Launchpad (build 14012)\n" +"X-Launchpad-Export-Date: 2011-10-19 05:40+0000\n" +"X-Generator: Launchpad (build 14157)\n" #. module: share #: code:addons/share/web/editors.py:15 diff --git a/addons/share/i18n/de.po b/addons/share/i18n/de.po index 67ece2db868..1a331379ad7 100644 --- a/addons/share/i18n/de.po +++ b/addons/share/i18n/de.po @@ -13,8 +13,8 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2011-09-05 05:47+0000\n" -"X-Generator: Launchpad (build 13830)\n" +"X-Launchpad-Export-Date: 2011-10-19 05:41+0000\n" +"X-Generator: Launchpad (build 14157)\n" #. module: share #: code:addons/share/web/editors.py:15 diff --git a/addons/share/i18n/es.po b/addons/share/i18n/es.po index 3eb8ef9f3e4..61956919dc1 100644 --- a/addons/share/i18n/es.po +++ b/addons/share/i18n/es.po @@ -14,8 +14,8 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2011-09-05 05:48+0000\n" -"X-Generator: Launchpad (build 13830)\n" +"X-Launchpad-Export-Date: 2011-10-19 05:41+0000\n" +"X-Generator: Launchpad (build 14157)\n" #. module: share #: code:addons/share/web/editors.py:15 diff --git a/addons/share/i18n/fi.po b/addons/share/i18n/fi.po index cbeda3f75e9..c18cfc6d139 100644 --- a/addons/share/i18n/fi.po +++ b/addons/share/i18n/fi.po @@ -8,14 +8,14 @@ msgstr "" "Project-Id-Version: openobject-addons\n" "Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n" "POT-Creation-Date: 2011-01-11 11:16+0000\n" -"PO-Revision-Date: 2011-06-13 06:18+0000\n" -"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" +"PO-Revision-Date: 2011-10-25 12:21+0000\n" +"Last-Translator: Jussi Mikkola <Unknown>\n" "Language-Team: Finnish <fi@li.org>\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2011-09-05 05:47+0000\n" -"X-Generator: Launchpad (build 13830)\n" +"X-Launchpad-Export-Date: 2011-10-27 05:22+0000\n" +"X-Generator: Launchpad (build 14197)\n" #. module: share #: code:addons/share/web/editors.py:15 @@ -149,7 +149,7 @@ msgstr "Jako velho: vaihe 2" #. module: share #: view:share.wizard:0 msgid "Share wizard: step 0" -msgstr "JJako velho: vaihe 0" +msgstr "" #. module: share #: view:share.wizard:0 @@ -183,7 +183,7 @@ msgstr "Valmis" #: field:share.wizard,user_ids:0 #: field:share.wizard.user,user_id:0 msgid "Users" -msgstr "" +msgstr "Käyttäjät" #. module: share #: code:addons/share/wizard/share_wizard.py:103 diff --git a/addons/share/i18n/fr.po b/addons/share/i18n/fr.po index 62c3f3b7624..0d2c29dd140 100644 --- a/addons/share/i18n/fr.po +++ b/addons/share/i18n/fr.po @@ -13,8 +13,8 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2011-09-05 05:47+0000\n" -"X-Generator: Launchpad (build 13830)\n" +"X-Launchpad-Export-Date: 2011-10-19 05:41+0000\n" +"X-Generator: Launchpad (build 14157)\n" #. module: share #: code:addons/share/web/editors.py:15 diff --git a/addons/share/i18n/gl.po b/addons/share/i18n/gl.po index d84b13d711b..96cf95882f2 100644 --- a/addons/share/i18n/gl.po +++ b/addons/share/i18n/gl.po @@ -14,8 +14,8 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2011-09-05 05:47+0000\n" -"X-Generator: Launchpad (build 13830)\n" +"X-Launchpad-Export-Date: 2011-10-19 05:41+0000\n" +"X-Generator: Launchpad (build 14157)\n" #. module: share #: code:addons/share/web/editors.py:15 diff --git a/addons/share/i18n/hr.po b/addons/share/i18n/hr.po index 32ef546bf1b..8ab09b1df48 100644 --- a/addons/share/i18n/hr.po +++ b/addons/share/i18n/hr.po @@ -14,8 +14,8 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2011-09-05 05:48+0000\n" -"X-Generator: Launchpad (build 13830)\n" +"X-Launchpad-Export-Date: 2011-10-19 05:41+0000\n" +"X-Generator: Launchpad (build 14157)\n" #. module: share #: code:addons/share/web/editors.py:15 diff --git a/addons/share/i18n/hu.po b/addons/share/i18n/hu.po index cd26e236bb2..b70fc82be99 100644 --- a/addons/share/i18n/hu.po +++ b/addons/share/i18n/hu.po @@ -14,8 +14,8 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2011-09-05 05:47+0000\n" -"X-Generator: Launchpad (build 13830)\n" +"X-Launchpad-Export-Date: 2011-10-19 05:41+0000\n" +"X-Generator: Launchpad (build 14157)\n" #. module: share #: code:addons/share/web/editors.py:15 diff --git a/addons/share/i18n/it.po b/addons/share/i18n/it.po index 2d538e10431..f86882443d9 100644 --- a/addons/share/i18n/it.po +++ b/addons/share/i18n/it.po @@ -14,8 +14,8 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2011-09-05 05:47+0000\n" -"X-Generator: Launchpad (build 13830)\n" +"X-Launchpad-Export-Date: 2011-10-19 05:41+0000\n" +"X-Generator: Launchpad (build 14157)\n" #. module: share #: code:addons/share/web/editors.py:15 diff --git a/addons/share/i18n/mn.po b/addons/share/i18n/mn.po index 23fce984996..a771519c8d0 100644 --- a/addons/share/i18n/mn.po +++ b/addons/share/i18n/mn.po @@ -14,8 +14,8 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2011-09-05 05:48+0000\n" -"X-Generator: Launchpad (build 13830)\n" +"X-Launchpad-Export-Date: 2011-10-19 05:41+0000\n" +"X-Generator: Launchpad (build 14157)\n" #. module: share #: code:addons/share/web/editors.py:15 diff --git a/addons/share/i18n/nl.po b/addons/share/i18n/nl.po index a8223b013c8..c341e57074e 100644 --- a/addons/share/i18n/nl.po +++ b/addons/share/i18n/nl.po @@ -14,8 +14,8 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2011-09-05 05:47+0000\n" -"X-Generator: Launchpad (build 13830)\n" +"X-Launchpad-Export-Date: 2011-10-19 05:41+0000\n" +"X-Generator: Launchpad (build 14157)\n" #. module: share #: code:addons/share/web/editors.py:15 diff --git a/addons/share/i18n/pl.po b/addons/share/i18n/pl.po index 02850ba09b3..6e375fb9b29 100644 --- a/addons/share/i18n/pl.po +++ b/addons/share/i18n/pl.po @@ -14,8 +14,8 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2011-09-05 05:48+0000\n" -"X-Generator: Launchpad (build 13830)\n" +"X-Launchpad-Export-Date: 2011-10-19 05:41+0000\n" +"X-Generator: Launchpad (build 14157)\n" #. module: share #: code:addons/share/web/editors.py:15 diff --git a/addons/share/i18n/pt.po b/addons/share/i18n/pt.po index 19816329531..cf0f13a7927 100644 --- a/addons/share/i18n/pt.po +++ b/addons/share/i18n/pt.po @@ -14,8 +14,8 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2011-09-05 05:48+0000\n" -"X-Generator: Launchpad (build 13830)\n" +"X-Launchpad-Export-Date: 2011-10-19 05:41+0000\n" +"X-Generator: Launchpad (build 14157)\n" #. module: share #: code:addons/share/web/editors.py:15 diff --git a/addons/share/i18n/pt_BR.po b/addons/share/i18n/pt_BR.po index 8619a36b4d1..356a09cf6c4 100644 --- a/addons/share/i18n/pt_BR.po +++ b/addons/share/i18n/pt_BR.po @@ -14,8 +14,8 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2011-09-05 05:48+0000\n" -"X-Generator: Launchpad (build 13830)\n" +"X-Launchpad-Export-Date: 2011-10-19 05:41+0000\n" +"X-Generator: Launchpad (build 14157)\n" #. module: share #: code:addons/share/web/editors.py:15 diff --git a/addons/share/i18n/ru.po b/addons/share/i18n/ru.po index 217c056bbed..976a0086685 100644 --- a/addons/share/i18n/ru.po +++ b/addons/share/i18n/ru.po @@ -14,8 +14,8 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2011-09-05 05:48+0000\n" -"X-Generator: Launchpad (build 13830)\n" +"X-Launchpad-Export-Date: 2011-10-19 05:41+0000\n" +"X-Generator: Launchpad (build 14157)\n" #. module: share #: code:addons/share/web/editors.py:15 diff --git a/addons/share/i18n/zh_CN.po b/addons/share/i18n/zh_CN.po index 41880d08961..7de45b699f2 100644 --- a/addons/share/i18n/zh_CN.po +++ b/addons/share/i18n/zh_CN.po @@ -14,8 +14,8 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2011-09-05 05:48+0000\n" -"X-Generator: Launchpad (build 13830)\n" +"X-Launchpad-Export-Date: 2011-10-19 05:41+0000\n" +"X-Generator: Launchpad (build 14157)\n" #. module: share #: code:addons/share/web/editors.py:15 diff --git a/addons/share/share_view.xml b/addons/share/share_view.xml index 98a10a3cec8..315f750a7f6 100644 --- a/addons/share/share_view.xml +++ b/addons/share/share_view.xml @@ -1,15 +1,15 @@ <?xml version="1.0" encoding="utf-8"?> <openerp> - <data> + <data> <record id="view_groups_form" model="ir.ui.view"> <field name="name">res.groups.form</field> <field name="model">res.groups</field> <field name="type">form</field> <field name="inherit_id" ref="base.view_groups_form"/> <field name="arch" type="xml"> - <group name="default_filters" position="inside"> + <field name="name" position="after"> <field name="share"/> - </group> + </field> </field> </record> </data> diff --git a/addons/share/static/src/css/share.css b/addons/share/static/src/css/share.css new file mode 100644 index 00000000000..3b47a065b1e --- /dev/null +++ b/addons/share/static/src/css/share.css @@ -0,0 +1,13 @@ + +.openerp li.oe-share { + background: url(../img/share.png) no-repeat; + padding-left: 20px; +} + +.openerp a.oe-share { + background: url(../img/share.png) no-repeat; + display: block; + float: left; + width: 20px; + height: 20px; +} diff --git a/addons/share/static/src/js/share.js b/addons/share/static/src/js/share.js new file mode 100644 index 00000000000..6d02a39cf1f --- /dev/null +++ b/addons/share/static/src/js/share.js @@ -0,0 +1,83 @@ + +openerp.share = function(instance) { +var QWeb = instance.web.qweb; +QWeb.add_template('/share/static/src/xml/share.xml'); + +function launch_wizard(self, view) { + var action = view.widget_parent.action; + var Share = new instance.web.DataSet(self, 'share.wizard', view.dataset.get_context()); + var domain = view.dataset.domain; + + if (view.fields_view.type == 'form') { + domain = new instance.web.CompoundDomain(domain, [['id', '=', view.datarecord.id]]); + } + + Share.create({ + name: action.name, + domain: domain, + action_id: action.id, + }, function(result) { + var share_id = result.result; + var step1 = Share.call('go_step_1', [[share_id],], function(result) { + var action = result; + self.do_action(action); + }); + }); +} + +var _has_share = null; +function if_has_share(yes, no) { + if (!_has_share) { + _has_share = $.Deferred(function() { + var self = this; + var session = instance.webclient.session; + session.on_session_invalid.add_last(function() { _has_share = null; }); + var func = new instance.web.Model(session, "share.wizard").get_func("has_share"); + func(session.uid).pipe(function(res) { + if(res) { + self.resolve(); + } else { + self.reject(); + } + }); + }); + } + _has_share.done(yes).fail(no); +} + + +instance.web.Sidebar = instance.web.Sidebar.extend({ + add_default_sections: function() { + this._super(); + var self = this; + if_has_share(function() { + self.add_items('other', [{ + label: 'Share', + callback: self.on_sidebar_click_share, + classname: 'oe-share', + }]); + }); + }, + on_sidebar_click_share: function(item) { + var view = this.widget_parent + launch_wizard(this, view); + }, +}); + +instance.web.ViewManagerAction.include({ + start: function() { + var self = this; + if_has_share(function() { + self.$element.find('a.oe-share').click(self.on_click_share); + }, function() { + self.$element.find('a.oe-share').remove(); + }); + return this._super.apply(this, arguments); + }, + on_click_share: function(e) { + e.preventDefault(); + launch_wizard(this, this.views[this.active_view].controller); + }, +}); + +}; diff --git a/addons/share/static/src/xml/share.xml b/addons/share/static/src/xml/share.xml new file mode 100644 index 00000000000..9a1363846a0 --- /dev/null +++ b/addons/share/static/src/xml/share.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- vim:fdl=1: +--> +<templates id="template" xml:space="preserve"> + + <t t-extend="ViewManagerAction"> + <t t-jquery=".oe-shortcut-toggle" t-operation="after"> + <a class="oe-share" href="#share" title="Share this in 2 clicks..."> + <!--<img src="/share/static/src/img/share.png"/>--> + </a> + </t> + </t> + +</templates> diff --git a/addons/share/web/__init__.py b/addons/share/web/__init__.py deleted file mode 100644 index f95bb222c10..00000000000 --- a/addons/share/web/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -import controllers -import editors
\ No newline at end of file diff --git a/addons/share/web/controllers.py b/addons/share/web/controllers.py deleted file mode 100644 index e682c8d9709..00000000000 --- a/addons/share/web/controllers.py +++ /dev/null @@ -1,49 +0,0 @@ -import urlparse -import cherrypy - -from openobject import rpc -from openobject.tools import expose, ast - -import openerp.controllers - - - -class ShareWizardController(openerp.controllers.SecuredController): - _cp_path = "/share" - - @expose() - def index(self, domain, context, view_id, search_domain='[]', action_id=None): - context = ast.literal_eval(context) - - if not action_id: - # This should not be needed anymore, but just in case users are - # running the module with an older version of the web client... - - # to remove soon-ish - action_id = rpc.RPCProxy('ir.actions.act_window').search( - [('view_id','=',int(view_id))], context=context) - if not action_id: return "" - - action_id = action_id[0] - - domain = ast.literal_eval(domain) - domain.extend(ast.literal_eval(search_domain)) - - scheme, netloc, _, _, _ = urlparse.urlsplit(cherrypy.request.base) - share_root_url = urlparse.urlunsplit(( - scheme, netloc, '/openerp/login', - 'db=%(dbname)s&user=%(login)s&password=%(password)s', '')) - - context.update( - #active_ids=share_wiz_id, - #active_id=share_wiz_id[0], - _terp_view_name='Share Wizard', - share_root_url=share_root_url) - Share = rpc.RPCProxy('share.wizard') - sharing_view_id = Share.create({ - 'domain': str(domain), - 'action_id': action_id and int(action_id) - }, context) - return openerp.controllers.actions.execute( - Share.go_step_1([sharing_view_id], context), - ids=[sharing_view_id], context=context) diff --git a/addons/share/web/editors.py b/addons/share/web/editors.py deleted file mode 100644 index 677de4a8317..00000000000 --- a/addons/share/web/editors.py +++ /dev/null @@ -1,94 +0,0 @@ -# -*- coding: utf-8 -*- -import openobject.templating - -class FormEditor(openobject.templating.TemplateEditor): - templates = ['/openerp/controllers/templates/form.mako'] - MAIN_FORM_BODY = u'id="main_form_body"' - - def insert_share_button(self, output): - # Insert the share button on the form title H1 line, at the very end, - # but only if the user is a member of the sharing group - share_opener_insertion = output.index('% endif', output.index( - '/view_diagram/process', - output.index(self.MAIN_FORM_BODY))) + len('% endif') - return output[:share_opener_insertion] + ''' - <% - if 'has_share' not in cp.session: - cp.session['has_share'] = rpc.RPCProxy('share.wizard').has_share() - %> - % if cp.session['has_share'] and buttons.toolbar and not is_dashboard: - <a id="share-opener" href="#share" title="${_('Share this in 2 clicks...')}"> - <img id="share-opener-img" src="/share/static/images/share.png"/> - </a> - <script type="text/javascript"> - jQuery(document).ready(function() { - jQuery("#share-opener").click(function() { - jQuery(this).attr( - "href", - openobject.http.getURL('/share', { - context: jQuery("#_terp_context").val(), - domain: jQuery("#_terp_domain").val(), - view_id: jQuery("#_terp_view_id").val(), - action_id: jQuery("#_terp_action_id").val(), - search_domain: jQuery("#_terp_view_type").val() == "form" ? - ("[('id','=',"+jQuery("#_terp_id").val()+")]") : - jQuery("#_terp_search_domain").val(), - })); - }); - }); - </script> - \n - % endif -''' + output[share_opener_insertion:] - - def edit(self, template, template_text): - return self.insert_share_button( - super(FormEditor, self).edit(template, template_text)) - - -class SidebarEditor(openobject.templating.TemplateEditor): - templates = ['/openerp/widgets/templates/sidebar.mako'] - ADD_SHARE_SECTION = u'id="sidebar"' - - def insert_share_link(self, output): - # Insert the link on the line, right after the link to open the - # attachment form, but only if the user is a member of the sharing group - share_opener_insertion = output.index( - '\n', - output.index(self.ADD_SHARE_SECTION)) + 1 - return output[:share_opener_insertion] + ''' - <% - if 'has_share' not in cp.session: - cp.session['has_share'] = rpc.RPCProxy('share.wizard').has_share() - %> - % if cp.session['has_share']: - <div id="share-wizard" class="sideheader-a"><h2>${_("Sharing")}</h2></div> - <ul class="clean-a"> - <li> - <a id="sharing" href="#share">${_("Share")}</a> - </li> - </ul> - <script type="text/javascript"> - jQuery(document).ready(function() { - jQuery("#sharing").click(function() { - jQuery(this).attr( - "href", - openobject.http.getURL('/share', { - context: jQuery("#_terp_context").val(), - domain: jQuery("#_terp_domain").val(), - view_id: jQuery("#_terp_view_id").val(), - action_id: jQuery("#_terp_action_id").val(), - search_domain: jQuery("#_terp_view_type").val() == "form" ? - ("[('id','=',"+jQuery("#_terp_id").val()+")]") : - jQuery("#_terp_search_domain").val(), - })); - }); - }); - </script> - \n - % endif -''' + output[share_opener_insertion:] - - def edit(self, template, template_text): - return self.insert_share_link( - super(SidebarEditor, self).edit(template, template_text)) diff --git a/addons/share/wizard/share_wizard.py b/addons/share/wizard/share_wizard.py index b66ccc2dd47..1cd8104100c 100644 --- a/addons/share/wizard/share_wizard.py +++ b/addons/share/wizard/share_wizard.py @@ -119,24 +119,38 @@ class share_wizard(osv.osv_memory): values['name'] = action.name return super(share_wizard,self).create(cr, uid, values, context=context) + def share_url_template(self, cr, uid, _ids, context=None): + # NOTE: take _ids in parameter to allow usage through browse_record objects + base_url = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url', default='', context=context) + if base_url: + base_url += '/?db=%(dbname)s&login=%(login)s' + return base_url + + def _share_root_url(self, cr, uid, ids, _fieldname, _args, context=None): + result = dict.fromkeys(ids, '') + data = dict(dbname=cr.dbname, login='') + for this in self.browse(cr, uid, ids, context=context): + result[this.id] = this.share_url_template() % data + return result + _columns = { 'action_id': fields.many2one('ir.actions.act_window', 'Action to share', required=True, help="The action that opens the screen containing the data you wish to share."), 'domain': fields.char('Domain', size=256, help="Optional domain for further data filtering"), - 'user_type': fields.selection(_user_type_selection,'Users to share with', + 'user_type': fields.selection(lambda s, *a, **k: s._user_type_selection(*a, **k),'Users to share with', required=True, help="Select the type of user(s) you would like to share data with."), 'new_users': fields.text("Emails"), 'access_mode': fields.selection([('readonly','Can view'),('readwrite','Can edit')],'Access Mode', required=True, help="Access rights to be granted on the shared documents."), 'result_line_ids': fields.one2many('share.wizard.result.line', 'share_wizard_id', 'Summary', readonly=True), - 'share_root_url': fields.char('Share Access URL', size=512, readonly=True, tooltip='Main access page for users that are granted shared access'), + 'share_root_url': fields.function(_share_root_url, string='Share Access URL', type='char', size=512, readonly=True, + help='Main access page for users that are granted shared access'), 'name': fields.char('Share Title', size=64, required=True, help="Title for the share (displayed to users as menu and shortcut name)"), 'message': fields.text("Personal Message", help="An optional personal message, to be included in the e-mail notification."), } _defaults = { - 'user_type' : 'new', + 'user_type' : 'emails', 'domain': lambda self, cr, uid, context, *a: context.get('domain', '[]'), - 'share_root_url': lambda self, cr, uid, context, *a: context.get('share_root_url') or _('Please specify "share_root_url" in context'), 'action_id': lambda self, cr, uid, context, *a: context.get('action_id'), 'access_mode': 'readonly', } @@ -537,12 +551,11 @@ class share_wizard(osv.osv_memory): try: domain = safe_eval(wizard_data.domain) if domain: - domain_expr = expression.expression(domain) for rel_field, model in fields_relations: related_domain = [] if not rel_field: continue for element in domain: - if domain_expr._is_leaf(element): + if expression.is_leaf(element): left, operator, right = element left = '%s.%s'%(rel_field, left) element = left, operator, right @@ -555,19 +568,6 @@ class share_wizard(osv.osv_memory): raise osv.except_osv(_('Sharing access could not be created'), _('Sorry, the current screen and filter you are trying to share are not supported at the moment.\nYou may want to try a simpler filter.')) - def _finish_result_lines(self, cr, uid, wizard_data, share_group_id, context=None): - """Perform finalization of the share, and populate the summary""" - share_root_url = wizard_data.share_root_url - format_url = '%(dbname)s' in share_root_url - for result in wizard_data.result_line_ids: - # share_root_url may contain placeholders for dbname, login and password - share_url = (share_root_url % \ - {'login': quote_plus(result.user_id.login), - 'password': '', # kept empty for security reasons - 'dbname': quote_plus(cr.dbname)}) \ - if format_url else share_root_url - result.write({'share_url': share_url}, context=context) - def _check_preconditions(self, cr, uid, wizard_data, context=None): self._assert(wizard_data.action_id and wizard_data.access_mode, _('Action and Access Mode are required to create a shared access'), @@ -662,15 +662,6 @@ class share_wizard(osv.osv_memory): # C. self._create_indirect_sharing_rules(cr, current_user, wizard_data, group_id, obj1, context=context) - # so far, so good -> check summary results and return them - self._finish_result_lines(cr, uid, wizard_data, group_id, context=context) - - # update share URL to make it generic - generic_share_url = wizard_data.share_root_url % {'dbname': cr.dbname, - 'login': '', - 'password': ''} - wizard_data.write({'share_root_url': generic_share_url}, context=context) - # refresh wizard_data wizard_data = self.browse(cr, uid, ids[0], context=context) @@ -742,11 +733,20 @@ share_wizard() class share_result_line(osv.osv_memory): _name = 'share.wizard.result.line' _rec_name = 'user_id' + + + def _share_url(self, cr, uid, ids, _fieldname, _args, context=None): + result = dict.fromkeys(ids, '') + for this in self.browse(cr, uid, ids, context=context): + data = dict(dbname=cr.dbname, login=this.login) + result[this.id] = this.share_wizard_id.share_url_template() % data + return result + _columns = { 'user_id': fields.many2one('res.users', required=True, readonly=True), 'login': fields.related('user_id', 'login', string='Login', type='char', size=64, required=True, readonly=True), 'password': fields.char('Password', size=64, readonly=True), - 'share_url': fields.char('Share URL', size=512, required=True), + 'share_url': fields.function(_share_url, string='Share URL', type='char', size=512), 'share_wizard_id': fields.many2one('share.wizard', 'Share Wizard', required=True), 'newly_created': fields.boolean('Newly created', readonly=True), } diff --git a/addons/share/wizard/share_wizard_view.xml b/addons/share/wizard/share_wizard_view.xml index 5087b85d7bd..128b32b07da 100644 --- a/addons/share/wizard/share_wizard_view.xml +++ b/addons/share/wizard/share_wizard_view.xml @@ -29,6 +29,10 @@ <field name="type">form</field> <field name="arch" type="xml"> <form string="Grant instant access to your documents"> + <group name="groups_group" colspan="4" col="4"> + <separator colspan="4" string="Who do you want to share with?"/> + <field name="user_type" /> + </group> <group colspan="4" name="emails_group" attrs="{'invisible':[('user_type','!=','emails')]}"> <separator colspan="4" string="Share with these people (one e-mail per line)"/> <field colspan="4" nolabel="1" name="new_users" attrs="{'required':[('user_type','=','emails')]}"/> @@ -78,7 +82,6 @@ - 'action_id' (id of action) - 'domain' (string expression for full domain to apply as sent to server, with dynamic data like 'uid' replaced by actual value (i.e. after eval)!) - - 'share_root_url' : URL for direct access to share page (may include %(login)s and %(password)s placeholders) --> <record id="action_share_wizard" model="ir.actions.act_window"> <field name="name">Share Wizard</field> @@ -94,7 +97,6 @@ - 'action_id' (id of action) - 'domain' (string expression for full domain to apply as sent to server, with dynamic data like 'uid' replaced by actual value (i.e. after eval)!) - - 'share_root_url' : URL for direct access to share page (may include %(login)s and %(password)s placeholders) --> <record id="action_share_wizard_step1" model="ir.actions.act_window"> <field name="name">Share Wizard</field> |
