<commit_before>openerp.account = function(instance) {
var _t = instance.web._t,
   _lt = instance.web._lt;
instance.web.views.add('form_clone', 'instance.account.extend_form_view');
 
instance.account.extend_viewmanager = instance.web.ViewManagerAction.include({
    start : function(){
        this._super()
        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);
    }, 
    setup_exended_form_view: function(view_model, view_id){
        var self = this;
        from_view = this.registry.get_object('form_clone');
        this.dataset_form = new instance.web.DataSetSearch(this, view_model, this.action.context, this.action.domain);
        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.on_pager_action('first');
        });
    } 
    
})
instance.account.extend_form_view = instance.web.FormView.extend({
    on_loaded: function(data) {
         this._super.apply(this,arguments);
         var self = this
         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() {
            var action = $(this).data('pager-action');
            self.on_pager_action(action);
        });
    },
    do_reconcilation:function(event){
        var self = this
        var list_view = this.getParent().views['list'].controller
        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", {
            action_id: py.eval(event.target.name),
            context: additional_context
            }, 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 () {
                    self.dataset.read_slice().done(function(){
                        self.on_pager_action('next');
                    });
            });
        });
    },

        
    do_nothing_to_reconcile:function(){
        var self = this;
        this.dataset.call(event.target.name, [[self.datarecord.id], self.dataset.context]).then(function() {
            self.dataset.read_slice().done(function(){
                self.on_pager_action('next');
            });
        });
    },
    
    do_update_pager: function(hide_index) {
        var index = this.dataset.index + 1
        if (this.dataset.ids.length == 0)
            index = 0;
        index = hide_index ? '-' : index;
        this.$el.find('span.oe_pager_index_extend').html(index).end()
                   .find('span.oe_pager_count_extend').html(this.dataset.ids.length);
    },
    
    on_pager_action: function(action) {
        var self = this
        var viewmanager = self.getParent();
        viewmanager.action.context.next_partner_only = true;
        //TODO: if no records, than it's not working, it giving error
        if (this.dataset.ids.length == 0){
            self.dataset.index = null;
            viewmanager.action.context.partner_id = [];
            viewmanager.searchview.do_search();
            self.reload();
            return
        }
        
        $.when(this._super(action)).then(function() {
            var id = self.get_fields_values().partner_id;
            viewmanager.action.context.partner_id = [id];
            viewmanager.searchview.do_search();
        });
    },
  })

}<commit_msg>[FIX] account: reconciliation form , set false if not data<commit_after>openerp.account = function(instance) {
var _t = instance.web._t,
   _lt = instance.web._lt;
instance.web.views.add('form_clone', 'instance.account.extend_form_view');
 
instance.account.extend_viewmanager = instance.web.ViewManagerAction.include({
    start : function(){
        this._super()
        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);
    }, 
    setup_exended_form_view: function(view_model, view_id){
        var self = this;
        from_view = this.registry.get_object('form_clone');
        this.dataset_form = new instance.web.DataSetSearch(this, view_model, this.action.context, this.action.domain);
        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.on_pager_action('first');
        });
    } 
    
})
instance.account.extend_form_view = instance.web.FormView.extend({
    on_loaded: function(data) {
         this._super.apply(this,arguments);
         var self = this
         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() {
            var action = $(this).data('pager-action');
            self.on_pager_action(action);
        });
    },
    do_reconcilation:function(event){
        var self = this
        var list_view = this.getParent().views['list'].controller
        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", {
            action_id: py.eval(event.target.name),
            context: additional_context
            }, 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 () {
                    self.dataset.read_slice().done(function(){
                        self.on_pager_action('next');
                    });
            });
        });
    },

        
    do_nothing_to_reconcile:function(){
        var self = this;
        this.dataset.call(event.target.name, [[self.datarecord.id], self.dataset.context]).then(function() {
            self.dataset.read_slice().done(function(){
                self.on_pager_action('next');
            });
        });
    },
    
    do_update_pager: function(hide_index) {
        var index = this.dataset.index + 1
        if (this.dataset.ids.length == 0)
            index = 0;
        index = hide_index ? '-' : index;
        this.$el.find('span.oe_pager_index_extend').html(index).end()
                   .find('span.oe_pager_count_extend').html(this.dataset.ids.length);
    },
    
    on_pager_action: function(action) {
        var self = this
        var viewmanager = self.getParent();
        viewmanager.action.context.next_partner_only = true;
        if (this.dataset.ids.length == 0){
            self.datarecord = {}
            viewmanager.action.context.partner_id = [];
            viewmanager.searchview.do_search();
            _(this.fields).each(function (field, f) {
                field.set_value(self.datarecord[f] || false);
            });
            self.do_update_pager();
        }
        else{        
            $.when(this._super(action)).then(function() {
                var id = self.get_fields_values().partner_id;
                viewmanager.action.context.partner_id = [id];
                viewmanager.searchview.do_search();
            });
        }
    },
  })

}
{'fraction_non_alphanumeric': 0.13627141568981063, 'fraction_numerical': 0.001352569882777277, 'mean_word_length': 2.2265454545454544, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5393687', 'n_tokens_mistral': 2651, 'n_tokens_neox': 2586, 'n_words': 359}