From 3d14a3927987568b1cc8b0f006409b00191ebd1c Mon Sep 17 00:00:00 2001 From: "Tidiane Sy (BAAMTU), psi(OpenERP)" <> Date: Fri, 7 Jan 2011 13:09:16 +0530 Subject: [PATCH 1/5] [FIX] account: closing fiscal year dubled the amount of parent account lp bug: https://launchpad.net/bugs/588776 fixed bzr revid: psi@tinyerp.co.in-20110107073916-l3rq03bpmbr3ef8u --- .../wizard/account_fiscalyear_close.py | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/addons/account/wizard/account_fiscalyear_close.py b/addons/account/wizard/account_fiscalyear_close.py index 6190f792c7f..e5e7dc38f56 100755 --- a/addons/account/wizard/account_fiscalyear_close.py +++ b/addons/account/wizard/account_fiscalyear_close.py @@ -95,6 +95,7 @@ class account_fiscalyear_close(osv.osv_memory): obj='account_move_line', context={'fiscalyear': fy_ids}) cr.execute('select id from account_account WHERE active AND company_id = %s', (old_fyear.company_id.id,)) ids = map(lambda x: x[0], cr.fetchall()) + account_balanced = [] for account in obj_acc_account.browse(cr, uid, ids, context={'fiscalyear': fy_id}): accnt_type_data = account.user_type @@ -103,16 +104,7 @@ class account_fiscalyear_close(osv.osv_memory): if accnt_type_data.close_method=='none' or account.type == 'view': continue if accnt_type_data.close_method=='balance': - if abs(account.balance)>0.0001: - obj_acc_move_line.create(cr, uid, { - 'debit': account.balance>0 and account.balance, - 'credit': account.balance<0 and -account.balance, - 'name': data[0]['report_name'], - 'date': period.date_start, - 'journal_id': new_journal.id, - 'period_id': period.id, - 'account_id': account.id - }, {'journal_id': new_journal.id, 'period_id':period.id}) + account_balanced.append(account.id) if accnt_type_data.close_method == 'unreconciled': offset = 0 limit = 100 @@ -198,6 +190,27 @@ class account_fiscalyear_close(osv.osv_memory): }) obj_acc_move_line.create(cr, uid, move) offset += limit + + acc_set = ",".join(map(str, account_balanced)) + cr.execute(("SELECT l.account_id as id, " \ + "COALESCE(SUM(l.debit),0) - COALESCE(SUM(l.credit), 0) as balance " \ + "FROM " \ + "account_move_line l " \ + "WHERE " \ + "l.account_id IN (%s) " \ + " GROUP BY l.account_id") % (acc_set, )) + for res in cr.dictfetchall(): + if abs(res['balance']) > 0.0001: + obj_acc_move_line.create(cr, uid, { + 'debit': res['balance'] > 0 and res['balance'], + 'credit': res['balance'] < 0 and -res['balance'], + 'name': data[0]['report_name'], + 'date': period.date_start, + 'journal_id': new_journal.id, + 'period_id': period.id, + 'account_id': res['id'], + 'fy_opening': True + }, {'journal_id': new_journal.id, 'period_id': period.id}) ids = obj_acc_move_line.search(cr, uid, [('journal_id','=',new_journal.id), ('period_id.fiscalyear_id','=',new_fyear.id)]) context['fy_closing'] = True From 2e44e7aae1b3393df04b76db4b0d29fb704b2418 Mon Sep 17 00:00:00 2001 From: "psi (Open ERP)" Date: Mon, 10 Jan 2011 14:41:07 +0530 Subject: [PATCH 2/5] [REF] account_voucher: Define access rule for sale.receipt.report object bzr revid: psi@tinyerp.co.in-20110110091107-nccpys8plpkmd52x --- addons/account_voucher/security/ir.model.access.csv | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/account_voucher/security/ir.model.access.csv b/addons/account_voucher/security/ir.model.access.csv index e2b048dcedd..a8d9c7f580b 100755 --- a/addons/account_voucher/security/ir.model.access.csv +++ b/addons/account_voucher/security/ir.model.access.csv @@ -5,3 +5,5 @@ "access_account_voucher_line_manager","account.voucher.line","model_account_voucher_line","account.group_account_manager",1,0,0,0 "access_account_voucher_invoice","account.voucher invoice","model_account_voucher","account.group_account_invoice",1,1,1,1 "access_account_voucher_line_invoice","account.voucher.line invoice","model_account_voucher_line","account.group_account_invoice",1,1,1,1 +"access_sale_receipt_report_manager","account.sale.receipt.report","model_sale_receipt_report","account.group_account_manager",1,1,1,1 +"access_sale_receipt_report_user","account.sale.receipt.report","model_sale_receipt_report","account.group_account_user",1,0,0,0 From 45e4c9bbe2108abdc489bf5185fad5173568b20a Mon Sep 17 00:00:00 2001 From: "psi (Open ERP)" Date: Mon, 10 Jan 2011 18:05:24 +0530 Subject: [PATCH 3/5] [REF] account_voucher: Define access rule for sale.receipt.report object bzr revid: psi@tinyerp.co.in-20110110123524-0dq57hzih50ctryj --- addons/account_voucher/security/ir.model.access.csv | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/account_voucher/security/ir.model.access.csv b/addons/account_voucher/security/ir.model.access.csv index a8d9c7f580b..33a0a0edbf3 100755 --- a/addons/account_voucher/security/ir.model.access.csv +++ b/addons/account_voucher/security/ir.model.access.csv @@ -7,3 +7,5 @@ "access_account_voucher_line_invoice","account.voucher.line invoice","model_account_voucher_line","account.group_account_invoice",1,1,1,1 "access_sale_receipt_report_manager","account.sale.receipt.report","model_sale_receipt_report","account.group_account_manager",1,1,1,1 "access_sale_receipt_report_user","account.sale.receipt.report","model_sale_receipt_report","account.group_account_user",1,0,0,0 +"access_sale_receipt_report_manager","account.sale.receipt.report","model_sale_receipt_report","account.group_account_manager",1,1,1,1 +"access_sale_receipt_report_user","account.sale.receipt.report","model_sale_receipt_report","account.group_account_user",1,0,0,0 From dbd13623994f67f366dfd360a1fb22495a29ee53 Mon Sep 17 00:00:00 2001 From: "psi (Open ERP)" Date: Mon, 10 Jan 2011 18:44:37 +0530 Subject: [PATCH 4/5] [REVERT] account: revert revno 4592 bzr revid: psi@tinyerp.co.in-20110110131437-uwitx9otrtcbqccp --- .../wizard/account_fiscalyear_close.py | 33 ++++++------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/addons/account/wizard/account_fiscalyear_close.py b/addons/account/wizard/account_fiscalyear_close.py index e5e7dc38f56..6190f792c7f 100755 --- a/addons/account/wizard/account_fiscalyear_close.py +++ b/addons/account/wizard/account_fiscalyear_close.py @@ -95,7 +95,6 @@ class account_fiscalyear_close(osv.osv_memory): obj='account_move_line', context={'fiscalyear': fy_ids}) cr.execute('select id from account_account WHERE active AND company_id = %s', (old_fyear.company_id.id,)) ids = map(lambda x: x[0], cr.fetchall()) - account_balanced = [] for account in obj_acc_account.browse(cr, uid, ids, context={'fiscalyear': fy_id}): accnt_type_data = account.user_type @@ -104,7 +103,16 @@ class account_fiscalyear_close(osv.osv_memory): if accnt_type_data.close_method=='none' or account.type == 'view': continue if accnt_type_data.close_method=='balance': - account_balanced.append(account.id) + if abs(account.balance)>0.0001: + obj_acc_move_line.create(cr, uid, { + 'debit': account.balance>0 and account.balance, + 'credit': account.balance<0 and -account.balance, + 'name': data[0]['report_name'], + 'date': period.date_start, + 'journal_id': new_journal.id, + 'period_id': period.id, + 'account_id': account.id + }, {'journal_id': new_journal.id, 'period_id':period.id}) if accnt_type_data.close_method == 'unreconciled': offset = 0 limit = 100 @@ -190,27 +198,6 @@ class account_fiscalyear_close(osv.osv_memory): }) obj_acc_move_line.create(cr, uid, move) offset += limit - - acc_set = ",".join(map(str, account_balanced)) - cr.execute(("SELECT l.account_id as id, " \ - "COALESCE(SUM(l.debit),0) - COALESCE(SUM(l.credit), 0) as balance " \ - "FROM " \ - "account_move_line l " \ - "WHERE " \ - "l.account_id IN (%s) " \ - " GROUP BY l.account_id") % (acc_set, )) - for res in cr.dictfetchall(): - if abs(res['balance']) > 0.0001: - obj_acc_move_line.create(cr, uid, { - 'debit': res['balance'] > 0 and res['balance'], - 'credit': res['balance'] < 0 and -res['balance'], - 'name': data[0]['report_name'], - 'date': period.date_start, - 'journal_id': new_journal.id, - 'period_id': period.id, - 'account_id': res['id'], - 'fy_opening': True - }, {'journal_id': new_journal.id, 'period_id': period.id}) ids = obj_acc_move_line.search(cr, uid, [('journal_id','=',new_journal.id), ('period_id.fiscalyear_id','=',new_fyear.id)]) context['fy_closing'] = True From 0ad59969cad9ccda66815301806c6983485e8179 Mon Sep 17 00:00:00 2001 From: "psi (Open ERP)" Date: Mon, 10 Jan 2011 19:01:23 +0530 Subject: [PATCH 5/5] [REF] account_voucher: Define access rules for sales.recept.report object bzr revid: psi@tinyerp.co.in-20110110133123-24za0sum4x8kr5gw --- addons/account_voucher/security/ir.model.access.csv | 2 -- 1 file changed, 2 deletions(-) diff --git a/addons/account_voucher/security/ir.model.access.csv b/addons/account_voucher/security/ir.model.access.csv index 33a0a0edbf3..a8d9c7f580b 100755 --- a/addons/account_voucher/security/ir.model.access.csv +++ b/addons/account_voucher/security/ir.model.access.csv @@ -7,5 +7,3 @@ "access_account_voucher_line_invoice","account.voucher.line invoice","model_account_voucher_line","account.group_account_invoice",1,1,1,1 "access_sale_receipt_report_manager","account.sale.receipt.report","model_sale_receipt_report","account.group_account_manager",1,1,1,1 "access_sale_receipt_report_user","account.sale.receipt.report","model_sale_receipt_report","account.group_account_user",1,0,0,0 -"access_sale_receipt_report_manager","account.sale.receipt.report","model_sale_receipt_report","account.group_account_manager",1,1,1,1 -"access_sale_receipt_report_user","account.sale.receipt.report","model_sale_receipt_report","account.group_account_user",1,0,0,0