diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py index 950ee2da895..0542c9fa79e 100644 --- a/addons/account/__openerp__.py +++ b/addons/account/__openerp__.py @@ -66,8 +66,8 @@ financial year and for preparation of vouchers there is a module named account_v 'wizard/account_period_close_view.xml', 'wizard/account_reconcile_view.xml', 'wizard/account_unreconcile_view.xml', - 'account_view.xml', 'account_move_reconciliation.xml', + 'account_view.xml', 'account_report.xml', 'account_financial_report_data.xml', 'wizard/account_report_common_view.xml', diff --git a/addons/account/account_move_reconciliation.py b/addons/account/account_move_reconciliation.py index 8dee6e98b22..f885214ec65 100644 --- a/addons/account/account_move_reconciliation.py +++ b/addons/account/account_move_reconciliation.py @@ -22,12 +22,9 @@ import tools from osv import fields,osv -class res_partner(osv.osv): - _inherit = 'res.partner' - _columns = { - 'partner_move_count': fields.integer('Partner move line count') - } -res_partner() +#1. Remove field from res.partner + +#4 remove get_unreconcile_entry method mange it with domain class account_move_line(osv.osv): _inherit = "account.move.line" @@ -49,53 +46,37 @@ class account_move_reconciliation(osv.osv): _auto = False def _rec_progress(self, cr, uid, ids, prop, unknow_none, context=None): + active_ids = context.get('active_ids', []) res = 0 - cr.execute("""SELECT partner_id, reconcile_id - FROM account_move_line WHERE state <> 'draft' - GROUP BY partner_id, reconcile_id""") - result = cr.fetchall() - partner_total = len(result) - partner_reconcile = len([ (x,y) for x, y in result if y == None ]) - if partner_total: - res = float(partner_total- partner_reconcile)/partner_total * 100 - + if active_ids: + total_records = self.search(cr, uid, [('id','in',active_ids)]) + total_reconcile = 0 + for record in self.read(cr, uid, total_records, ['reconcile_count'], context=context): + if record['reconcile_count'] > 0: + total_reconcile += 1 + res = float(total_reconcile)/len(total_records) * 100 res_all = {} for id in ids: 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_reconciliation, 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'), + 'last_reconciliation_date':fields.related('partner_id', 'last_reconciliation_date' ,type='datetime', relation='res.partner', string='Last Reconciliation'), 'latest_date' :fields.date('Latest Entry'), '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'), + 'reconcile_count':fields.integer('Reconcile 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_reconciliation') cr.execute(""" CREATE or REPLACE VIEW account_move_reconciliation as ( - SELECT p.id, p.id as partner_id, - MAX(p.last_reconciliation_date) as last_reconciliation_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 + SELECT move_line.partner_id as id, move_line.partner_id, + MAX(move_line.date) as latest_date, + (select count(reconcile.id) from account_move_line as reconcile where reconcile.reconcile_id is not null and reconcile.partner_id = move_line.partner_id) as reconcile_count + FROM account_move_line as move_line where move_line.state <> 'draft' + GROUP by move_line.partner_id ) """) account_move_reconciliation() diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index b6880dab90d..8f4089e5e2c 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -1582,16 +1582,6 @@ - - Entries To Reconcile - account.move.line - form - tree,form - - - {'view_mode':True} - - Entries To Reconcile account.move.line @@ -1599,7 +1589,7 @@ tree,form [('partner_id.customer','=',True)] - + @@ -1609,7 +1599,7 @@ tree,form [('partner_id.supplier','=',True)] - +