[FIX] compatibility between auth_openid and base_crypt

lp bug: https://launchpad.net/bugs/1026784 fixed

bzr revid: api@openerp.com-20121115142203-13s6zw6yxpfkfzmj
This commit is contained in:
Arnaud Pineux 2012-11-15 15:22:03 +01:00
commit bc35c05961
9 changed files with 40 additions and 40 deletions

View File

@ -25,6 +25,21 @@ from osv import osv
from osv import fields
def _reopen(self, res_id, model):
return {'type': 'ir.actions.act_window',
'view_mode': 'form',
'view_type': 'form',
'res_id': res_id,
'res_model': self._name,
'target': 'new',
# save original model in context, because selecting the list of available
# templates requires a model in context
'context': {
'default_model': model,
},
}
class mail_compose_message(osv.TransientModel):
_inherit = 'mail.compose.message'
@ -42,10 +57,8 @@ class mail_compose_message(osv.TransientModel):
else:
model = context.get('default_model', context.get('active_model'))
if model:
record_ids = email_template_obj.search(cr, uid, [('model', '=', model)], context=context)
return email_template_obj.name_get(cr, uid, record_ids, context) + [(False, '')]
return []
record_ids = email_template_obj.search(cr, uid, [('model', '=', model)], context=context)
return email_template_obj.name_get(cr, uid, record_ids, context) + [(False, '')]
def default_get(self, cr, uid, fields, context=None):
if context is None:
@ -109,7 +122,7 @@ class mail_compose_message(osv.TransientModel):
onchange_res['partner_ids'] = [(4, partner_id) for partner_id in onchange_res.pop('partner_ids', [])]
onchange_res['attachment_ids'] = [(4, attachment_id) for attachment_id in onchange_res.pop('attachment_ids', [])]
record.write(onchange_res)
return True
return _reopen(self, record.id, record.model)
def onchange_use_template(self, cr, uid, ids, use_template, template_id, composition_mode, model, res_id, context=None):
""" onchange_use_template (values: True or False). If use_template is
@ -141,8 +154,8 @@ class mail_compose_message(osv.TransientModel):
'attachment_ids': [(6, 0, [att.id for att in record.attachment_ids])]
}
template_id = email_template.create(cr, uid, values, context=context)
record.write({'template_id': template_id, 'use_template': True})
return True
record.write(record.onchange_template_id(True, template_id, record.composition_mode, record.model, record.res_id)['value'])
return _reopen(self, record.id, record.model)
#------------------------------------------------------
# Wizard validation and send

View File

@ -14,12 +14,11 @@
</xpath>
<xpath expr="//footer" position="inside">
<group class="oe_right" col="1">
<div>Use template
<div attrs="{'invisible':[('use_template','=',False)]}">Use template
<field name="template_id" attrs="{'invisible':[('use_template','=',False)]}"
nolabel="1"
on_change="onchange_template_id(use_template, template_id, composition_mode, model, res_id, context)"/>
</div>
or
<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"

View File

@ -7,7 +7,7 @@
<field name="res_model">mail.message</field>
<field name="context">{
'default_model': 'res.users',
'default_res_id': uid
'default_res_id': uid,
}</field>
<field name="params" eval="&quot;{
'domain': [

View File

@ -57,7 +57,8 @@ class res_partner_mail(osv.Model):
if thread_id not in partner_ids:
partner_ids.append(thread_id)
kwargs['partner_ids'] = partner_ids
return super(res_partner_mail, self).message_post(cr, uid, False, body=body, subject=subject,
thread_id = False
return super(res_partner_mail, self).message_post(cr, uid, thread_id, body=body, subject=subject,
type=type, subtype=subtype, parent_id=parent_id, attachments=attachments, context=context, **kwargs)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -113,7 +113,8 @@ class res_users(osv.Model):
alias_pool.unlink(cr, uid, alias_ids, context=context)
return res
def message_post_api(self, cr, uid, thread_id, body='', subject=False, parent_id=False, attachment_ids=None, context=None):
def message_post_user_api(self, cr, uid, thread_id, body='', subject=False, parent_id=False,
attachment_ids=None, context=None, content_subtype='plaintext', **kwargs):
""" Redirect the posting of message on res.users to the related partner.
This is done because when giving the context of Chatter on the
various mailboxes, we do not have access to the current partner_id.
@ -124,8 +125,8 @@ class res_users(osv.Model):
if isinstance(thread_id, (list, tuple)):
thread_id = thread_id[0]
partner_id = self.pool.get('res.users').read(cr, uid, thread_id, ['partner_id'], context=context)['partner_id'][0]
return self.pool.get('res.partner').message_post_api(cr, uid, partner_id, body=body, subject=subject,
parent_id=parent_id, attachment_ids=attachment_ids, context=context)
return self.pool.get('res.partner').message_post_user_api(cr, uid, partner_id, body=body, subject=subject,
parent_id=parent_id, attachment_ids=attachment_ids, context=context, content_subtype=content_subtype, **kwargs)
def message_post(self, cr, uid, thread_id, context=None, **kwargs):
""" Redirect the posting of message on res.users to the related partner.
@ -140,10 +141,6 @@ class res_users(osv.Model):
partner_id = self.pool.get('res.users').read(cr, uid, thread_id, ['partner_id'], context=context)['partner_id'][0]
return self.pool.get('res.partner').message_post(cr, uid, partner_id, context=context, **kwargs)
def message_update(self, cr, uid, ids, msg_dict, update_vals=None, context=None):
partner_id = self.pool.get('res.users').browse(cr, uid, ids)[0].partner_id.id
return self.pool.get('res.partner').message_update(cr, uid, [partner_id], msg_dict,
update_vals=update_vals, context=context)
class res_users_mail_group(osv.Model):
""" Update of res.users class

View File

@ -24,7 +24,7 @@ openerp.mail = function (session) {
*/
var context_keys = ['default_template_id', 'default_composition_mode',
'default_use_template', 'default_partner_ids', 'default_model',
'default_res_id', 'default_content_subtype', , 'default_subject',
'default_res_id', 'default_content_subtype', 'default_subject',
'default_body', 'active_id', 'lang', 'bin_raw', 'tz',
'active_model', 'edi_web_url_view', 'active_ids',
'default_attachment_ids']
@ -521,8 +521,6 @@ openerp.mail = function (session) {
on_compose_fullmail: function (default_composition_mode) {
if (default_composition_mode == 'reply') {
var context = {
'default_model': this.context.default_model,
'default_res_id': this.context.default_res_id,
'default_composition_mode': default_composition_mode,
'default_parent_id': this.id,
'default_body': mail.ChatterUtils.get_text2html(this.$el ? (this.$el.find('textarea:not(.oe_compact)').val() || '') : ''),
@ -532,7 +530,6 @@ openerp.mail = function (session) {
var context = {
'default_model': this.context.default_model,
'default_res_id': this.context.default_res_id,
'default_content_subtype': 'html',
'default_composition_mode': default_composition_mode,
'default_parent_id': this.id,
'default_body': mail.ChatterUtils.get_text2html(this.$el ? (this.$el.find('textarea:not(.oe_compact)').val() || '') : ''),
@ -601,16 +598,15 @@ openerp.mail = function (session) {
this.parent_thread.context
]).done(function (record) {
var thread = self.parent_thread;
if (self.options.display_indented_thread < self.thread_level && thread.parent_message) {
thread = thread.parent_message.parent_thread;
var thread = thread.parent_message.parent_thread;
}
var root = thread == self.options.root_thread;
// create object and attach to the thread object
thread.message_fetch([['id', 'child_of', [self.id]]], false, [record], function (arg, data) {
data[0].no_sorted = true;
var message = thread.create_message_object( data[0] );
// insert the message on dom
thread.insert_message( message, self.$el );
thread.insert_message( message, root ? undefined : self.$el, root );
if (thread.parent_message) {
self.$el.remove();
self.parent_thread.compose_message = null;
@ -1275,7 +1271,7 @@ openerp.mail = function (session) {
* The sort is define by the thread_level (O for newer on top).
* @param : {object} ThreadMessage object
*/
insert_message: function (message, dom_insert_after) {
insert_message: function (message, dom_insert_after, prepend) {
var self=this;
if (this.options.show_compact_message > this.thread_level) {
this.instantiate_compose_message();
@ -1287,6 +1283,8 @@ openerp.mail = function (session) {
if (dom_insert_after) {
message.insertAfter(dom_insert_after);
}if (prepend) {
message.prependTo(self.$el);
} else {
message.appendTo(self.$el);
}
@ -1699,7 +1697,6 @@ openerp.mail = function (session) {
views: [[false, 'form']],
target: 'new',
context: {
'default_content_subtype': 'html',
},
};
session.client.action_manager.do_action(action);
@ -1733,7 +1730,7 @@ openerp.mail = function (session) {
view_type: 'form',
views: [[false, 'form']],
target: 'new',
context: { 'default_content_subtype': 'html' },
context: {},
};
session.client.action_manager.do_action(action);
},

View File

@ -95,14 +95,6 @@
</t>
</t>
<t t-name="mail.thread.message.private">
<div>
<span class="oe_placeholder_checkbox_private"/>
<span class="oe_send_private">This email is private.</span>
<span class="oe_send_public">I wrote for contacts and all my followers.</span>
</div>
</t>
<!--
template to the recipients list
-->

View File

@ -463,7 +463,8 @@ 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)]},
{'default_composition_mode': 'comment', 'default_model': 'mail.group', 'default_res_id': self.group_pigs_id})
{'default_composition_mode': 'comment', 'default_model': 'mail.group', 'default_res_id': self.group_pigs_id,
'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')

View File

@ -114,7 +114,7 @@ class mail_compose_message(osv.TransientModel):
_defaults = {
'composition_mode': 'comment',
'content_subtype': lambda self, cr, uid, ctx={}: 'plain',
'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,
@ -135,7 +135,7 @@ class mail_compose_message(osv.TransientModel):
related to.
:param int res_id: id of the document record this mail is related to
"""
doc_name_get = self.pool.get(model).name_get(cr, uid, res_id, context=context)
doc_name_get = self.pool.get(model).name_get(cr, uid, [res_id], context=context)
if doc_name_get:
record_name = doc_name_get[0][1]
else: