Example #1
0
 def _execute_command_lead(self, **kwargs):
     partner = self.env.user.partner_id
     key = kwargs['body']
     channel_partners = self.env['mail.channel.partner'].search([
         ('partner_id', '!=', partner.id),
         ('channel_id', '=', self.id)], limit=1
     )
     if key.strip() == '/lead':
         msg = self._define_command_lead()['help']
     else:
         description = ''.join(
             '%s: %s\n' % (message.author_id.name or self.anonymous_name, message.body)
             for message in self.channel_message_ids.sorted('id')
         )
         lead = self.env['crm.lead'].create({
             'name': html2plaintext(key[5:]),
             'partner_id': channel_partners.partner_id.id,
             'user_id': None,
             'team_id': None,
             'description': html2plaintext(description),
             'referred': partner.name
         })
         lead._onchange_partner_id()
         msg = _('Created a new lead: <a href="#" data-oe-id="%s" data-oe-model="crm.lead">%s</a>') % (lead.id, lead.name)
     self._send_transient_message(partner, msg)
Example #2
0
 def setHtmlFallbackText(self, padID, html):
     try:
         # Prevents malformed HTML errors
         html_wellformed = '<html><body>' + html + '</body></html>'
         return self.setHtml(padID, html_wellformed)
     except Exception:
         _logger.exception('Falling back to setText. SetHtml failed with message:')
         return self.setText(padID, html2plaintext(html).encode('UTF-8'))
Example #3
0
 def _compute_teaser(self):
     for blog_post in self:
         if blog_post.teaser_manual:
             blog_post.teaser = blog_post.teaser_manual
         else:
             content = html2plaintext(blog_post.content).replace('\n', ' ')
             blog_post.teaser = ' '.join(
                 itertools.islice(
                     (c for c in content.split(' ') if c), 50)) + '...'
Example #4
0
 def _compute_description(self):
     for message in self:
         if message.subject:
             message.description = message.subject
         else:
             plaintext_ct = '' if not message.body else html2plaintext(
                 message.body)
             message.description = plaintext_ct[:30] + '%s' % (
                 ' [...]' if len(plaintext_ct) >= 30 else '')
Example #5
0
 def _get_discussion_detail(self, ids, publish=False, **post):
     values = []
     for message in request.env['mail.message'].sudo().browse(ids):
         values.append({
             "id": message.id,
             "author_name": message.author_id.name,
             "author_image": message.author_id.image and \
                 (b"data:image/png;base64,%s" % message.author_id.image) or \
                 b'/website_blog/static/src/img/anonymous.png',
             "date": message.date,
             'body': html2plaintext(message.body),
             'website_published' : message.website_published,
             'publish' : publish,
         })
     return values
Example #6
0
    def send_get_email_dict(self, partner=None):
        """Return a dictionary for specific email values, depending on a
        partner, or generic to the whole recipients given by mail.email_to.

            :param Model partner: specific recipient partner
        """
        self.ensure_one()
        body = self.send_get_mail_body(partner=partner)
        body_alternative = tools.html2plaintext(body)
        res = {
            'body': body,
            'body_alternative': body_alternative,
            'email_to': self.send_get_mail_to(partner=partner),
        }
        return res
Example #7
0
 def action_create_calendar_event(self):
     self.ensure_one()
     action = self.env.ref('calendar.action_calendar_event').read()[0]
     action['context'] = {
         'default_activity_type_id':
         self.activity_type_id.id,
         'default_res_id':
         self.env.context.get('default_res_id'),
         'default_res_model':
         self.env.context.get('default_res_model'),
         'default_name':
         self.summary,
         'default_description':
         self.note and tools.html2plaintext(self.note) or '',
         'default_activity_ids': [(6, 0, self.ids)],
     }
     return action
Example #8
0
 def _get_plain_content(self):
     self.plain_content = tools.html2plaintext(self.content)[0:500] if self.content else False
Example #9
0
 def _compute_name(self):
     """ Read the first line of the memo to determine the note name """
     for note in self:
         text = html2plaintext(note.memo) if note.memo else ''
         note.name = text.strip().replace('*', '').split("\n")[0]
Example #10
0
 def _get_note_first_line(self):
     for message in self:
         message.name = (message.message and html2plaintext(message.message) or "").strip().replace('*', '').split("\n")[0]