summaryrefslogtreecommitdiff
path: root/addons/account_lock
diff options
context:
space:
mode:
authorqdp-odoo <qdp@odoo.com>2018-05-31 14:36:34 +0200
committerqdp-odoo <qdp@odoo.com>2018-05-31 14:37:24 +0200
commit579b233d383c95ca259b5333b6202b42a1dd80b0 (patch)
tree4521740e6a0ef607ca4a44fe705300f2eaa81268 /addons/account_lock
parentfb59b5601434a5d4f310672cc0923934a7333583 (diff)
[FIX] l10n_fr_certification: can't change module dependancies on stable version
Commit https://github.com/odoo/odoo/commit/2eb344f23b3a9daa8e7c7ddaead145a8b05b39bf changed the dependancies of l10n_fr_certification which is not acceptable on stable. Instead, the method to check is now moved in account module (to avoid duplicated) and it is called by l10n_fr_certification and account_lock module.
Diffstat (limited to 'addons/account_lock')
-rw-r--r--addons/account_lock/i18n/account_lock.pot24
-rw-r--r--addons/account_lock/models/res_company.py65
2 files changed, 1 insertions, 88 deletions
diff --git a/addons/account_lock/i18n/account_lock.pot b/addons/account_lock/i18n/account_lock.pot
index 8015c500a2f..2cf269729a6 100644
--- a/addons/account_lock/i18n/account_lock.pot
+++ b/addons/account_lock/i18n/account_lock.pot
@@ -20,27 +20,3 @@ msgstr ""
msgid "Companies"
msgstr ""
-#. module: account_lock
-#: code:addons/account_lock/models/res_company.py:51
-#, python-format
-msgid "The lock date for advisors is irreversible and can't be removed."
-msgstr ""
-
-#. module: account_lock
-#: code:addons/account_lock/models/res_company.py:55
-#, python-format
-msgid "The new lock date for advisors must be set after the previous lock date."
-msgstr ""
-
-#. module: account_lock
-#: code:addons/account_lock/models/res_company.py:77
-#, python-format
-msgid "You cannot define stricter conditions on advisors than on users. Please make sure that the lock date on advisor is set before the lock date for users."
-msgstr ""
-
-#. module: account_lock
-#: code:addons/account_lock/models/res_company.py:66
-#, python-format
-msgid "You cannot lock a period that is not finished yet. Please make sure that the lock date for advisors is not set after the last day of the previous month."
-msgstr ""
-
diff --git a/addons/account_lock/models/res_company.py b/addons/account_lock/models/res_company.py
index c6834f298ee..7d718b76664 100644
--- a/addons/account_lock/models/res_company.py
+++ b/addons/account_lock/models/res_company.py
@@ -1,14 +1,6 @@
# -*- coding: utf-8 -*-
-import time
-import calendar
-
-from datetime import datetime
-from dateutil.relativedelta import relativedelta
-
-from openerp import fields, models, api, _
-from openerp.exceptions import ValidationError
-from openerp.tools.misc import DEFAULT_SERVER_DATE_FORMAT
+from openerp import models, api
class ResCompany(models.Model):
@@ -20,58 +12,3 @@ class ResCompany(models.Model):
if 'fiscalyear_lock_date' in vals or 'period_lock_date' in vals:
self._check_lock_dates(vals)
return super(ResCompany, self).write(vals)
-
- @api.multi
- def _check_lock_dates(self, vals):
- '''Check the lock dates for the current companies. This can't be done in a api.constrains because we need
- to perform some comparison between new/old values. This method forces the lock dates to be irreversible.
-
- * You cannot define stricter conditions on advisors than on users. Then, the lock date on advisor must be set
- after the lock date for users.
- * You cannot lock a period that is not finished yet. Then, the lock date for advisors must be set after the
- last day of the previous month.
- * The new lock date for advisors must be set after the previous lock date.
-
- :param vals: The values passed to the write method.
- '''
- period_lock_date = vals.get('period_lock_date') and\
- time.strptime(vals['period_lock_date'], DEFAULT_SERVER_DATE_FORMAT)
- fiscalyear_lock_date = vals.get('fiscalyear_lock_date') and\
- time.strptime(vals['fiscalyear_lock_date'], DEFAULT_SERVER_DATE_FORMAT)
-
- previous_month = datetime.strptime(fields.Date.today(), DEFAULT_SERVER_DATE_FORMAT) + relativedelta(months=-1)
- days_previous_month = calendar.monthrange(previous_month.year, previous_month.month)
- previous_month = previous_month.replace(day=days_previous_month[1]).timetuple()
- for company in self:
- old_fiscalyear_lock_date = company.fiscalyear_lock_date and\
- time.strptime(company.fiscalyear_lock_date, DEFAULT_SERVER_DATE_FORMAT)
-
- # The user attempts to remove the lock date for advisors
- if old_fiscalyear_lock_date and not fiscalyear_lock_date and 'fiscalyear_lock_date' in vals:
- raise ValidationError(_('The lock date for advisors is irreversible and can\'t be removed.'))
-
- # The user attempts to set a lock date for advisors prior to the previous one
- if old_fiscalyear_lock_date and fiscalyear_lock_date and fiscalyear_lock_date < old_fiscalyear_lock_date:
- raise ValidationError(_('The new lock date for advisors must be set after the previous lock date.'))
-
- # In case of no new fiscal year in vals, fallback to the oldest
- if not fiscalyear_lock_date:
- if old_fiscalyear_lock_date:
- fiscalyear_lock_date = old_fiscalyear_lock_date
- else:
- continue
-
- # The user attempts to set a lock date for advisors prior to the last day of previous month
- if fiscalyear_lock_date > previous_month:
- raise ValidationError(_('You cannot lock a period that is not finished yet. Please make sure that the lock date for advisors is not set after the last day of the previous month.'))
-
- # In case of no new period lock date in vals, fallback to the one defined in the company
- if not period_lock_date:
- if company.period_lock_date:
- period_lock_date = time.strptime(company.period_lock_date, DEFAULT_SERVER_DATE_FORMAT)
- else:
- continue
-
- # The user attempts to set a lock date for advisors prior to the lock date for users
- if period_lock_date < fiscalyear_lock_date:
- raise ValidationError(_('You cannot define stricter conditions on advisors than on users. Please make sure that the lock date on advisor is set before the lock date for users.'))