Ejemplo n.º 1
0
    def open_task(self, cr, uid, ids, context=None):
        """
        Open Task Form for Project Task.
        @param cr: the current row, from the database cursor,
        @param uid: the current user’s ID for security checks,
        @param ids: List of project task’s IDs
        @param context: A standard dictionary for contextual values
        @return: Dictionary value which open Project Task form.
        """

        data_pool = self.pool.get('ir.model.data')
        value = {}
        task_form_id = data_pool.get_object(cr, uid, 'project', 'view_task_form2')
        task_tree_id = data_pool.get_object(cr, uid, 'project', 'view_task_tree2')
        task_calendar_id = data_pool.get_object(cr, uid, 'project', 'view_task_calendar')
        for id in ids:
            value = {
                    'name': _('Tasks'),
                    'view_type': 'form',
                    'view_mode': 'form,tree',
                    'res_model': 'project.task',
                    'view_id': False,
                    'views': [(task_form_id, 'form'), (task_tree_id, 'tree'), (task_calendar_id, 'calendar')],
                    'type': 'ir.actions.act_window',
                    'res_id': base_calendar.base_calendar_id2real_id(id),
                    'nodestroy': True
                    }

        return value
Ejemplo n.º 2
0
    def open_task(self, cr, uid, ids, context=None):
        """
        Open Task Form for Project Task.
        @param cr: the current row, from the database cursor,
        @param uid: the current user’s ID for security checks,
        @param ids: List of project task’s IDs
        @param context: A standard dictionary for contextual values
        @return: Dictionary value which open Project Task form.
        """

        data_pool = self.pool.get("ir.model.data")
        value = {}
        task_form_id = data_pool.get_object(cr, uid, "project", "view_task_form2")
        task_tree_id = data_pool.get_object(cr, uid, "project", "view_task_tree2")
        task_calendar_id = data_pool.get_object(cr, uid, "project", "view_task_calendar")
        for id in ids:
            value = {
                "name": _("Tasks"),
                "view_type": "form",
                "view_mode": "form,tree",
                "res_model": "project.task",
                "view_id": False,
                "views": [(task_form_id, "form"), (task_tree_id, "tree"), (task_calendar_id, "calendar")],
                "type": "ir.actions.act_window",
                "res_id": base_calendar.base_calendar_id2real_id(id),
                "nodestroy": True,
            }

        return value
Ejemplo n.º 3
0
 def case_open(self, cr, uid, ids, *args):
     """Confirms meeting
     @param self: The object pointer
     @param cr: the current row, from the database cursor,
     @param uid: the current user’s ID for security checks,
     @param ids: List of Meeting Ids
     @param *args: Tuple Value for additional Params
     """
     res = super(crm_meeting, self).case_open(cr, uid, ids, args)
     for (id, name) in self.name_get(cr, uid, ids):
         message = _("The meeting '%s' has been confirmed.") % name
         id = base_calendar.base_calendar_id2real_id(id)
         self.log(cr, uid, id, message)
     return res
Ejemplo n.º 4
0
 def case_open(self, cr, uid, ids, *args):
     """Confirms meeting
     @param self: The object pointer
     @param cr: the current row, from the database cursor,
     @param uid: the current user’s ID for security checks,
     @param ids: List of Meeting Ids
     @param *args: Tuple Value for additional Params
     """
     res = super(crm_meeting, self).case_open(cr, uid, ids, args)
     for (id, name) in self.name_get(cr, uid, ids):
         message = _("The meeting '%s' has been confirmed.") % name
         id=base_calendar.base_calendar_id2real_id(id)
         self.log(cr, uid, id, message)
     return res
 def export_cal(self, cr, uid, ids, context=None):
     """
         @param self: The object pointer
         @param cr: the current row, from the database cursor,
         @param uid: the current user’s ID for security checks,
         @param ids: List of CRM Meeting’s IDs
         @param context: A standard dictionary for contextual values
     """
     if context is None: context = {}
     ids = map(lambda x: base_calendar.base_calendar_id2real_id(x), ids)
     event_data = self.read(cr, uid, ids, context=context)
     event_obj = self.pool.get('basic.calendar.event')
     context.update({'model': self._name})
     ical = event_obj.export_cal(cr, uid, event_data, context=context)
     return ical.serialize()
Ejemplo n.º 6
0
 def export_cal(self, cr, uid, ids, context=None):
     """
         @param self: The object pointer
         @param cr: the current row, from the database cursor,
         @param uid: the current user’s ID for security checks,
         @param ids: List of CRM Meeting’s IDs
         @param context: A standard dictionary for contextual values
     """
     if context is None: context = {}
     ids = map(lambda x: base_calendar.base_calendar_id2real_id(x), ids)
     event_data = self.read(cr, uid, ids, context=context)
     event_obj = self.pool.get('basic.calendar.event')
     context.update({'model': self._name})
     ical = event_obj.export_cal(cr, uid, event_data, context=context)
     return ical.serialize()
Ejemplo n.º 7
0
    def case_close(self, cr, uid, ids, *args):
        for (id, name) in self.name_get(cr, uid, ids):
                message = _("The task '%s' has been closed.") % name
                id=base_calendar.base_calendar_id2real_id(id)
                self.log(cr, uid, id, message)

        self.write(cr, uid, ids, {'date_closed': time.strftime('%Y-%m-%d %H:%M:%S')})
        cases = self.browse(cr, uid, ids)
        for case in cases:
            data = {'state': 'done', 'active': True}
            if not case.user_id:
                data['user_id'] = uid
            self.write(cr, uid, case.id, data)
        self._action(cr, uid, cases, 'done')
        return True
Ejemplo n.º 8
0
    def open_task(self, cr, uid, ids, context=None):
        """
        Open Task Form for Project Task.
        @param cr: the current row, from the database cursor,
        @param uid: the current user’s ID for security checks,
        @param ids: List of project task’s IDs
        @param context: A standard dictionary for contextual values
        @return: Dictionary value which open Project Task form.
        """

        data_pool = self.pool.get('ir.model.data')
        value = {}
        task_form_id = data_pool.get_object(cr, uid, 'project',
                                            'view_task_form2')
        task_tree_id = data_pool.get_object(cr, uid, 'project',
                                            'view_task_tree2')
        task_calendar_id = data_pool.get_object(cr, uid, 'project',
                                                'view_task_calendar')
        for id in ids:
            value = {
                'name':
                _('Tasks'),
                'view_type':
                'form',
                'view_mode':
                'form,tree',
                'res_model':
                'project.task',
                'view_id':
                False,
                'views': [(task_form_id, 'form'), (task_tree_id, 'tree'),
                          (task_calendar_id, 'calendar')],
                'type':
                'ir.actions.act_window',
                'res_id':
                base_calendar.base_calendar_id2real_id(id),
                'nodestroy':
                True
            }

        return value
Ejemplo n.º 9
0
    def case_open(self, cr, uid, ids, *args):
        """Confirms task
        @param self: The object pointer
        @param cr: the current row, from the database cursor,
        @param uid: the current user’s ID for security checks,
        @param ids: List of task Ids
        @param *args: Tuple Value for additional Params
        """
        if ids:
            for (id, name) in self.name_get(cr, uid, ids):
                message = _("The task '%s' has been confirmed.") % name
                id=base_calendar.base_calendar_id2real_id(id)
                self.log(cr, uid, id, message)

            cases = self.browse(cr, uid, ids)
            for case in cases:
                data = {'state': 'open', 'active': True}
                if not case.user_id:
                    data['user_id'] = uid
                self.write(cr, uid, case.id, data)

            self._action(cr, uid, cases, 'open')
        return True
    def do_invite(self, cr, uid, ids, context=None):
        """
        Invites attendee for meeting..
        @param cr: the current row, from the database cursor,
        @param uid: the current user’s ID for security checks,
        @param ids: List of base calendar invite attendee’s IDs.
        @param context: A standard dictionary for contextual values
        @return: Dictionary of {}.
        """

        if context is None:
            context = {}

        model = False
        context_id = context and context.get('active_id', False) or False
        if not context or not context.get('model'):
            return {'type': 'ir.actions.act_window_close'}
        else:
            model = context.get('model')

        model_field = context.get('attendee_field', False)
        obj = self.pool.get(model)
        res_obj = obj.browse(cr, uid, context_id, context=context)
        att_obj = self.pool.get('calendar.attendee')
        user_obj = self.pool.get('res.users')
        current_user = user_obj.browse(cr, uid, uid, context=context)
        for datas in self.read(cr, uid, ids, context=context):
            type = datas.get('type')
            vals = []
            mail_to = []
            attendees = []
            ref = {}

            if not model == 'calendar.attendee':
                if context_id:
                    ref = {'ref': '%s,%s' % (model, base_calendar.base_calendar_id2real_id(context_id))}
                else:
                    return {'type': 'ir.actions.act_window_close'}
            if type == 'internal':
                
                if not datas.get('user_ids'):
                    raise osv.except_osv(_('Error!'), ("Please select any User"))
                for user_id in datas.get('user_ids'):
                    user = user_obj.browse(cr, uid, user_id)
                    res = {
                           'user_id': user_id,
                           'email': user.address_id.email
                           }
                    res.update(ref)
                    vals.append(res)
                    if user.address_id.email:
                        mail_to.append(user.address_id.email)

            elif  type == 'external' and datas.get('email'):
                res = {'email': datas['email']}
                res.update(ref)
                vals.append(res)
                mail_to.append(datas['email'])

            elif  type == 'partner':
                add_obj = self.pool.get('res.partner.address')
                for contact in  add_obj.browse(cr, uid, datas['contact_ids']):
                    res = {
                           'partner_address_id': contact.id,
                           'email': contact.email
                           }
                    res.update(ref)
                    vals.append(res)
                    if contact.email:
                        mail_to.append(contact.email)

            for att_val in vals:
                if model == 'calendar.attendee':
                    att = att_obj.browse(cr, uid, context_id)
                    att_val.update({
                        'parent_ids': [(4, att.id)],
                        'ref': att.ref and (att.ref._name + ',' +str(att.ref.id)) or False
                        })

                attendees.append(att_obj.create(cr, uid, att_val))
            if model_field:
                for attendee in attendees:
                    obj.write(cr, uid, res_obj.id, {model_field: [(4, attendee)]})

            if datas.get('send_mail'):
                if not mail_to:
                    name =  map(lambda x: x[1], filter(lambda x: type==x[0], \
                                       self._columns['type'].selection))
                    raise osv.except_osv(_('Error!'), ("%s must have an email  Address to send mail") %(name[0]))
                att_obj._send_mail(cr, uid, attendees, mail_to, \
                       email_from = current_user.user_email or tools.config.get('email_from', False))

        return {'type': 'ir.actions.act_window_close'}
    def compute_exrule_string(self, cr, uid, ids, context=None):
        """
        Compute rule string.
        @param self: the object pointer
        @param cr: the current row, from the database cursor,
        @param uid: the current user’s ID for security checks,
        @param datas: dictionary of freq and interval value.
        @return: string value which compute FREQILY;INTERVAL
        """

        weekdays = ['mo', 'tu', 'we', 'th', 'fr', 'sa', 'su']
        weekstring = ''
        monthstring = ''
        yearstring = ''
        if context is None: 
            context = {}
        ex_id = base_calendar.base_calendar_id2real_id(context.get('active_id', False))
        model = context.get('model', False)
        model_obj = self.pool.get(model)
        for datas in self.read(cr, uid, ids, context=context):
            freq = datas.get('freq')
            if freq == 'None':
                model_obj.write(cr, uid, ex_id,{'exrule': ''})
                return{}

            interval_srting = datas.get('interval') and (';INTERVAL=' + str(datas.get('interval'))) or ''

            if freq == 'weekly':

                byday = map(lambda x: x.upper(), filter(lambda x: datas.get(x) and x in weekdays, datas))
                if byday:
                    weekstring = ';BYDAY=' + ','.join(byday)

            elif freq == 'monthly':
                if datas.get('select1')=='date' and (datas.get('day') < 1 or datas.get('day') > 31):
                    raise osv.except_osv(_('Error!'), ("Please select proper Day of month"))
                if datas.get('select1')=='day':
                    monthstring = ';BYDAY=' + datas.get('byday') + datas.get('week_list')
                elif datas.get('select1')=='date':
                    monthstring = ';BYMONTHDAY=' + str(datas.get('day'))

            elif freq == 'yearly':
                if datas.get('select1')=='date' and (datas.get('day') < 1 or datas.get('day') > 31):
                    raise osv.except_osv(_('Error!'), ("Please select proper Day of month"))
                bymonth = ';BYMONTH=' + str(datas.get('month_list'))
                if datas.get('select1')=='day':
                    bystring = ';BYDAY=' + datas.get('byday') + datas.get('week_list')
                elif datas.get('select1')=='date':
                    bystring = ';BYMONTHDAY=' + str(datas.get('day'))
                yearstring = bymonth + bystring

            if datas.get('end_date'):
                datas['end_date'] = ''.join((re.compile('\d')).findall(datas.get('end_date'))) + '235959Z'
            enddate = (datas.get('count') and (';COUNT=' + str(datas.get('count'))) or '') +\
                                 ((datas.get('end_date') and (';UNTIL=' + datas.get('end_date'))) or '')

            exrule_string = 'FREQ=' + freq.upper() + weekstring + interval_srting \
                                + enddate + monthstring + yearstring

            model_obj.write(cr, uid, ex_id,{'exrule': exrule_string})
            return {'type': 'ir.actions.act_window_close'}

        _defaults = {
         'freq': lambda *x: 'None',
         'select1': lambda *x: 'date',
         'interval': lambda *x: 1,
    }
Ejemplo n.º 12
0
    def compute_exrule_string(self, cr, uid, ids, context=None):
        """
        Compute rule string.
        @param self: the object pointer
        @param cr: the current row, from the database cursor,
        @param uid: the current user’s ID for security checks,
        @param datas: dictionary of freq and interval value.
        @return: string value which compute FREQILY;INTERVAL
        """

        weekdays = ['mo', 'tu', 'we', 'th', 'fr', 'sa', 'su']
        weekstring = ''
        monthstring = ''
        yearstring = ''
        if context is None:
            context = {}
        ex_id = base_calendar.base_calendar_id2real_id(
            context.get('active_id', False))
        model = context.get('model', False)
        model_obj = self.pool.get(model)
        for datas in self.read(cr, uid, ids, context=context):
            freq = datas.get('freq')
            if freq == 'None':
                model_obj.write(cr, uid, ex_id, {'exrule': ''})
                return {}

            interval_srting = datas.get('interval') and (
                ';INTERVAL=' + str(datas.get('interval'))) or ''

            if freq == 'weekly':

                byday = map(
                    lambda x: x.upper(),
                    filter(lambda x: datas.get(x) and x in weekdays, datas))
                if byday:
                    weekstring = ';BYDAY=' + ','.join(byday)

            elif freq == 'monthly':
                if datas.get('select1') == 'date' and (datas.get('day') < 1 or
                                                       datas.get('day') > 31):
                    raise osv.except_osv(_('Error!'),
                                         ("Please select proper Day of month"))
                if datas.get('select1') == 'day':
                    monthstring = ';BYDAY=' + datas.get('byday') + datas.get(
                        'week_list')
                elif datas.get('select1') == 'date':
                    monthstring = ';BYMONTHDAY=' + str(datas.get('day'))

            elif freq == 'yearly':
                if datas.get('select1') == 'date' and (datas.get('day') < 1 or
                                                       datas.get('day') > 31):
                    raise osv.except_osv(_('Error!'),
                                         ("Please select proper Day of month"))
                bymonth = ';BYMONTH=' + str(datas.get('month_list'))
                if datas.get('select1') == 'day':
                    bystring = ';BYDAY=' + datas.get('byday') + datas.get(
                        'week_list')
                elif datas.get('select1') == 'date':
                    bystring = ';BYMONTHDAY=' + str(datas.get('day'))
                yearstring = bymonth + bystring

            if datas.get('end_date'):
                datas['end_date'] = ''.join((re.compile('\d')).findall(
                    datas.get('end_date'))) + '235959Z'
            enddate = (datas.get('count') and (';COUNT=' + str(datas.get('count'))) or '') +\
                                 ((datas.get('end_date') and (';UNTIL=' + datas.get('end_date'))) or '')

            exrule_string = 'FREQ=' + freq.upper() + weekstring + interval_srting \
                                + enddate + monthstring + yearstring

            model_obj.write(cr, uid, ex_id, {'exrule': exrule_string})
            return {'type': 'ir.actions.act_window_close'}

        _defaults = {
            'freq': lambda *x: 'None',
            'select1': lambda *x: 'date',
            'interval': lambda *x: 1,
        }
    def do_invite(self, cr, uid, ids, context=None):
        """
        Invites attendee for meeting..
        @param cr: the current row, from the database cursor,
        @param uid: the current user’s ID for security checks,
        @param ids: List of base calendar invite attendee’s IDs.
        @param context: A standard dictionary for contextual values
        @return: Dictionary of {}.
        """

        if context is None:
            context = {}

        model = False
        context_id = context and context.get("active_id", False) or False
        if not context or not context.get("model"):
            return {"type": "ir.actions.act_window_close"}
        else:
            model = context.get("model")

        model_field = context.get("attendee_field", False)
        obj = self.pool.get(model)
        res_obj = obj.browse(cr, uid, context_id, context=context)
        att_obj = self.pool.get("calendar.attendee")
        user_obj = self.pool.get("res.users")
        current_user = user_obj.browse(cr, uid, uid, context=context)
        for datas in self.read(cr, uid, ids, context=context):
            type = datas.get("type")
            vals = []
            mail_to = []
            attendees = []
            ref = {}

            if not model == "calendar.attendee":
                if context_id:
                    ref = {"ref": "%s,%s" % (model, base_calendar.base_calendar_id2real_id(context_id))}
                else:
                    return {"type": "ir.actions.act_window_close"}
            if type == "internal":

                if not datas.get("user_ids"):
                    raise osv.except_osv(_("Error!"), ("Please select any User"))
                for user_id in datas.get("user_ids"):
                    user = user_obj.browse(cr, uid, user_id)
                    res = {"user_id": user_id, "email": user.address_id.email}
                    res.update(ref)
                    vals.append(res)
                    if user.address_id.email:
                        mail_to.append(user.address_id.email)

            elif type == "external" and datas.get("email"):
                res = {"email": datas["email"]}
                res.update(ref)
                vals.append(res)
                mail_to.append(datas["email"])

            elif type == "partner":
                add_obj = self.pool.get("res.partner.address")
                for contact in add_obj.browse(cr, uid, datas["contact_ids"]):
                    res = {"partner_address_id": contact.id, "email": contact.email}
                    res.update(ref)
                    vals.append(res)
                    if contact.email:
                        mail_to.append(contact.email)

            for att_val in vals:
                if model == "calendar.attendee":
                    att = att_obj.browse(cr, uid, context_id)
                    att_val.update(
                        {
                            "parent_ids": [(4, att.id)],
                            "ref": att.ref and (att.ref._name + "," + str(att.ref.id)) or False,
                        }
                    )

                attendees.append(att_obj.create(cr, uid, att_val))
            if model_field:
                for attendee in attendees:
                    obj.write(cr, uid, res_obj.id, {model_field: [(4, attendee)]})

            if datas.get("send_mail"):
                if not mail_to:
                    name = map(lambda x: x[1], filter(lambda x: type == x[0], self._columns["type"].selection))
                    raise osv.except_osv(_("Error!"), _("%s must have an email  address to send mail") % (name[0]))
                att_obj._send_mail(
                    cr,
                    uid,
                    attendees,
                    mail_to,
                    email_from=current_user.user_email or tools.config.get("email_from", False),
                )

        return {"type": "ir.actions.act_window_close"}