diff options
Diffstat (limited to 'addons/share/wizard/share_wizard.py')
| -rw-r--r-- | addons/share/wizard/share_wizard.py | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/addons/share/wizard/share_wizard.py b/addons/share/wizard/share_wizard.py index f48ad7654e7..161cbfba112 100644 --- a/addons/share/wizard/share_wizard.py +++ b/addons/share/wizard/share_wizard.py @@ -33,6 +33,7 @@ from openerp.osv import expression from openerp.tools.translate import _ from openerp.tools.safe_eval import safe_eval import openerp +from openerp.exceptions import UserError _logger = logging.getLogger(__name__) FULL_ACCESS = ('perm_read', 'perm_write', 'perm_create', 'perm_unlink') @@ -58,7 +59,7 @@ class share_wizard(osv.TransientModel): The error_message should have been translated with _(). """ if not condition: - raise osv.except_osv(_('Sharing access cannot be created.'), error_message) + raise UserError(error_message) def has_group(self, cr, uid, module, group_xml_id, context=None): """Returns True if current user is a member of the group identified by the module, group_xml_id pair.""" @@ -201,8 +202,7 @@ class share_wizard(osv.TransientModel): def go_step_1(self, cr, uid, ids, context=None): wizard_data = self.browse(cr,uid,ids,context)[0] if wizard_data.user_type == 'emails' and not self.has_email(cr, uid, context=context): - raise osv.except_osv(_('No email address configured'), - _('You must configure your email address in the user preferences before using the Share button.')) + raise UserError(_('You must configure your email address in the user preferences before using the Share button.')) model, res_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'share', 'action_share_wizard_step1') action = self.pool[model].read(cr, uid, [res_id], context=context)[0] action['res_id'] = ids[0] @@ -631,9 +631,8 @@ class share_wizard(osv.TransientModel): group_id, model_id=model.id, domain=str(related_domain), rule_name=rule_name, restrict=True, context=context) except Exception: - _logger.exception('Failed to create share access') - raise osv.except_osv(_('Sharing access cannot 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.')) + _logger.info('Failed to create share access', exc_info=True) + raise UserError(_('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 _check_preconditions(self, cr, uid, wizard_data, context=None): self._assert(wizard_data.action_id and wizard_data.access_mode, @@ -755,7 +754,7 @@ class share_wizard(osv.TransientModel): res_id = cond[2] # Record id not found: issue if res_id <= 0: - raise osv.except_osv(_('Record id not found'), _('The share engine has not been able to fetch a record_id for your invitation.')) + raise UserError(_('The share engine has not been able to fetch a record_id for your invitation.')) self.pool[model.model].message_subscribe(cr, uid, [res_id], new_ids + existing_ids, context=context) # self.send_invite_email(cr, uid, wizard_data, context=context) # self.send_invite_note(cr, uid, model.model, res_id, wizard_data, context=context) @@ -810,7 +809,7 @@ class share_wizard(osv.TransientModel): notification_obj = self.pool.get('mail.notification') user = self.pool.get('res.users').browse(cr, UID_ROOT, uid) if not user.email: - raise osv.except_osv(_('Email Required'), _('The current user must have an email address configured in User Preferences to be able to send outgoing emails.')) + raise UserError(_('The current user must have an email address configured in User Preferences to be able to send outgoing emails.')) # TODO: also send an HTML version of this mail for result_line in wizard_data.result_line_ids: @@ -841,7 +840,7 @@ class share_wizard(osv.TransientModel): mail_mail = self.pool.get('mail.mail') user = self.pool.get('res.users').browse(cr, UID_ROOT, uid) if not user.email: - raise osv.except_osv(_('Email Required'), _('The current user must have an email address configured in User Preferences to be able to send outgoing emails.')) + raise UserError(_('The current user must have an email address configured in User Preferences to be able to send outgoing emails.')) # TODO: also send an HTML version of this mail mail_ids = [] |
