Skip to content
Snippets Groups Projects
Commit fb59b560 authored by Laurent Smet's avatar Laurent Smet
Browse files

[FIX] account: fix test on closed period since account_lock module

Module account_lock has been introduced by:
https://github.com/odoo/odoo/commit/2eb344f23b3a9daa8e7c7ddaead145a8b05b39bf

A new constrains appears on the lock dates: their must not be set
after the last day of the previous month.
Then, it breaks the test on closed period that set the lock date 'yesterday'.
parent 2eb344f2
No related branches found
No related tags found
No related merge requests found
from openerp.addons.account.tests.account_test_classes import AccountingTestCase
from openerp.osv.orm import except_orm
from datetime import datetime, timedelta
from datetime import datetime
from dateutil.relativedelta import relativedelta
from calendar import monthrange
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT
class TestPeriodState(AccountingTestCase):
......@@ -10,26 +12,26 @@ 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.yesterday_str = self.yesterday.strftime(DEFAULT_SERVER_DATE_FORMAT)
last_day_month = datetime.now() - relativedelta(months=1)
last_day_month = last_day_month.replace(day=monthrange(last_day_month.year, last_day_month.month)[1])
self.last_day_month_str = last_day_month.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')])
draft_entries = self.env['account.move'].search([('date', '<=', self.last_day_month_str), ('state', '=', 'draft')])
if draft_entries:
draft_entries.post()
self.user_id.company_id.write({'fiscalyear_lock_date': self.yesterday_str})
self.user_id.company_id.fiscalyear_lock_date = self.last_day_month_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]
def test_period_state(self):
cr, uid = self.cr, self.uid
with self.assertRaises(except_orm):
move = self.env['account.move'].create({
'name': '/',
'journal_id': self.sale_journal_id.id,
'date': self.day_before_yesterday.strftime(DEFAULT_SERVER_DATE_FORMAT),
'date': self.last_day_month_str,
'line_ids': [(0, 0, {
'name': 'foo',
'debit': 10,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment