mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
[FIX] All remarks made in review: style issue, wrong usage of '\', better if check,...
This commit is contained in:
@@ -4,18 +4,17 @@
|
|||||||
# Author Joel Grand-Guillaume. Copyright 2012 Camptocamp SA
|
# Author Joel Grand-Guillaume. Copyright 2012 Camptocamp SA
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU Affero General Public License as
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
# (at your option) any later version.
|
# License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU Affero General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
import account_constraints
|
import account_constraints
|
||||||
@@ -4,29 +4,30 @@
|
|||||||
# Author Joel Grand-Guillaume. Copyright 2012 Camptocamp SA
|
# Author Joel Grand-Guillaume. Copyright 2012 Camptocamp SA
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU Affero General Public License as
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
# (at your option) any later version.
|
# License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU Affero General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
{
|
{
|
||||||
'name' : 'Account Contraints',
|
'name' : 'Account Constraints',
|
||||||
'version' : '1',
|
'version' : '1',
|
||||||
'depends' : [
|
'depends' : [
|
||||||
'account',
|
'account',
|
||||||
],
|
],
|
||||||
'author' : 'Camptocamp',
|
'author' : 'Camptocamp',
|
||||||
|
'license': 'AGPL-3',
|
||||||
'category': 'Generic Modules/Accounting',
|
'category': 'Generic Modules/Accounting',
|
||||||
'description': """
|
'description': """
|
||||||
Add contraints in the accounting module of OpenERP to avoid bad usage by users that lead
|
Add constraints in the accounting module of OpenERP to avoid bad usage by users that lead
|
||||||
to corrupted datas. This is based on our experiences and legal state of the art in other
|
to corrupted datas. This is based on our experiences and legal state of the art in other
|
||||||
software.
|
software.
|
||||||
|
|
||||||
|
|||||||
@@ -4,16 +4,16 @@
|
|||||||
# Author Joel Grand-Guillaume. Copyright 2012 Camptocamp SA
|
# Author Joel Grand-Guillaume. Copyright 2012 Camptocamp SA
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU Affero General Public License as
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
# (at your option) any later version.
|
# License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU Affero General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
@@ -26,18 +26,18 @@ from openerp.tools.translate import _
|
|||||||
class AccountMove(Model):
|
class AccountMove(Model):
|
||||||
_inherit = "account.move"
|
_inherit = "account.move"
|
||||||
|
|
||||||
def _check_fiscal_year(self, cursor, user, ids):
|
def _check_fiscal_year(self, cr, uid, ids):
|
||||||
for move in self.browse(cursor, user, ids):
|
for move in self.browse(cr, uid, ids):
|
||||||
date_start = move.period_id.fiscalyear_id.date_start
|
date_start = move.period_id.fiscalyear_id.date_start
|
||||||
date_stop = move.period_id.fiscalyear_id.date_stop
|
date_stop = move.period_id.fiscalyear_id.date_stop
|
||||||
if move.date < date_start or move.date > date_stop:
|
if not date_start <= move.date <= date_stop:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
_constraints = [
|
_constraints = [
|
||||||
(_check_fiscal_year,
|
(_check_fiscal_year,
|
||||||
'You cannot create entries with date not in the fiscal year of the chosen period',
|
'You cannot create entries with date not in the fiscal year of the chosen period',
|
||||||
['line_id','']),
|
['line_id']),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@@ -65,15 +65,15 @@ class AccountMoveLine(Model):
|
|||||||
|
|
||||||
_constraints = [
|
_constraints = [
|
||||||
(
|
(
|
||||||
_check_currency_and_amount,
|
_check_currency_and_amount,
|
||||||
"You cannot create journal items with a secondary currency without recording \
|
"You cannot create journal items with a secondary currency without "
|
||||||
both 'currency' and 'amount currency' field.",
|
"recording both 'currency' and 'amount currency' field.",
|
||||||
['currency_id','amount_currency']
|
['currency_id','amountount_currency']
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
_check_currency_amount,
|
_check_currency_amount,
|
||||||
'The amount expressed in the secondary currency must be positif when journal item\
|
"The amount expressed in the secondary currency must be positif when journal item "
|
||||||
are debit and negatif when journal item are credit.',
|
"are debit and negatif when journal item are credit.",
|
||||||
['amount_currency']
|
['amount_currency']
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
|
|||||||
Reference in New Issue
Block a user