[MOVE] Moved mass mailing chardomain widget to web.

bzr revid: tde@openerp.com-20140415133933-1uqlj3yujdwozz2m
This commit is contained in:
Thibault Delavallée 2014-04-15 15:39:33 +02:00
parent 4808ca3796
commit da7cb60cfc
3 changed files with 1 additions and 91 deletions

View File

@ -53,9 +53,7 @@ professional emails and reuse templates in a few clicks.
'js': [
'static/src/js/mass_mailing.js',
],
'qweb' : [
'static/src/xml/*.xml',
],
'qweb': [],
'css': [
'static/src/css/mass_mailing.css',
'static/src/css/email_template.css'

View File

@ -10,79 +10,4 @@ openerp.mass_mailing = function (instance) {
}
},
});
instance.web.form.CharDomainButton = instance.web.form.AbstractField.extend(instance.web.form.ReinitializeFieldMixin, {
init: function(field_manager, node) {
this._super.apply(this, arguments);
},
start: function() {
var self=this;
this._super.apply(this, arguments);
this.on("change:effective_readonly", this, function () {
this.display_field();
this.render_value();
});
this.$('button.select_records').on('click', self.on_click);
this.display_field();
return this._super();
},
render_value: function() {
this.$('button.select_records').css('visibility', this.get('effective_readonly') ? 'hidden': '');
},
set_value: function(value_) {
var self = this;
this.set('value', value_ || false);
this.display_field();
},
display_field: function() {
var self = this;
this.$el.html(instance.web.qweb.render("CharDomainButton", {widget: this}));
if (this.get('value')) {
var domain = instance.web.pyeval.eval('domain', this.get('value'));
var relation = this.getParent().fields.mailing_model.get('value')[0];
var ds = new instance.web.DataSetStatic(self, relation, self.build_context());
ds.call('search_count', [domain]).then(function (results) {
$('.oe_domain_count', self.$el).text(results + ' records selected');
$('button span', self.$el).text(' Change selection');
});
} else {
$('.oe_domain_count', this.$el).text('0 record selected');
$('button span', this.$el).text(' Select records');
};
},
on_click: function(ev) {
var self = this;
var model = this.options.model || this.field_manager.get_field_value(this.options.model_field);
this.pop = new instance.web.form.SelectCreatePopup(this);
this.pop.select_element(
model, {title: 'Select records...'},
[], this.build_context());
this.pop.on("elements_selected", self, function(element_ids) {
if (this.pop.$('input.oe_list_record_selector').prop('checked')) {
var search_data = this.pop.searchview.build_search_data();
var domain_done = instance.web.pyeval.eval_domains_and_contexts({
domains: search_data.domains,
contexts: search_data.contexts,
group_by_seq: search_data.groupbys || []
}).then(function (results) {
return results.domain;
});
}
else {
var domain = ["id", "in", element_ids];
var domain_done = $.Deferred().resolve(domain);
}
$.when(domain_done).then(function (domain) {
var domain = self.pop.dataset.domain.concat(domain || []);
self.set_value(JSON.stringify(domain))
});
});
event.preventDefault();
},
});
instance.web.form.widgets = instance.web.form.widgets.extend(
{'char_domain': 'instance.web.form.CharDomainButton'}
);
};

View File

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<template>
<t t-name="CharDomainButton">
<div class="oe_form_field">
<span class="oe_domain_count"/>
<button class="oe_button oe_link select_records" type="button"
t-att-style="widget.node.attrs.style"
t-att-accesskey="widget.node.attrs.accesskey">
<span class="fa fa-arrow-right"/>
</button>
</div>
</t>
</template>