[FIX] mail: context default value error
bzr revid: chm@openerp.com-20121010101532-v2vx6h01x4zeq0ac
This commit is contained in:
parent
01b083e14d
commit
df873d22a8
|
@ -149,31 +149,6 @@ class document_file(osv.osv):
|
|||
_sql_constraints = [
|
||||
# filename_uniq is not possible in pure SQL
|
||||
]
|
||||
def _check_duplication(self, cr, uid, vals, ids=None, op='create'):
|
||||
name = vals.get('name', False)
|
||||
parent_id = vals.get('parent_id', False)
|
||||
res_model = vals.get('res_model', False)
|
||||
res_id = vals.get('res_id', 0)
|
||||
|
||||
if op == 'write':
|
||||
for file in self.browse(cr, uid, ids): # FIXME fields_only
|
||||
if not name:
|
||||
name = file.name
|
||||
if not parent_id:
|
||||
parent_id = file.parent_id and file.parent_id.id or False
|
||||
if not res_model:
|
||||
res_model = file.res_model and file.res_model or False
|
||||
if not res_id:
|
||||
res_id = file.res_id and file.res_id or 0
|
||||
res = self.search(cr, uid, [('id', '<>', file.id), ('name', '=', name), ('parent_id', '=', parent_id), ('res_model', '=', res_model), ('res_model', '!=', ''), ('res_id', '=', res_id)])
|
||||
if len(res):
|
||||
return False
|
||||
if op == 'create':
|
||||
res = self.search(cr, uid, [('name', '=', name), ('parent_id', '=', parent_id), ('res_id', '=', res_id), ('res_model', '=', res_model), ('res_model', '!=', '')])
|
||||
if len(res):
|
||||
return False
|
||||
return True
|
||||
|
||||
def check(self, cr, uid, ids, mode, context=None, values=None):
|
||||
"""Check access wrt. res_model, relax the rule of ir.attachment parent
|
||||
|
||||
|
@ -221,12 +196,6 @@ class document_file(osv.osv):
|
|||
if not len(res):
|
||||
return False
|
||||
|
||||
# when a user write a mail, there are no model
|
||||
# don't check the duplication for the mails
|
||||
res_mail = self.search(cr, uid, [('id', 'in', ids), ('res_model', '=', '')])
|
||||
if res!=res_mail and not self._check_duplication(cr, uid, vals, ids, 'write'):
|
||||
raise osv.except_osv(_('ValidateError'), _('File name must be unique!'))
|
||||
|
||||
# if nodes call this write(), they must skip the code below
|
||||
from_node = context and context.get('__from_node', False)
|
||||
if (('parent_id' in vals) or ('name' in vals)) and not from_node:
|
||||
|
@ -291,22 +260,8 @@ class document_file(osv.osv):
|
|||
else:
|
||||
if vals.get('file_size'):
|
||||
del vals['file_size']
|
||||
result = self._check_duplication(cr, uid, vals)
|
||||
if not result:
|
||||
domain = [
|
||||
('res_id', '=', vals['res_id']),
|
||||
('res_model', '=', vals['res_model']),
|
||||
('datas_fname', '=', vals['datas_fname']),
|
||||
]
|
||||
attach_ids = self.search(cr, uid, domain, context=context)
|
||||
super(document_file, self).write(cr, uid, attach_ids,
|
||||
{'datas' : vals['datas']},
|
||||
context=context)
|
||||
result = attach_ids[0]
|
||||
else:
|
||||
#raise osv.except_osv(_('ValidateError'), _('File name must be unique!'))
|
||||
result = super(document_file, self).create(cr, uid, vals, context)
|
||||
return result
|
||||
|
||||
return super(document_file, self).create(cr, uid, vals, context)
|
||||
|
||||
def __get_partner_id(self, cr, uid, res_model, res_id, context=None):
|
||||
""" A helper to retrieve the associated partner from any res_model+id
|
||||
|
|
|
@ -82,11 +82,15 @@
|
|||
overflow: auto;
|
||||
}
|
||||
|
||||
.openerp .oe_mail_record_wall > .oe_mail_wall_threads {
|
||||
.openerp .oe_mail_record_wall {
|
||||
margin: auto;
|
||||
width: 560px;
|
||||
}
|
||||
|
||||
.openerp .oe_mail_record_wall > .oe_mail_wall_threads {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.openerp div.oe_mail_recthread_aside {
|
||||
float: right;
|
||||
width: 250px;
|
||||
|
@ -145,6 +149,10 @@
|
|||
z-index: 5;
|
||||
}
|
||||
.openerp .oe_mouse_subtypes .oe_recthread_subtypes {
|
||||
background: #fff;
|
||||
padding: 2px;
|
||||
border: 1px solid #aaaaaa;
|
||||
border-top: 0px;
|
||||
position: absolute;
|
||||
z-index: 2;
|
||||
}
|
||||
|
|
|
@ -19,12 +19,39 @@ openerp.mail = function(session) {
|
|||
session.web.FormView = session.web.FormView.extend({
|
||||
do_action: function(action, on_close) {
|
||||
if (action.res_model == 'mail.compose.message') {
|
||||
$(".openerp_webclient_container .oe_view_manager_current .oe_mail .oe_mail_wall_button_fletch").click();
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return this._super(action, on_close);
|
||||
|
||||
if(action.action_from != 'mail.ThreadComposeMessage' && action.type != 'ir.actions.act_window_close'){
|
||||
// destroy wall before reload
|
||||
$('.openerp .oe_mail_wall_threads .oe_mail_thread button.oe_mail_wall_button_destroy').click();
|
||||
|
||||
|
||||
/* hack for stop context propagation of wrong value
|
||||
* delete this hack when a global method to clean context is create
|
||||
*/
|
||||
for(var key in action.context){
|
||||
if( key!='default_template_id' &&
|
||||
key!='default_use_template' &&
|
||||
key!='default_model' &&
|
||||
key!='default_res_id' &&
|
||||
key!='default_subtype' &&
|
||||
key!='active_id' &&
|
||||
key!='lang' &&
|
||||
key!='bin_raw' &&
|
||||
key!='tz' &&
|
||||
key!='active_model' &&
|
||||
key!='edi_web_url_view' &&
|
||||
key!='active_ids')
|
||||
action.context[key]=null;
|
||||
};
|
||||
/* end hack */
|
||||
|
||||
|
||||
} else {
|
||||
$('.openerp .oe_mail_wall_threads .oe_mail_thread button.oe_mail_wall_button_fletch').click();
|
||||
}
|
||||
|
||||
}
|
||||
return this._super(action, on_close);
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -90,7 +117,7 @@ openerp.mail = function(session) {
|
|||
* This form is a mail.compose.message form_view.
|
||||
*/
|
||||
|
||||
mail.ComposeMessage = session.web.Widget.extend({
|
||||
mail.ThreadComposeMessage = session.web.Widget.extend({
|
||||
template: 'mail.compose_message',
|
||||
|
||||
/**
|
||||
|
@ -316,11 +343,12 @@ openerp.mail = function(session) {
|
|||
res_model: 'mail.compose.message',
|
||||
view_mode: 'form',
|
||||
view_type: 'form',
|
||||
action_from: 'mail.ThreadComposeMessage',
|
||||
views: [[false, 'form']],
|
||||
target: 'new',
|
||||
context: {
|
||||
'default_res_model': this.model,
|
||||
'default_res_id': this.res_id,
|
||||
'default_res_model': this.context.default_res_model,
|
||||
'default_res_id': this.context.default_res_id,
|
||||
'default_content_subtype': 'html',
|
||||
'default_is_private': true,
|
||||
'default_parent_id': this.id,
|
||||
|
@ -847,7 +875,7 @@ openerp.mail = function(session) {
|
|||
|
||||
instantiate_ComposeMessage: function(){
|
||||
// add message composition form view
|
||||
this.ComposeMessage = new mail.ComposeMessage(this,{
|
||||
this.ComposeMessage = new mail.ThreadComposeMessage(this,{
|
||||
'context': this.context,
|
||||
'parameters': this,
|
||||
'show_attachment_delete': true,
|
||||
|
@ -860,7 +888,7 @@ openerp.mail = function(session) {
|
|||
on_first_thread: function(){
|
||||
var self=this;
|
||||
// fetch and display message, using message_ids if set
|
||||
this.message_fletch(true);
|
||||
this.message_fletch();
|
||||
|
||||
$(document).scroll( self.on_scroll );
|
||||
window.setTimeout( self.on_scroll, 500 );
|
||||
|
@ -872,11 +900,15 @@ openerp.mail = function(session) {
|
|||
this.ComposeMessage.set_free_attachments();
|
||||
}
|
||||
|
||||
var button_flesh = $('<button style="display:none;" class="oe_mail_wall_button_fletch"/>').click(function(event){
|
||||
var button_destroy = $('<button style="display:none;" class="oe_mail_wall_button_destroy"/>').click(function(event){
|
||||
if(event)event.stopPropagation();
|
||||
self.message_fletch(true);
|
||||
self.destroy();
|
||||
});
|
||||
this.$el.prepend(button_flesh);
|
||||
var button_fletch = $('<button style="display:none;" class="oe_mail_wall_button_fletch"/>').click(function(event){
|
||||
if(event)event.stopPropagation();
|
||||
self.message_fletch();
|
||||
});
|
||||
this.$el.prepend(button_destroy,button_fletch);
|
||||
this.$el.addClass("oe_mail_wall_first_thread");
|
||||
},
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
context="{'force_email':True}"
|
||||
on_change="onchange_partner_ids(partner_ids)"
|
||||
class="oe_mail_compose_message_partner_ids"/>
|
||||
<field name="is_private" help="If this message is not private, this message will send to all your followers or all followers of the parented message."/>
|
||||
<!--field name="is_private" help="If this message is not private, this message will send to all your followers or all followers of the parented message."/-->
|
||||
<field name="attachment_ids" colspan="2" nolabel="1" widget="many2many_tags"
|
||||
placeholder="Add attachments..." invisible="1"
|
||||
class="oe_mail_compose_message_attachment_ids"/>
|
||||
|
|
Loading…
Reference in New Issue