From 8c9aa6d0b036a4beee960939f393316bdcd1a4a7 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Tue, 23 Dec 2014 09:53:14 +0100 Subject: [PATCH 1/8] Aged balance report: the only sensible filter is by end period The filters by date or by start period are meaningless for an aged partner balance. Hide the choice of filters and let only the 'end period' available. --- .../i18n/account_financial_report_webkit.pot | 5 +++++ account_financial_report_webkit/i18n/de.po | 5 +++++ account_financial_report_webkit/i18n/en_US.po | 5 +++++ account_financial_report_webkit/i18n/es.po | 5 +++++ account_financial_report_webkit/i18n/fr.po | 5 +++++ account_financial_report_webkit/i18n/it.po | 5 +++++ account_financial_report_webkit/i18n/nl.po | 5 +++++ .../wizard/aged_partner_balance_wizard.py | 13 ++++++++++++- .../wizard/aged_partner_balance_wizard.xml | 11 +++++++---- 9 files changed, 54 insertions(+), 5 deletions(-) diff --git a/account_financial_report_webkit/i18n/account_financial_report_webkit.pot b/account_financial_report_webkit/i18n/account_financial_report_webkit.pot index 861c314e..92a3eab1 100644 --- a/account_financial_report_webkit/i18n/account_financial_report_webkit.pot +++ b/account_financial_report_webkit/i18n/account_financial_report_webkit.pot @@ -1516,3 +1516,8 @@ msgstr "" msgid "{'required': [('filter', '=', 'filter_opening')]}" msgstr "" +#. module: account_financial_report_webkit +#: view:account.aged.trial.balance.webkit:account_financial_report_webkit.account_aged_trial_balance_webkit +msgid "At the end of" +msgstr "" + diff --git a/account_financial_report_webkit/i18n/de.po b/account_financial_report_webkit/i18n/de.po index 8f5173d3..531d513e 100644 --- a/account_financial_report_webkit/i18n/de.po +++ b/account_financial_report_webkit/i18n/de.po @@ -1320,3 +1320,8 @@ msgstr "" #: field:trial.balance.webkit,comp2_filter:0 msgid "Compare By" msgstr "" + +#. module: account_financial_report_webkit +#: view:account.aged.trial.balance.webkit:account_financial_report_webkit.account_aged_trial_balance_webkit +msgid "At the end of" +msgstr "" diff --git a/account_financial_report_webkit/i18n/en_US.po b/account_financial_report_webkit/i18n/en_US.po index 5db4722d..43886309 100644 --- a/account_financial_report_webkit/i18n/en_US.po +++ b/account_financial_report_webkit/i18n/en_US.po @@ -1320,3 +1320,8 @@ msgstr "" #: field:trial.balance.webkit,comp2_filter:0 msgid "Compare By" msgstr "" + +#. module: account_financial_report_webkit +#: view:account.aged.trial.balance.webkit:account_financial_report_webkit.account_aged_trial_balance_webkit +msgid "At the end of" +msgstr "" diff --git a/account_financial_report_webkit/i18n/es.po b/account_financial_report_webkit/i18n/es.po index 9b5d7314..159f85c7 100644 --- a/account_financial_report_webkit/i18n/es.po +++ b/account_financial_report_webkit/i18n/es.po @@ -1367,3 +1367,8 @@ msgstr "¡Valor haber o debe erróneo en el asiento contable!" #: field:trial.balance.webkit,comp2_filter:0 msgid "Compare By" msgstr "Comparar por" + +#. module: account_financial_report_webkit +#: view:account.aged.trial.balance.webkit:account_financial_report_webkit.account_aged_trial_balance_webkit +msgid "At the end of" +msgstr "" diff --git a/account_financial_report_webkit/i18n/fr.po b/account_financial_report_webkit/i18n/fr.po index 9956dd43..02cf5c0e 100644 --- a/account_financial_report_webkit/i18n/fr.po +++ b/account_financial_report_webkit/i18n/fr.po @@ -1580,3 +1580,8 @@ msgstr "" #: view:trial.balance.webkit:account_financial_report_webkit.account_trial_balance_view_webkit msgid "{'required': [('filter', '=', 'filter_opening')]}" msgstr "" + +#. module: account_financial_report_webkit +#: view:account.aged.trial.balance.webkit:account_financial_report_webkit.account_aged_trial_balance_webkit +msgid "At the end of" +msgstr "À fin de" diff --git a/account_financial_report_webkit/i18n/it.po b/account_financial_report_webkit/i18n/it.po index 09d7de92..57b33322 100644 --- a/account_financial_report_webkit/i18n/it.po +++ b/account_financial_report_webkit/i18n/it.po @@ -1366,3 +1366,8 @@ msgstr "Valore di credito o debito errato nella registrazione contabile!" #: field:trial.balance.webkit,comp2_filter:0 msgid "Compare By" msgstr "Confronta per" + +#. module: account_financial_report_webkit +#: view:account.aged.trial.balance.webkit:account_financial_report_webkit.account_aged_trial_balance_webkit +msgid "At the end of" +msgstr "" diff --git a/account_financial_report_webkit/i18n/nl.po b/account_financial_report_webkit/i18n/nl.po index f458ed75..ff293ac8 100644 --- a/account_financial_report_webkit/i18n/nl.po +++ b/account_financial_report_webkit/i18n/nl.po @@ -1320,3 +1320,8 @@ msgstr "" #: field:trial.balance.webkit,comp2_filter:0 msgid "Compare By" msgstr "" + +#. module: account_financial_report_webkit +#: view:account.aged.trial.balance.webkit:account_financial_report_webkit.account_aged_trial_balance_webkit +msgid "At the end of" +msgstr "" diff --git a/account_financial_report_webkit/wizard/aged_partner_balance_wizard.py b/account_financial_report_webkit/wizard/aged_partner_balance_wizard.py index a3126489..1a3ddca2 100644 --- a/account_financial_report_webkit/wizard/aged_partner_balance_wizard.py +++ b/account_financial_report_webkit/wizard/aged_partner_balance_wizard.py @@ -18,7 +18,7 @@ # along with this program. If not, see . # ############################################################################## -from openerp.osv import orm +from openerp.osv import orm, fields class AccountAgedTrialBalance(orm.TransientModel): @@ -31,6 +31,17 @@ class AccountAgedTrialBalance(orm.TransientModel): _name = "account.aged.trial.balance.webkit" _description = "Aged partner balanced" + _columns = { + 'filter': fields.selection( + [('filter_period', 'Periods')], + "Filter by", + required=True), + } + + _defaults = { + 'filter': 'filter_period', + } + def _print_report(self, cr, uid, ids, data, context=None): # we update form with display account value data = self.pre_print_report(cr, uid, ids, data, context=context) diff --git a/account_financial_report_webkit/wizard/aged_partner_balance_wizard.xml b/account_financial_report_webkit/wizard/aged_partner_balance_wizard.xml index 2d0d7273..7d19e28c 100644 --- a/account_financial_report_webkit/wizard/aged_partner_balance_wizard.xml +++ b/account_financial_report_webkit/wizard/aged_partner_balance_wizard.xml @@ -42,14 +42,17 @@ onchange_fiscalyear(fiscalyear_id, period_to, date_to, until_date) - - onchange_date_to(fiscalyear_id, period_to, date_to, until_date) + + True + + + True onchange_period_to(fiscalyear_id, period_to, date_to, until_date) - - [('fiscalyear_id', '=', fiscalyear_id), ('special', '=', False)] + + At the end of [('fiscalyear_id', '=', fiscalyear_id), ('special', '=', False)] From 47333a0dc5bf42a7e92f42747c5a03465459d117 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Tue, 23 Dec 2014 10:08:33 +0100 Subject: [PATCH 2/8] Add es translation term --- account_financial_report_webkit/i18n/es.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_financial_report_webkit/i18n/es.po b/account_financial_report_webkit/i18n/es.po index 159f85c7..90497568 100644 --- a/account_financial_report_webkit/i18n/es.po +++ b/account_financial_report_webkit/i18n/es.po @@ -1371,4 +1371,4 @@ msgstr "Comparar por" #. module: account_financial_report_webkit #: view:account.aged.trial.balance.webkit:account_financial_report_webkit.account_aged_trial_balance_webkit msgid "At the end of" -msgstr "" +msgstr "Al final de" From 8bacbd6083b68b19dcda3f71c9960e3254fb40a2 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Mon, 5 Jan 2015 10:03:23 +0100 Subject: [PATCH 3/8] Remove the dates and "period from" from the aged balance tests --- .../tests/aged_trial_balance.yml | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/account_financial_report_webkit/tests/aged_trial_balance.yml b/account_financial_report_webkit/tests/aged_trial_balance.yml index d94cddab..1548d1f3 100644 --- a/account_financial_report_webkit/tests/aged_trial_balance.yml +++ b/account_financial_report_webkit/tests/aged_trial_balance.yml @@ -42,19 +42,6 @@ data_dict = {'chart_account_id':ref('account.chart0'), 'fiscalyear_id': ref('account.data_fiscalyear'), 'until_date': '%s-12-31' %(datetime.now().year), 'target_move': 'posted', 'amount_currency': True, 'result_selection': 'customer_supplier', - 'filter': 'filter_period', 'period_from': ref('account.period_1'), 'period_to': ref('account.period_12')} - from openerp.tools import test_reports - test_reports.try_report_action(cr, uid, 'action_account_aged_trial_balance_menu_webkit',wiz_data=data_dict, context=ctx, our_module='account_financial_report_webkit') - -- - In order to test the PDF Aged Partner Balance Report webkit wizard I will print report with filters on dates -- - !python {model: account.account}: | - from datetime import datetime - ctx={} - data_dict = {'chart_account_id':ref('account.chart0'), 'fiscalyear_id': ref('account.data_fiscalyear'), - 'until_date': '%s-12-31' %(datetime.now().year), 'target_move': 'posted', - 'amount_currency': True, 'result_selection': 'customer_supplier', - 'filter': 'filter_date', 'date_from': '%s-01-01' %(datetime.now().year), 'date_to': '%s-12-31' %(datetime.now().year)} + 'filter': 'filter_period', 'period_to': ref('account.period_12')} from openerp.tools import test_reports test_reports.try_report_action(cr, uid, 'action_account_aged_trial_balance_menu_webkit',wiz_data=data_dict, context=ctx, our_module='account_financial_report_webkit') From 8671e63f54f11bea341c1dd760f49d2b1db8eb6c Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Mon, 5 Jan 2015 11:02:34 +0100 Subject: [PATCH 4/8] Set a first period found because the start period is mandatory. And what we want is to look in all the periods since the beginning. Also set a default fiscal year to the current one so we have a default end period. --- .../wizard/aged_partner_balance_wizard.py | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/account_financial_report_webkit/wizard/aged_partner_balance_wizard.py b/account_financial_report_webkit/wizard/aged_partner_balance_wizard.py index 1a3ddca2..ef079860 100644 --- a/account_financial_report_webkit/wizard/aged_partner_balance_wizard.py +++ b/account_financial_report_webkit/wizard/aged_partner_balance_wizard.py @@ -18,7 +18,10 @@ # along with this program. If not, see . # ############################################################################## +from datetime import date from openerp.osv import orm, fields +from openerp.tools import DEFAULT_SERVER_DATE_FORMAT as DATE_FORMAT +from openerp.tools.translate import _ class AccountAgedTrialBalance(orm.TransientModel): @@ -31,6 +34,35 @@ class AccountAgedTrialBalance(orm.TransientModel): _name = "account.aged.trial.balance.webkit" _description = "Aged partner balanced" + def _get_current_fiscalyear(self, cr, uid, context=None): + user_obj = self.pool['res.users'] + company = user_obj.browse(cr, uid, uid, context=context).company_id + fyear_obj = self.pool['account.period'] + today = date.today().strftime(DATE_FORMAT) + fyear_ids = fyear_obj.search( + cr, uid, + [('date_start', '>=', today), + ('date_stop', '<=', today), + ('company_id', '=', company.id)], + limit=1, + context=context) + if fyear_ids: + return fyear_ids[0] + + def _get_first_period(self, cr, uid, context=None): + user_obj = self.pool['res.users'] + company = user_obj.browse(cr, uid, uid, context=context).company_id + period_obj = self.pool['account.period'] + period_ids = period_obj.search(cr, uid, + [('special', '=', False), + ('company_id', '=', company.id)], + limit=1, + order='date_start ASC', + context=context) + if not period_ids: + raise orm.except_orm(_('Error'), _('No period found')) + return period_ids[0] + _columns = { 'filter': fields.selection( [('filter_period', 'Periods')], @@ -40,6 +72,8 @@ class AccountAgedTrialBalance(orm.TransientModel): _defaults = { 'filter': 'filter_period', + 'fiscalyear_id': _get_current_fiscalyear, + 'period_from': _get_first_period, } def _print_report(self, cr, uid, ids, data, context=None): From bdda82009e55372305954a64bffc16f816a81b5e Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Mon, 5 Jan 2015 11:16:59 +0100 Subject: [PATCH 5/8] The end period must be set and thus the fiscal year too --- .../wizard/aged_partner_balance_wizard.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/account_financial_report_webkit/wizard/aged_partner_balance_wizard.py b/account_financial_report_webkit/wizard/aged_partner_balance_wizard.py index ef079860..e738ef8c 100644 --- a/account_financial_report_webkit/wizard/aged_partner_balance_wizard.py +++ b/account_financial_report_webkit/wizard/aged_partner_balance_wizard.py @@ -68,6 +68,12 @@ class AccountAgedTrialBalance(orm.TransientModel): [('filter_period', 'Periods')], "Filter by", required=True), + 'fiscalyear_id': fields.many2one( + 'account.fiscalyear', + 'Fiscal Year', help='Keep empty for all open fiscal year', + required=True), + 'period_to': fields.many2one('account.period', 'End Period', + required=True), } _defaults = { From 066f81857324b5e15161f27dbb81ce0090d9521e Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Mon, 5 Jan 2015 11:29:13 +0100 Subject: [PATCH 6/8] Set the required period to --- .../tests/aged_trial_balance.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/account_financial_report_webkit/tests/aged_trial_balance.yml b/account_financial_report_webkit/tests/aged_trial_balance.yml index 1548d1f3..4caf4e85 100644 --- a/account_financial_report_webkit/tests/aged_trial_balance.yml +++ b/account_financial_report_webkit/tests/aged_trial_balance.yml @@ -4,7 +4,9 @@ !python {model: account.account}: | from datetime import datetime ctx={} - data_dict = {'chart_account_id':ref('account.chart0'), 'until_date': '%s-12-31' %(datetime.now().year)} + data_dict = {'chart_account_id':ref('account.chart0'), 'until_date': '%s-12-31' %(datetime.now().year), + 'fiscalyear_id': ref('account.data_fiscalyear'), + 'period_to': ref('account.period_12')} from openerp.tools import test_reports test_reports.try_report_action(cr, uid, 'action_account_aged_trial_balance_menu_webkit',wiz_data=data_dict, context=ctx, our_module='account_financial_report_webkit') @@ -16,7 +18,8 @@ ctx={} data_dict = {'chart_account_id':ref('account.chart0'), 'fiscalyear_id': ref('account.data_fiscalyear'), 'until_date': '%s-12-31' %(datetime.now().year), 'target_move': 'posted', - 'amount_currency': True, 'result_selection': 'customer_supplier'} + 'amount_currency': True, 'result_selection': 'customer_supplier', + 'period_to': ref('account.period_12')} from openerp.tools import test_reports test_reports.try_report_action(cr, uid, 'action_account_aged_trial_balance_menu_webkit',wiz_data=data_dict, context=ctx, our_module='account_financial_report_webkit') @@ -29,7 +32,8 @@ data_dict = {'chart_account_id':ref('account.chart0'), 'fiscalyear_id': ref('account.data_fiscalyear'), 'until_date': '%s-12-31' %(datetime.now().year), 'target_move': 'posted', 'amount_currency': True, 'result_selection': 'customer_supplier', - 'partner_ids': [ref('base.res_partner_2'), ref('base.res_partner_1')]} + 'partner_ids': [ref('base.res_partner_2'), ref('base.res_partner_1')], + 'period_to': ref('account.period_12')} from openerp.tools import test_reports test_reports.try_report_action(cr, uid, 'action_account_aged_trial_balance_menu_webkit',wiz_data=data_dict, context=ctx, our_module='account_financial_report_webkit') From c79efef2bfad635d8028c44e39d904f646b23b23 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Mon, 5 Jan 2015 12:15:31 +0100 Subject: [PATCH 7/8] Remove contradictory help message --- .../wizard/aged_partner_balance_wizard.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_financial_report_webkit/wizard/aged_partner_balance_wizard.py b/account_financial_report_webkit/wizard/aged_partner_balance_wizard.py index e738ef8c..362ce03c 100644 --- a/account_financial_report_webkit/wizard/aged_partner_balance_wizard.py +++ b/account_financial_report_webkit/wizard/aged_partner_balance_wizard.py @@ -70,7 +70,7 @@ class AccountAgedTrialBalance(orm.TransientModel): required=True), 'fiscalyear_id': fields.many2one( 'account.fiscalyear', - 'Fiscal Year', help='Keep empty for all open fiscal year', + 'Fiscal Year', required=True), 'period_to': fields.many2one('account.period', 'End Period', required=True), From a90af8e2f4936cefc8e0d283bba3822233a78929 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Tue, 13 Jan 2015 10:20:15 +0100 Subject: [PATCH 8/8] Change the periods when the fiscal year is modified The default value on period_from is now useless because set by the onchange when we set the fiscalyear. --- .../wizard/aged_partner_balance_wizard.py | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/account_financial_report_webkit/wizard/aged_partner_balance_wizard.py b/account_financial_report_webkit/wizard/aged_partner_balance_wizard.py index 362ce03c..19caf2d4 100644 --- a/account_financial_report_webkit/wizard/aged_partner_balance_wizard.py +++ b/account_financial_report_webkit/wizard/aged_partner_balance_wizard.py @@ -49,20 +49,6 @@ class AccountAgedTrialBalance(orm.TransientModel): if fyear_ids: return fyear_ids[0] - def _get_first_period(self, cr, uid, context=None): - user_obj = self.pool['res.users'] - company = user_obj.browse(cr, uid, uid, context=context).company_id - period_obj = self.pool['account.period'] - period_ids = period_obj.search(cr, uid, - [('special', '=', False), - ('company_id', '=', company.id)], - limit=1, - order='date_start ASC', - context=context) - if not period_ids: - raise orm.except_orm(_('Error'), _('No period found')) - return period_ids[0] - _columns = { 'filter': fields.selection( [('filter_period', 'Periods')], @@ -79,9 +65,24 @@ class AccountAgedTrialBalance(orm.TransientModel): _defaults = { 'filter': 'filter_period', 'fiscalyear_id': _get_current_fiscalyear, - 'period_from': _get_first_period, } + def onchange_fiscalyear(self, cr, uid, ids, fiscalyear=False, + period_id=False, date_to=False, until_date=False, + context=None): + res = super(AccountAgedTrialBalance, self).onchange_fiscalyear( + cr, uid, ids, fiscalyear=fiscalyear, period_id=period_id, + date_to=date_to, until_date=until_date, context=context + ) + filters = self.onchange_filter(cr, uid, ids, filter='filter_period', + fiscalyear_id=fiscalyear, + context=context) + res['value'].update({ + 'period_from': filters['value']['period_from'], + 'period_to': filters['value']['period_to'], + }) + return res + def _print_report(self, cr, uid, ids, data, context=None): # we update form with display account value data = self.pre_print_report(cr, uid, ids, data, context=context)