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/wizard | |
| parent | 9fe0f6fa83b84d0806359bdc2a3ae31dfb7e997a (diff) | |
| parent | 3d22bb8b55d48e5ee8226f023555f003288b157a (diff) | |
[MERGE]: Merge with latest trunk
bzr revid: rpa@tinyerp.com-20111102052827-0bctjrhb4amyg6pl
Diffstat (limited to 'addons/share/wizard')
| -rw-r--r-- | addons/share/wizard/share_wizard.py | 58 | ||||
| -rw-r--r-- | addons/share/wizard/share_wizard_view.xml | 6 |
2 files changed, 33 insertions, 31 deletions
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> |
