From 092a646c66a960df8eb0d555136daf563675d45e Mon Sep 17 00:00:00 2001 From: "RGA(OpenERP)" <> Date: Fri, 6 Jul 2012 15:00:39 +0530 Subject: [PATCH] [IMP] click on nothing to reconcile button skip current parnter bzr revid: rgaopenerp-20120706093039-842mld92j582sals --- addons/account/account_move_line_extended.py | 40 ++++++++++++------- addons/account/account_move_line_extended.xml | 2 +- addons/account/static/src/js/account.js | 33 ++++++++++++--- 3 files changed, 55 insertions(+), 20 deletions(-) diff --git a/addons/account/account_move_line_extended.py b/addons/account/account_move_line_extended.py index 2a36a7a77d8..ce2df185bfc 100644 --- a/addons/account/account_move_line_extended.py +++ b/addons/account/account_move_line_extended.py @@ -44,34 +44,46 @@ class account_move_partner_info(osv.osv): res_all[id] = res return res_all + def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False): + ids = super(account_move_partner_info, self).search(cr, uid, args, offset, limit, order, context, count) + res = [] + for l in self.browse(cr, uid, ids, context=context): + if (not l.partner_move_count) or (l.move_lines_count >l.partner_move_count): + res.append(l.id) + return res + _columns = { 'partner_id':fields.many2one('res.partner', 'Partner'), 'last_reconciliation_date':fields.datetime('Last Reconciliation'), 'latest_date' :fields.date('Latest Entry'), -# 'followup_date': fields.date('Latest Follow-up'), - 'reconciliation_progress': fields.function(_rec_progress, string='Progress (%)', type='float') - + 'reconciliation_progress': fields.function(_rec_progress, string='Progress (%)', type='float'), + 'move_lines_count':fields.integer('Move Count'), + 'partner_move_count':fields.integer('Partner move line count'), } + def skip_partner(self, cr, uid, ids, context): + res_partner = self.pool.get('res.partner') + for line in self.browse(cr, uid, ids, context=context): + res_partner.write(cr, uid, [line.id] ,{'partner_move_count':line.move_lines_count}) + def init(self, cr): tools.drop_view_if_exists(cr, 'account_move_partner_info') cr.execute(""" create or replace view account_move_partner_info as ( SELECT p.id, p.id as partner_id, max(p.last_reconciliation_date) as last_reconciliation_date, - max(l.date) as latest_date + max(l.date) as latest_date, + count(l.id) as move_lines_count, + max(p.partner_move_count) as partner_move_count FROM account_move_line as l INNER JOIN res_partner AS p ON (l.partner_id = p.id) group by p.id ) """) account_move_partner_info() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - - - -#SELECT p.id as partner_id, -# max(p.last_reconciliation_date) as last_reconciliation_date, -# max(l.date) as latest_date, -# max(l.followup_date) as followup_date -#From account_move_line as l INNER JOIN res_partner AS p ON (l.partner_id = p.id) -#group by p.id \ No newline at end of file +class res_partner(osv.osv): + _inherit = 'res.partner' + _columns = { + 'partner_move_count': fields.integer('Partner move line count') + } +res_partner() +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/account/account_move_line_extended.xml b/addons/account/account_move_line_extended.xml index 27c52b2c7ac..8fcf518fc4c 100644 --- a/addons/account/account_move_line_extended.xml +++ b/addons/account/account_move_line_extended.xml @@ -19,7 +19,7 @@
diff --git a/addons/account/static/src/js/account.js b/addons/account/static/src/js/account.js index 544ec4ccbd2..a3ad0f85ccd 100644 --- a/addons/account/static/src/js/account.js +++ b/addons/account/static/src/js/account.js @@ -3,6 +3,7 @@ var _t = instance.web._t, _lt = instance.web._lt; instance.web.views.add('form_clone', 'instance.account.extend_form_view'); instance.web.form.tags.add('list_button','instance.account.list_button') +instance.web.form.tags.add('btn_extend','instance.account.btn_extend') instance.web.form.widgets.add('many2one_pager','instance.account.many2one_pager') instance.account.extend_actionmanager = instance.web.ActionManager.include({ ir_actions_act_window: function (action, on_close) { @@ -53,7 +54,7 @@ instance.account.extend_viewmanager = instance.web.ViewManagerAction.extend({ }, start : function(){ this._super() - this.setup_exended_list_view(this) + this.setup_exended_form_view(this) }, on_mode_switch: function (view_type, no_store, options) { self = this @@ -61,7 +62,7 @@ instance.account.extend_viewmanager = instance.web.ViewManagerAction.extend({ self.list_view = self.views['list'] }) }, - setup_exended_list_view: function(parent){ + setup_exended_form_view: function(parent){ var self = this, from_view, obj_from_view; @@ -106,8 +107,8 @@ instance.account.extend_form_view = instance.web.FormView.extend({ viewmanager.action.domain = (viewmanager.action.domain || []).concat([["partner_id", "=", id]]) viewmanager.searchview.do_search() }) - } -}) + }, + }) instance.account.many2one_pager = instance.web.form.FieldMany2One.extend({ template: "FieldMany2One_Pager", display_string: function(str) { @@ -132,7 +133,30 @@ instance.account.many2one_pager = instance.web.form.FieldMany2One.extend({ } }, }) +instance.account.btn_extend = instance.web.form.WidgetButton.extend({ + on_confirmed: function() { + var self = this; + var context = this.node.attrs.context; + if (context && context.__ref) { + context = new instance.web.CompoundContext(context); + context.set_eval_context(this._build_eval_context()); + } + + return this.view.do_execute_action( + _.extend({}, this.node.attrs, {context: context}), + this.view.dataset, this.view.datarecord.id, function () { + $.when(self.view.dataset.read_slice()).then(function() { + if (!_.isEmpty(self.view.dataset.ids)){ + self.view.reload(); + //reload list view + self.view.on_pager_action() + } + }) + + }); + }, +}) instance.account.list_button = instance.web.form.WidgetButton.extend({ on_click: function() { @@ -162,7 +186,6 @@ instance.account.list_button = instance.web.form.WidgetButton.extend({ self.getParent().reload() }); }); - } })