1 openerp.mass_mailing = function (instance) {
2 var _t = instance.web._t;
3 openerp.mass_mailing = function(openerp) {
4 openerp.web_kanban.KanbanRecord.include({
5 on_card_clicked: function (event) {
6 if (this.view.dataset.model === 'mail.mass_mailing.campaign') {
7 this.$('.oe_mailings').click();
9 this._super.apply(this, arguments);
15 instance.web.form.CharDomainButton = instance.web.form.AbstractField.extend({
16 template: 'CharDomainButton',
17 init: function(field_manager, node) {
18 this._super.apply(this, arguments);
22 this._super.apply(this, arguments);
23 $('button', this.$el).on('click', self.on_click);
26 set_button: function() {
27 if (this.get('value')) {
28 // TODO: rpc to copute X
29 $('.oe_domain_count', this.$el).text('X records selected');
30 $('button span', this.$el).text(' Change selection');
32 $('.oe_domain_count', this.$el).text('0 record selected');
33 $('button span', this.$el).text(' Select records');
36 on_click: function(ev) {
38 var model = this.options.model || this.field_manager.get_field_value(this.options.model_field);
39 this.pop = new instance.web.form.SelectCreatePopup(this);
40 this.pop.select_element(
41 model, {title: 'Select records...'},
42 [], this.build_context());
43 this.pop.on("elements_selected", self, function() {
45 var search_data = this.pop.searchview.build_search_data()
46 instance.web.pyeval.eval_domains_and_contexts({
47 domains: search_data.domains,
48 contexts: search_data.contexts,
49 group_by_seq: search_data.groupbys || []
50 }).then(function (results) {
51 // if selected IDS change domain
52 var domain = self2.pop.dataset.domain.concat(results.domain || []);
53 self.set_value(JSON.stringify(domain))
56 event.preventDefault();
58 set_value: function(value_) {
60 this.set('value', value_ || false);
65 instance.web.form.widgets = instance.web.form.widgets.extend(
66 {'char_domain': 'instance.web.form.CharDomainButton'}