From 421b7f156e2a455dd579f6621f882818b9276512 Mon Sep 17 00:00:00 2001 From: Damien Crier Date: Wed, 27 Apr 2016 17:21:10 +0200 Subject: [PATCH] [IMP] add date_range_id on ledgers wizards [FIX] restore partner ledger menuitem --- account_financial_report_qweb/__openerp__.py | 5 +++- account_financial_report_qweb/menuitems.xml | 6 +++++ .../wizard/general_ledger_wizard.xml | 2 +- .../wizard/ledger_report_wizard.py | 24 +++++++++++++++---- .../wizard/partner_ledger_wizard.xml | 10 ++------ 5 files changed, 32 insertions(+), 15 deletions(-) diff --git a/account_financial_report_qweb/__openerp__.py b/account_financial_report_qweb/__openerp__.py index 7663cd86..861940b6 100644 --- a/account_financial_report_qweb/__openerp__.py +++ b/account_financial_report_qweb/__openerp__.py @@ -15,7 +15,7 @@ 'website': 'http://www.camptocamp.com', 'depends': [ 'account', - # 'date_range', + 'date_range', ], 'data': [ 'wizard/aged_partner_balance_wizard_view.xml', @@ -30,6 +30,9 @@ 'reports.xml', # 'wizard/partner_ledger_wizard.xml', 'report/templates/ledger_general.xml', + 'wizard/partner_ledger_wizard.xml', + 'menuitems.xml', + 'reports.xml', 'report/templates/general_ledger.xml', 'report/templates/open_invoice_report.xml' ], diff --git a/account_financial_report_qweb/menuitems.xml b/account_financial_report_qweb/menuitems.xml index df97a0a0..b99d652d 100644 --- a/account_financial_report_qweb/menuitems.xml +++ b/account_financial_report_qweb/menuitems.xml @@ -15,6 +15,12 @@ id="menu_ledger_report_wizard" /> + + - + diff --git a/account_financial_report_qweb/wizard/ledger_report_wizard.py b/account_financial_report_qweb/wizard/ledger_report_wizard.py index 49d48426..3fa41fce 100644 --- a/account_financial_report_qweb/wizard/ledger_report_wizard.py +++ b/account_financial_report_qweb/wizard/ledger_report_wizard.py @@ -11,7 +11,7 @@ class LedgerReportWizard(models.TransientModel): _description = "Ledger Report Wizard" company_id = fields.Many2one(comodel_name='res.company') - # date_range = ?? + date_range_id = fields.Many2one(comodel_name='date.range', required=True) date_from = fields.Date() date_to = fields.Date() target_move = fields.Selection([('posted', 'All Posted Entries'), @@ -66,8 +66,14 @@ class LedgerReportWizard(models.TransientModel): def _build_contexts(self, data): result = {} - result['journal_ids'] = 'journal_ids' in data['form'] and data['form']['journal_ids'] or False - result['state'] = 'target_move' in data['form'] and data['form']['target_move'] or '' + result['journal_ids'] = ( + 'journal_ids' in data['form'] and + data['form']['journal_ids'] or False + ) + result['state'] = ( + 'target_move' in data['form'] and + data['form']['target_move'] or '' + ) result['date_from'] = data['form']['date_from'] or False result['date_to'] = data['form']['date_to'] or False result['strict_range'] = True if result['date_from'] else False @@ -79,7 +85,15 @@ class LedgerReportWizard(models.TransientModel): data = {} data['ids'] = self.env.context.get('active_ids', []) data['model'] = self.env.context.get('active_model', 'ir.ui.menu') - data['form'] = self.read(['date_from', 'date_to', 'journal_ids', 'target_move'])[0] + data['form'] = self.read(['date_from', 'date_to', + 'journal_ids', 'target_move'])[0] used_context = self._build_contexts(data) - data['form']['used_context'] = dict(used_context, lang=self.env.context.get('lang', 'en_US')) + data['form']['used_context'] = ( + dict(used_context, lang=self.env.context.get('lang', 'en_US')) + ) return self._print_report(data) + + @api.onchange('date_range_id') + def onchange_date_range_id(self): + self.date_from = self.date_range_id.date_start + self.date_to = self.date_range_id.date_end diff --git a/account_financial_report_qweb/wizard/partner_ledger_wizard.xml b/account_financial_report_qweb/wizard/partner_ledger_wizard.xml index f00141de..c6b920d9 100644 --- a/account_financial_report_qweb/wizard/partner_ledger_wizard.xml +++ b/account_financial_report_qweb/wizard/partner_ledger_wizard.xml @@ -13,7 +13,7 @@ - + @@ -32,7 +32,7 @@