mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
[MIG]account_lock_to_date to v12
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
'name': 'Account Lock To Date',
|
||||
'summary': """
|
||||
Allows to set an account lock date in the future.""",
|
||||
'version': '11.0.1.0.0',
|
||||
'version': '12.0.1.0.0',
|
||||
'license': 'AGPL-3',
|
||||
'author': 'Eficent, Odoo Community Association (OCA)',
|
||||
'website': 'https://github.com/OCA/account-financial-tools',
|
||||
|
||||
@@ -4,6 +4,7 @@ from datetime import datetime
|
||||
from dateutil.relativedelta import relativedelta
|
||||
import calendar
|
||||
import time
|
||||
from time import mktime
|
||||
from odoo import api, fields, models, SUPERUSER_ID, _
|
||||
from odoo.tools.misc import DEFAULT_SERVER_DATE_FORMAT
|
||||
from odoo.exceptions import ValidationError
|
||||
@@ -36,24 +37,17 @@ class ResCompany(models.Model):
|
||||
|
||||
:param vals: The values passed to the write method.
|
||||
'''
|
||||
period_lock_to_date = vals.get('period_lock_to_date') and\
|
||||
time.strptime(vals['period_lock_to_date'],
|
||||
DEFAULT_SERVER_DATE_FORMAT)
|
||||
fiscalyear_lock_to_date = vals.get('fiscalyear_lock_to_date') and\
|
||||
time.strptime(vals['fiscalyear_lock_to_date'],
|
||||
DEFAULT_SERVER_DATE_FORMAT)
|
||||
period_lock_to_date = vals.get('period_lock_to_date')
|
||||
fiscalyear_lock_to_date = vals.get('fiscalyear_lock_to_date')
|
||||
|
||||
next_month = datetime.strptime(
|
||||
fields.Date.today(),
|
||||
DEFAULT_SERVER_DATE_FORMAT) + relativedelta(months=+1)
|
||||
next_month = datetime.now() + relativedelta(months=+1)
|
||||
days_next_month = calendar.monthrange(next_month.year,
|
||||
next_month.month)
|
||||
next_month = next_month.replace(
|
||||
day=days_next_month[1]).timetuple()
|
||||
next_month = datetime.fromtimestamp(mktime(next_month)).date()
|
||||
for company in self:
|
||||
old_fiscalyear_lock_to_date = company.fiscalyear_lock_to_date and\
|
||||
time.strptime(company.fiscalyear_lock_to_date,
|
||||
DEFAULT_SERVER_DATE_FORMAT)
|
||||
old_fiscalyear_lock_to_date = company.fiscalyear_lock_to_date
|
||||
|
||||
# The user attempts to remove the lock date for advisors
|
||||
if old_fiscalyear_lock_to_date and \
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
from odoo.tests.common import TransactionCase
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
from odoo.tools.misc import DEFAULT_SERVER_DATE_FORMAT
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
class TestAccountLockToDateUpdate(TransactionCase):
|
||||
@@ -88,8 +90,16 @@ class TestAccountLockToDateUpdate(TransactionCase):
|
||||
'groups_id': [(4, self.adviser_group.id)],
|
||||
})
|
||||
wizard.sudo(self.demo_user.id).execute()
|
||||
self.assertEqual(self.company.period_lock_to_date, '2900-01-01')
|
||||
self.assertEqual(self.company.fiscalyear_lock_to_date, '2900-02-01')
|
||||
self.assertEqual(
|
||||
self.company.period_lock_to_date,
|
||||
datetime.strptime(
|
||||
'2900-01-01',
|
||||
DEFAULT_SERVER_DATE_FORMAT).date())
|
||||
self.assertEqual(
|
||||
self.company.fiscalyear_lock_to_date,
|
||||
datetime.strptime(
|
||||
'2900-02-01',
|
||||
DEFAULT_SERVER_DATE_FORMAT).date())
|
||||
|
||||
def test_03_create_move_outside_period(self):
|
||||
"""We test that we cannot create journal entries after the
|
||||
|
||||
Reference in New Issue
Block a user