[REM] mail.compose.wizard: remove unused body_text and content_subtype fields
These fields were used in pre-7.0 to manage the plaintext variant of the mail being composed, but as of 7.0 the composition wizard will always use the HTML/Rich text mode, so they can be dropped. bzr revid: odo@openerp.com-20121115135634-fcy6mexnctwg0nxb
This commit is contained in:
parent
c558ac6272
commit
e5921325bd
|
@ -63,7 +63,6 @@ class crm_lead_forward_to_partner(osv.osv_memory):
|
|||
|
||||
_defaults = {
|
||||
'history_mode': 'latest',
|
||||
'content_subtype': lambda self,cr, uid, context={}: 'html',
|
||||
}
|
||||
|
||||
def get_record_data(self, cr, uid, model, res_id, context=None):
|
||||
|
|
|
@ -115,10 +115,9 @@ class test_message_compose(test_mail_mockup.TestMailMockups):
|
|||
compose.refresh()
|
||||
message_pids = [partner.id for partner in compose.partner_ids]
|
||||
partner_ids = self.res_partner.search(cr, uid, [('email', 'in', ['b@b.b', 'c@c.c', 'd@d.d'])])
|
||||
# Test: mail.compose.message: subject, body, content_subtype, partner_ids
|
||||
# Test: mail.compose.message: subject, body, partner_ids
|
||||
self.assertEqual(compose.subject, _subject1, 'mail.compose.message subject incorrect')
|
||||
self.assertEqual(compose.body, _body_html1, 'mail.compose.message body incorrect')
|
||||
self.assertEqual(compose.content_subtype, 'html', 'mail.compose.message content_subtype incorrect')
|
||||
self.assertEqual(set(message_pids), set(partner_ids), 'mail.compose.message partner_ids incorrect')
|
||||
# Test: mail.compose.message: attachments
|
||||
# Test: mail.message: attachments
|
||||
|
@ -156,10 +155,9 @@ class test_message_compose(test_mail_mockup.TestMailMockups):
|
|||
compose.refresh()
|
||||
message_pids = [partner.id for partner in compose.partner_ids]
|
||||
partner_ids = [p_a_id]
|
||||
# Test: mail.compose.message: subject, body, content_subtype, partner_ids
|
||||
# Test: mail.compose.message: subject, body, partner_ids
|
||||
self.assertEqual(compose.subject, '${object.name}', 'mail.compose.message subject incorrect')
|
||||
self.assertEqual(compose.body, '${object.description}', 'mail.compose.message body incorrect')
|
||||
self.assertEqual(compose.content_subtype, 'html', 'mail.compose.message content_subtype incorrect')
|
||||
self.assertEqual(set(message_pids), set(partner_ids), 'mail.compose.message partner_ids incorrect')
|
||||
|
||||
# 3. Post the comment, get created message
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<field name="inherit_id" ref="mail.email_compose_message_wizard_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="//field[@name='content_subtype']" position="after">
|
||||
<xpath expr="//field[@name='model']" position="after">
|
||||
<field name="use_template" invisible="1"
|
||||
on_change="onchange_use_template(use_template, template_id, composition_mode, model, res_id, context)"/>
|
||||
</xpath>
|
||||
|
@ -21,8 +21,7 @@
|
|||
</div>
|
||||
<button icon="/email_template/static/src/img/email_template_save.png"
|
||||
type="object" name="save_as_template" string="Save as new template" class="oe_link"
|
||||
help="Save as a new template"
|
||||
attrs="{'invisible':[('content_subtype','!=','html')]}"/>
|
||||
help="Save as a new template"/>
|
||||
</group>
|
||||
</xpath>
|
||||
</data>
|
||||
|
|
|
@ -437,9 +437,8 @@ class test_mail(test_mail_mockup.TestMailMockups):
|
|||
|
||||
# Mail data
|
||||
_subject = 'Pigs'
|
||||
_body_text = 'Pigs rules'
|
||||
_msg_reply = 'Re: Pigs'
|
||||
_msg_body = '<pre>Pigs rules</pre>'
|
||||
_body = 'Pigs <b>rule</b>'
|
||||
_reply_subject = 'Re: Pigs'
|
||||
_attachments = [
|
||||
{'name': 'First', 'datas_fname': 'first.txt', 'datas': 'My first attachment'.encode('base64')},
|
||||
{'name': 'Second', 'datas_fname': 'second.txt', 'datas': 'My second attachment'.encode('base64')}
|
||||
|
@ -462,9 +461,9 @@ class test_mail(test_mail_mockup.TestMailMockups):
|
|||
|
||||
# 1. Comment group_pigs with body_text and subject
|
||||
compose_id = mail_compose.create(cr, uid,
|
||||
{'subject': _subject, 'body_text': _body_text, 'partner_ids': [(4, p_c_id), (4, p_d_id)]},
|
||||
{'subject': _subject, 'body': _body, 'partner_ids': [(4, p_c_id), (4, p_d_id)]},
|
||||
{'default_composition_mode': 'comment', 'default_model': 'mail.group', 'default_res_id': self.group_pigs_id,
|
||||
'default_content_subtype': 'plaintext'})
|
||||
'default_content_subtype': 'plaintext'})
|
||||
compose = mail_compose.browse(cr, uid, compose_id)
|
||||
# Test: mail.compose.message: composition_mode, model, res_id
|
||||
self.assertEqual(compose.composition_mode, 'comment', 'mail.compose.message incorrect composition_mode')
|
||||
|
@ -476,8 +475,8 @@ class test_mail(test_mail_mockup.TestMailMockups):
|
|||
group_pigs.refresh()
|
||||
message = group_pigs.message_ids[0]
|
||||
# Test: mail.message: subject, body inside pre
|
||||
self.assertEqual(message.subject, False, 'mail.message incorrect subject')
|
||||
self.assertEqual(message.body, _msg_body, 'mail.message incorrect body')
|
||||
self.assertEqual(message.subject, _subject, 'mail.message incorrect subject')
|
||||
self.assertEqual(message.body, _body, 'mail.message incorrect body')
|
||||
# Test: mail.message: notified_partner_ids = entries in mail.notification: group_pigs fans (a, b) + mail.compose.message partner_ids (c, d)
|
||||
msg_pids = [partner.id for partner in message.notified_partner_ids]
|
||||
test_pids = [p_b_id, p_c_id, p_d_id]
|
||||
|
@ -495,13 +494,12 @@ class test_mail(test_mail_mockup.TestMailMockups):
|
|||
{'attachment_ids': [(0, 0, _attachments[0]), (0, 0, _attachments[1])]},
|
||||
{'default_composition_mode': 'reply', 'default_model': 'mail.thread', 'default_res_id': self.group_pigs_id, 'default_parent_id': message.id})
|
||||
compose = mail_compose.browse(cr, uid, compose_id)
|
||||
# Test: model, res_id, parent_id, content_subtype
|
||||
# Test: model, res_id, parent_id
|
||||
self.assertEqual(compose.model, 'mail.group', 'mail.compose.message incorrect model')
|
||||
self.assertEqual(compose.res_id, self.group_pigs_id, 'mail.compose.message incorrect res_id')
|
||||
self.assertEqual(compose.parent_id.id, message.id, 'mail.compose.message incorrect parent_id')
|
||||
self.assertEqual(compose.content_subtype, 'html', 'mail.compose.message incorrect content_subtype')
|
||||
# Test: mail.message: subject as Re:.., body in html, parent_id
|
||||
self.assertEqual(compose.subject, _msg_reply, 'mail.message incorrect subject')
|
||||
self.assertEqual(compose.subject, _reply_subject, 'mail.message incorrect subject')
|
||||
# self.assertIn('Administrator wrote:<blockquote><pre>Pigs rules</pre></blockquote>', compose.body, 'mail.message body is incorrect')
|
||||
self.assertEqual(compose.parent_id and compose.parent_id.id, message.id, 'mail.message parent_id incorrect')
|
||||
# Test: mail.message: attachments
|
||||
|
@ -520,8 +518,6 @@ class test_mail(test_mail_mockup.TestMailMockups):
|
|||
{'default_composition_mode': 'mass_mail', 'default_model': 'mail.group', 'default_res_id': False,
|
||||
'active_ids': [self.group_pigs_id, group_bird_id]})
|
||||
compose = mail_compose.browse(cr, uid, compose_id)
|
||||
# Test: content_subtype is html
|
||||
self.assertEqual(compose.content_subtype, 'html', 'mail.compose.message content_subtype incorrect')
|
||||
|
||||
# 2. Post the comment, get created message for each group
|
||||
mail_compose.send_mail(cr, uid, [compose_id],
|
||||
|
|
|
@ -81,7 +81,7 @@ class mail_compose_message(osv.TransientModel):
|
|||
elif composition_mode == 'comment' and model and res_id:
|
||||
vals = self.get_record_data(cr, uid, model, res_id, context=context)
|
||||
elif composition_mode == 'mass_mail' and model and active_ids:
|
||||
vals = {'model': model, 'res_id': res_id, 'content_subtype': 'html'}
|
||||
vals = {'model': model, 'res_id': res_id}
|
||||
else:
|
||||
vals = {'model': model, 'res_id': res_id}
|
||||
if composition_mode:
|
||||
|
@ -106,16 +106,10 @@ class mail_compose_message(osv.TransientModel):
|
|||
domain=lambda self: [('res_model', '=', self._name)],
|
||||
string='Attachments'),
|
||||
'filter_id': fields.many2one('ir.filters', 'Filters'),
|
||||
'body_text': fields.text('Plain-text Contents'),
|
||||
'content_subtype': fields.char('Message content subtype', size=32, readonly=1,
|
||||
help="Type of message, usually 'html' or 'plain', used to select "\
|
||||
"plain-text or rich-text contents accordingly"),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'composition_mode': 'comment',
|
||||
'content_subtype': lambda self, cr, uid, ctx={}: 'html',
|
||||
'body_text': lambda self, cr, uid, ctx={}: False,
|
||||
'body': lambda self, cr, uid, ctx={}: '',
|
||||
'subject': lambda self, cr, uid, ctx={}: False,
|
||||
'partner_ids': lambda self, cr, uid, ctx={}: [],
|
||||
|
@ -172,32 +166,9 @@ class mail_compose_message(osv.TransientModel):
|
|||
'parent_id': message_data.id,
|
||||
'subject': reply_subject,
|
||||
'partner_ids': partner_ids,
|
||||
'content_subtype': 'html',
|
||||
}
|
||||
return result
|
||||
|
||||
def toggle_content_subtype(self, cr, uid, ids, context=None):
|
||||
""" toggle content_subtype: calls onchange_formatting to emulate an
|
||||
on_change, then writes the value to update the form. """
|
||||
for record in self.browse(cr, uid, ids, context=context):
|
||||
content_st_new_value = 'plain' if record.content_subtype == 'html' else 'html'
|
||||
onchange_res = self.onchange_content_subtype(cr, uid, ids, content_st_new_value, record.model, record.res_id, context=context)
|
||||
self.write(cr, uid, [record.id], onchange_res['value'], context=context)
|
||||
return True
|
||||
|
||||
def onchange_content_subtype(self, cr, uid, ids, value, model, res_id, context=None):
|
||||
""" This onchange allows to have some specific behavior when switching
|
||||
between text or html mode. This method can be overridden.
|
||||
:param values: 'plain' or 'html'
|
||||
"""
|
||||
return {'value': {'content_subtype': value}}
|
||||
|
||||
def dummy(self, cr, uid, ids, context=None):
|
||||
""" TDE: defined to have buttons that do basically nothing. It is
|
||||
currently impossible to have buttons that do nothing special
|
||||
in views (if type not specified, considered as 'object'). """
|
||||
return True
|
||||
|
||||
#------------------------------------------------------
|
||||
# Wizard validation and send
|
||||
#------------------------------------------------------
|
||||
|
@ -218,8 +189,8 @@ class mail_compose_message(osv.TransientModel):
|
|||
for res_id in res_ids:
|
||||
# default values, according to the wizard options
|
||||
post_values = {
|
||||
'subject': wizard.subject if wizard.content_subtype == 'html' else False,
|
||||
'body': wizard.body if wizard.content_subtype == 'html' else '<pre>%s</pre>' % tools.ustr(wizard.body_text),
|
||||
'subject': wizard.subject,
|
||||
'body': wizard.body,
|
||||
'parent_id': wizard.parent_id and wizard.parent_id.id,
|
||||
'partner_ids': [(4, partner.id) for partner in wizard.partner_ids],
|
||||
'attachments': [(attach.datas_fname or attach.name, base64.b64decode(attach.datas)) for attach in wizard.attachment_ids],
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
<field name="model" invisible="1"/>
|
||||
<field name="res_id" invisible="1"/>
|
||||
<field name="parent_id" invisible="1"/>
|
||||
<field name="content_subtype" invisible="1"/>
|
||||
<!-- visible wizard -->
|
||||
<label for="partner_ids" string="Recipients"/>
|
||||
<div>
|
||||
|
|
Loading…
Reference in New Issue