From e2a239f4a4159ea64cf315164b7050ab1d2240bb Mon Sep 17 00:00:00 2001 From: qdp-odoo Date: Tue, 28 Mar 2017 11:59:00 +0200 Subject: [PATCH] [FIX] account: fix test. This was broken since commit 925440b7a0dbde85ec9b7a4474f205da0ef96f94 that was specifically restricting the closing of a FY if any unposted move was left in the system. --- addons/account/tests/test_account_move_closed_period.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/addons/account/tests/test_account_move_closed_period.py b/addons/account/tests/test_account_move_closed_period.py index d3e9a5b08c2..4dcb8ac777e 100644 --- a/addons/account/tests/test_account_move_closed_period.py +++ b/addons/account/tests/test_account_move_closed_period.py @@ -11,10 +11,15 @@ class TestPeriodState(AccountingTestCase): def setUp(self): super(TestPeriodState, self).setUp() cr, uid = self.cr, self.uid + self.user_id = self.env['res.users'].browse(self.uid) self.day_before_yesterday = datetime.now() - timedelta(2) self.yesterday = datetime.now() - timedelta(1) - self.user_id = self.env['res.users'].browse(self.uid) - self.user_id.company_id.write({'fiscalyear_lock_date': self.yesterday.strftime(DEFAULT_SERVER_DATE_FORMAT)}) + self.yesterday_str = self.yesterday.strftime(DEFAULT_SERVER_DATE_FORMAT) + #make sure there is no unposted entry + draft_entries = self.env['account.move'].search([('date', '<=', self.yesterday_str), ('state', '=', 'draft')]) + if draft_entries: + draft_entries.post() + self.user_id.company_id.write({'fiscalyear_lock_date': self.yesterday_str}) self.sale_journal_id = self.env['account.journal'].search([('type', '=', 'sale')])[0] self.account_id = self.env['account.account'].search([('internal_type', '=', 'receivable')])[0]