[MERGE] Forward porting of saas-1 until rev 8739
authorMartin Trigaux <mat@openerp.com>
Wed, 5 Jun 2013 09:04:53 +0000 (11:04 +0200)
committerMartin Trigaux <mat@openerp.com>
Wed, 5 Jun 2013 09:04:53 +0000 (11:04 +0200)
bzr revid: mat@openerp.com-20130605090453-e4mg37kms5j1r18n

12 files changed:
1  2 
addons/account/account_invoice.py
addons/auth_signup/res_users.py
addons/base_action_rule/base_action_rule.py
addons/crm/crm_lead.py
addons/mail/mail_mail.py
addons/mail/mail_message.py
addons/mail/mail_thread.py
addons/mail/static/src/js/mail.js
addons/portal/wizard/portal_wizard.py
addons/project/project.py
addons/project_issue/project_issue.py
addons/share/wizard/share_wizard.py

Simple merge
Simple merge
@@@ -62,10 -61,8 +62,11 @@@ class base_action_rule(osv.osv)
              help="When unchecked, the rule is hidden and will not be executed."),
          'sequence': fields.integer('Sequence',
              help="Gives the sequence order when displaying a list of rules."),
 +        'kind': fields.selection(
 +            [('on_create', 'On Creation'), ('on_write', 'On Update'), ('on_time', 'Based on Timed Condition')],
 +            string='When to Run'),
          'trg_date_id': fields.many2one('ir.model.fields', string='Trigger Date',
+             help="When should the condition be triggered. If present, will be checked by the scheduler. If empty, will be checked at creation and update.",
              domain="[('model_id', '=', model_id), ('ttype', 'in', ('date', 'datetime'))]"),
          'trg_date_range': fields.integer('Delay after trigger date',
              help="Delay after the trigger date." \
Simple merge
Simple merge
Simple merge
@@@ -449,70 -460,20 +460,84 @@@ class mail_thread(osv.AbstractModel)
          ir_attachment_obj.unlink(cr, uid, attach_ids, context=context)
          return True
  
+     def check_mail_message_access(self, cr, uid, mids, operation, model_obj=None, context=None):
+         """ mail.message check permission rules for related document. This method is
+             meant to be inherited in order to implement addons-specific behavior.
+             A common behavior would be to allow creating messages when having read
+             access rule on the document, for portal document such as issues. """
+         if not model_obj:
+             model_obj = self
+         if operation in ['create', 'write', 'unlink']:
+             model_obj.check_access_rights(cr, uid, 'write')
+             model_obj.check_access_rule(cr, uid, mids, 'write', context=context)
+         else:
+             model_obj.check_access_rights(cr, uid, operation)
+             model_obj.check_access_rule(cr, uid, mids, operation, context=context)
 +    def _get_formview_action(self, cr, uid, id, model=None, context=None):
 +        """ Return an action to open the document. This method is meant to be
 +            overridden in addons that want to give specific view ids for example.
 +
 +            :param int id: id of the document to open
 +            :param string model: specific model that overrides self._name
 +        """
 +        return {
 +                'type': 'ir.actions.act_window',
 +                'res_model': model or self._name,
 +                'view_type': 'form',
 +                'view_mode': 'form',
 +                'views': [(False, 'form')],
 +                'target': 'current',
 +                'res_id': id,
 +            }
 +
 +    def _get_inbox_action_xml_id(self, cr, uid, context=None):
 +        """ When redirecting towards the Inbox, choose which action xml_id has
 +            to be fetched. This method is meant to be inherited, at least in portal
 +            because portal users have a different Inbox action than classic users. """
 +        return ('mail', 'action_mail_inbox_feeds')
 +
 +    def message_redirect_action(self, cr, uid, context=None):
 +        """ For a given message, return an action that either
 +            - opens the form view of the related document if model, res_id, and
 +              read access to the document
 +            - opens the Inbox with a default search on the conversation if model,
 +              res_id
 +            - opens the Inbox with context propagated
 +
 +        """
 +        if context is None:
 +            context = {}
 +
 +        # default action is the Inbox action
 +        self.pool.get('res.users').browse(cr, SUPERUSER_ID, uid, context=context)
 +        act_model, act_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, *self._get_inbox_action_xml_id(cr, uid, context=context))
 +        action = self.pool.get(act_model).read(cr, uid, act_id, [])
 +
 +        # if msg_id specified: try to redirect to the document or fallback on the Inbox
 +        msg_id = context.get('params', {}).get('message_id')
 +        if not msg_id:
 +            return action
 +        msg = self.pool.get('mail.message').browse(cr, uid, msg_id, context=context)
 +        if msg.model and msg.res_id:
 +            action.update({
 +                'context': {
 +                    'search_default_model': msg.model,
 +                    'search_default_res_id': msg.res_id,
 +                }
 +            })
 +            if self.pool.get(msg.model).check_access_rights(cr, uid, 'read', raise_exception=False):
 +                try:
 +                    model_obj = self.pool.get(msg.model)
 +                    model_obj.check_access_rule(cr, uid, [msg.res_id], 'read', context=context)
 +                    if not hasattr(model_obj, '_get_formview_action'):
 +                        action = self.pool.get('mail.thread')._get_formview_action(cr, uid, msg.res_id, model=msg.model, context=context)
 +                    else:
 +                        action = model_obj._get_formview_action(cr, uid, msg.res_id, context=context)
 +                except (osv.except_osv, orm.except_orm):
 +                    pass
 +        return action
 +
      #------------------------------------------------------
      # Email specific
      #------------------------------------------------------
Simple merge
@@@ -172,8 -203,9 +203,9 @@@ class wizard_user(osv.osv_memory)
              @return: browse record of model res.users
          """
          res_users = self.pool.get('res.users')
 -        create_context = dict(context or {}, noshortcut=True)       # to prevent shortcut creation
 +        create_context = dict(context or {}, noshortcut=True, no_reset_password=True)       # to prevent shortcut creation
          values = {
+             'email': extract_email(wizard_user.email),
              'login': extract_email(wizard_user.email),
              'partner_id': wizard_user.partner_id.id,
              'groups_id': [(6, 0, [])],
Simple merge
Simple merge
Simple merge