2012-06-12 07:19:58 +00:00
|
|
|
openerp.account = function(instance) {
|
2012-06-20 13:26:21 +00:00
|
|
|
var _t = instance.web._t,
|
|
|
|
_lt = instance.web._lt;
|
|
|
|
instance.web.views.add('form_clone', 'instance.account.extend_form_view');
|
2012-08-07 08:44:10 +00:00
|
|
|
|
|
|
|
instance.account.extend_viewmanager = instance.web.ViewManagerAction.include({
|
2012-06-20 13:26:21 +00:00
|
|
|
start : function(){
|
|
|
|
this._super()
|
2012-08-29 09:57:06 +00:00
|
|
|
if(this.action.context && this.action.context.extended_view_id && this.action.context.extended_model)
|
|
|
|
this.setup_exended_form_view(this.action.context.extended_model, this.action.context.extended_view_id);
|
2012-06-20 13:26:21 +00:00
|
|
|
},
|
2012-08-29 09:57:06 +00:00
|
|
|
setup_exended_form_view: function(view_model, view_id){
|
2012-08-29 12:43:03 +00:00
|
|
|
var self = this;
|
2012-06-20 13:26:21 +00:00
|
|
|
from_view = this.registry.get_object('form_clone');
|
2012-08-29 09:57:06 +00:00
|
|
|
this.dataset_form = new instance.web.DataSetSearch(this, view_model, this.action.context, this.action.domain);
|
2012-08-29 12:43:03 +00:00
|
|
|
this.dataset_loaded = this.dataset_form.read_slice();
|
|
|
|
obj_from_view = new from_view(self, self.dataset_form, view_id, options={});
|
|
|
|
obj_from_view.template = 'ExtendedFormView';
|
|
|
|
view_form = obj_from_view.appendTo(self.$el.find('.oe_extended_form_view'));
|
|
|
|
$.when(view_form, this.dataset_loaded).then(function() {
|
|
|
|
obj_from_view.post_action();
|
|
|
|
});
|
2012-06-20 13:26:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
instance.account.extend_form_view = instance.web.FormView.extend({
|
2012-06-22 07:21:43 +00:00
|
|
|
on_loaded: function(data) {
|
|
|
|
this._super.apply(this,arguments);
|
|
|
|
var self = this
|
2012-08-29 06:37:32 +00:00
|
|
|
this.$el.find(".oe_reconcile").on('click', this.do_reconcilation)
|
|
|
|
this.$el.find(".oe_nothing_to_reconcile").on('click', this.do_nothing_to_reconcile)
|
|
|
|
this.$el.on('click','a[data-pager-action]',function() {
|
2012-06-22 07:21:43 +00:00
|
|
|
var action = $(this).data('pager-action');
|
|
|
|
self.on_pager_action(action);
|
|
|
|
});
|
|
|
|
},
|
2012-08-07 13:34:27 +00:00
|
|
|
do_reconcilation:function(event){
|
2012-07-04 09:09:23 +00:00
|
|
|
var self = this
|
2012-08-07 13:34:27 +00:00
|
|
|
var list_view = this.getParent().views['list'].controller
|
2012-06-20 13:26:21 +00:00
|
|
|
ids = list_view.get_selected_ids()
|
|
|
|
if (ids.length == 0) {
|
|
|
|
instance.web.dialog($("<div />").text(_t("You must choose at least one record.")), { title: _t("Warning"), modal: true });
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
var additional_context = _.extend({
|
|
|
|
active_id: ids[0],
|
|
|
|
active_ids: ids,
|
|
|
|
active_model: list_view.dataset.model
|
|
|
|
});
|
|
|
|
self.rpc("/web/action/load", {
|
2012-08-07 13:34:27 +00:00
|
|
|
action_id: py.eval(event.target.name),
|
2012-06-20 13:26:21 +00:00
|
|
|
context: additional_context
|
2012-08-06 13:20:34 +00:00
|
|
|
}, function(result) {
|
|
|
|
result.result.context = _.extend(result.result.context || {},
|
|
|
|
additional_context);
|
|
|
|
result.result.flags = result.result.flags || {};
|
|
|
|
result.result.flags.new_window = true;
|
|
|
|
self.do_action(result.result, function () {
|
2012-08-29 12:43:03 +00:00
|
|
|
self.post_action();
|
2012-06-20 13:26:21 +00:00
|
|
|
});
|
|
|
|
});
|
2012-08-07 13:34:27 +00:00
|
|
|
},
|
2012-08-29 12:43:03 +00:00
|
|
|
|
|
|
|
post_action: function(){
|
|
|
|
// hide if not records otherwise go next record
|
|
|
|
var self = this;
|
|
|
|
var viewmanager = this.getParent();
|
|
|
|
this.dataset.read_slice().done(function(){
|
|
|
|
if (_.isEmpty(self.dataset.ids)){
|
2012-08-30 10:39:54 +00:00
|
|
|
viewmanager.action.context.next_partner_only = true;
|
|
|
|
/*self.$el.hide();
|
2012-08-29 12:43:03 +00:00
|
|
|
viewmanager.action.context.next_partner_only = false;
|
2012-08-30 10:39:54 +00:00
|
|
|
viewmanager.searchview.do_search();*/
|
2012-08-29 12:43:03 +00:00
|
|
|
}
|
|
|
|
else{
|
2012-08-30 10:39:54 +00:00
|
|
|
self.on_pager_action('first');
|
2012-08-29 12:43:03 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2012-08-08 05:34:42 +00:00
|
|
|
|
2012-08-09 06:50:42 +00:00
|
|
|
do_nothing_to_reconcile:function(){
|
2012-08-29 12:43:03 +00:00
|
|
|
var self = this;
|
2012-08-20 14:26:45 +00:00
|
|
|
this.dataset.call(event.target.name, [[self.datarecord.id], self.dataset.context]).then(function() {
|
2012-08-29 12:43:03 +00:00
|
|
|
self.post_action();
|
|
|
|
});
|
2012-08-08 05:34:42 +00:00
|
|
|
},
|
|
|
|
|
2012-08-07 13:34:27 +00:00
|
|
|
do_update_pager: function(hide_index) {
|
2012-08-30 12:10:41 +00:00
|
|
|
var index = this.dataset.index + 1
|
|
|
|
if (this.dataset.ids.length == 0)
|
|
|
|
index = 0;
|
|
|
|
index = hide_index ? '-' : index;
|
2012-08-29 06:37:32 +00:00
|
|
|
this.$el.find('span.oe_pager_index_extend').html(index).end()
|
2012-08-07 13:34:27 +00:00
|
|
|
.find('span.oe_pager_count_extend').html(this.dataset.ids.length);
|
|
|
|
},
|
|
|
|
|
|
|
|
on_pager_action: function(action) {
|
|
|
|
var self = this
|
|
|
|
var viewmanager = self.getParent();
|
|
|
|
$.when(this._super(action)).then(function() {
|
|
|
|
var id = self.get_fields_values().partner_id;
|
2012-08-29 09:57:06 +00:00
|
|
|
viewmanager.action.context.next_partner_only = true;
|
|
|
|
viewmanager.action.context.partner_id = [id];
|
2012-08-07 13:34:27 +00:00
|
|
|
viewmanager.searchview.do_search();
|
|
|
|
})
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
2012-06-12 07:19:58 +00:00
|
|
|
}
|