[IMP] mail, base_import: context key disabling history tracking
* added a ``tracking_disable`` context key used by mail to completely disable subscriptions setup and events generation during create and write operations * added import option to optionally set up that context key and speed up imports at the cost of not setting up subscriptions and not sending create/update events bzr revid: xmo@openerp.com-20140512100400-d1axjam2d0i2y0tf
This commit is contained in:
parent
f14f632ef5
commit
b39aac717d
|
@ -363,7 +363,10 @@ openerp.base_import = function (instance) {
|
|||
var fields = this.$('.oe_import_fields input.oe_import_match_field').map(function (index, el) {
|
||||
return $(el).select2('val') || false;
|
||||
}).get();
|
||||
kwargs.context = this.parent_context;
|
||||
kwargs.context = _.extend(
|
||||
{}, this.parent_context,
|
||||
{tracking_disable: !this.$('#oe_import_tracking').prop('checked')}
|
||||
);
|
||||
return this.Import.call('do', [this.id, fields, this.import_options()], kwargs)
|
||||
.then(undefined, function (error, event) {
|
||||
// In case of unexpected exception, convert
|
||||
|
|
|
@ -53,6 +53,15 @@
|
|||
|
||||
<div class="oe_import_with_file oe_padding">
|
||||
<h2>Map your data to OpenERP</h2>
|
||||
<div title="If the model uses openchatter, history tracking
|
||||
will set up subscriptions and send notifications
|
||||
during the import, but lead to a slower import.">
|
||||
<input type="checkbox" id="oe_import_tracking"
|
||||
checked="checked"/>
|
||||
<label for="oe_import_tracking">
|
||||
Track history during import
|
||||
</label>
|
||||
</div>
|
||||
<input type="checkbox" class="oe_import_has_header"
|
||||
id="oe_import_has_header" checked="checked"/>
|
||||
<label for="oe_import_has_header">The first row of the
|
||||
|
|
|
@ -359,6 +359,10 @@ class mail_thread(osv.AbstractModel):
|
|||
if context is None:
|
||||
context = {}
|
||||
|
||||
if context.get('tracking_disable'):
|
||||
return super(mail_thread, self).create(
|
||||
cr, uid, values, context=context)
|
||||
|
||||
# subscribe uid unless asked not to
|
||||
if not context.get('mail_create_nosubscribe'):
|
||||
pid = self.pool['res.users'].browse(cr, SUPERUSER_ID, uid).partner_id.id
|
||||
|
@ -394,6 +398,9 @@ class mail_thread(osv.AbstractModel):
|
|||
context = {}
|
||||
if isinstance(ids, (int, long)):
|
||||
ids = [ids]
|
||||
if context.get('tracking_disable'):
|
||||
return super(mail_thread, self).write(
|
||||
cr, uid, ids, values, context=context)
|
||||
# Track initial values of tracked fields
|
||||
track_ctx = dict(context)
|
||||
if 'lang' not in track_ctx:
|
||||
|
|
Loading…
Reference in New Issue