From 28674278cd7d778e0ab3f00fce5376cefc36d839 Mon Sep 17 00:00:00 2001 From: os-kng Date: Wed, 27 Apr 2016 16:41:44 +0200 Subject: [PATCH] [IMP] Align with open invoice wizard: check date range, minor cleanup. --- .../wizard/aged_partner_balance_wizard.py | 20 +++++++++++++------ .../wizard/open_invoice_wizard.py | 2 +- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/account_financial_report_qweb/wizard/aged_partner_balance_wizard.py b/account_financial_report_qweb/wizard/aged_partner_balance_wizard.py index 546181d0..57a87fab 100644 --- a/account_financial_report_qweb/wizard/aged_partner_balance_wizard.py +++ b/account_financial_report_qweb/wizard/aged_partner_balance_wizard.py @@ -4,6 +4,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from datetime import datetime +from openerp.exceptions import Warning as UserError from openerp import api, fields, models @@ -13,12 +14,11 @@ class AccountAgedTrialBalance(models.TransientModel): _description = 'Aged partner balanced' company_id = fields.Many2one( - comodel_name='res.company', + 'res.company', string='Company', - required=True - ) - date_from = fields.Date('Date from') - date_to = fields.Date('Date to') + required=True, + default=lambda s: s.env.user.company_id + ) target_move = fields.Selection([('posted', 'All Posted Entries'), ('all', 'All Entries')], string='Target Moves', @@ -53,6 +53,14 @@ class AccountAgedTrialBalance(models.TransientModel): def onchange_atdate(self): self.until_date = self.at_date + @api.onchange('until_date') + def onchange_untildate(self): + # ---- until_date must be always >= of at_date + if self.until_date: + if self.until_date < self.at_date: + raise UserError( + 'Until Date must be equal or greater than At Date') + @api.multi def check_report(self): - return True \ No newline at end of file + return True diff --git a/account_financial_report_qweb/wizard/open_invoice_wizard.py b/account_financial_report_qweb/wizard/open_invoice_wizard.py index 713a6cc8..79591f85 100644 --- a/account_financial_report_qweb/wizard/open_invoice_wizard.py +++ b/account_financial_report_qweb/wizard/open_invoice_wizard.py @@ -56,7 +56,7 @@ class OpenInvoiceWizard(models.TransientModel): if self.until_date: if self.until_date < self.at_date: raise UserError( - 'Until Date must be equal or greater then At Date') + 'Until Date must be equal or greater than At Date') @api.multi def print_report(self):