mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
[IMP] make the constraint checking the date is within the move fiscal year configurable per journal
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
##############################################################################
|
||||
{
|
||||
'name' : 'Account Constraints',
|
||||
'version' : '1.0',
|
||||
'version' : '1.1',
|
||||
'depends' : [
|
||||
'account',
|
||||
],
|
||||
@@ -37,7 +37,7 @@ and legal state of the art in other software.
|
||||
Summary of constraints are:
|
||||
|
||||
* Add a constraint on account move: you cannot pickup a date that is not
|
||||
in the fiscal year of the concerned period
|
||||
in the fiscal year of the concerned period (configurable per journal)
|
||||
|
||||
* For manual entries when multicurrency:
|
||||
|
||||
@@ -56,8 +56,13 @@ Summary of constraints are:
|
||||
that the user cannot make mistakes even in draft state, he must pass through the
|
||||
parent object to make his modification.
|
||||
|
||||
Contributors
|
||||
* Stéphane Bidoul <stephane.bidoul@acsone.eu>
|
||||
|
||||
""",
|
||||
'website': 'http://www.camptocamp.com',
|
||||
'data': [],
|
||||
'data': [
|
||||
'view/account_journal.xml',
|
||||
],
|
||||
'installable': True,
|
||||
}
|
||||
|
||||
@@ -22,15 +22,32 @@ from openerp.osv import fields, orm, osv
|
||||
from openerp.tools.translate import _
|
||||
|
||||
|
||||
class AccountJournal(orm.Model):
|
||||
_inherit = 'account.journal'
|
||||
|
||||
_columns = {
|
||||
'allow_date_fy': fields.boolean('Check Date in Fiscal Year',
|
||||
help='If set to True then do not '
|
||||
'accept the entry if '
|
||||
'the entry date is not into '
|
||||
'the fiscal year dates'),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'allow_date_fy': True,
|
||||
}
|
||||
|
||||
|
||||
class AccountMove(orm.Model):
|
||||
_inherit = "account.move"
|
||||
|
||||
def _check_fiscal_year(self, cr, uid, ids):
|
||||
for move in self.browse(cr, uid, ids):
|
||||
date_start = move.period_id.fiscalyear_id.date_start
|
||||
date_stop = move.period_id.fiscalyear_id.date_stop
|
||||
if not date_start <= move.date <= date_stop:
|
||||
return False
|
||||
if move.journal_id.allow_date_fy:
|
||||
date_start = move.period_id.fiscalyear_id.date_start
|
||||
date_stop = move.period_id.fiscalyear_id.date_stop
|
||||
if not date_start <= move.date <= date_stop:
|
||||
return False
|
||||
return True
|
||||
|
||||
_constraints = [
|
||||
|
||||
18
account_constraints/view/account_journal.xml
Normal file
18
account_constraints/view/account_journal.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="view_account_journal_allow_date_fy" model="ir.ui.view">
|
||||
<field name="name">account.journal.allow_date_fy</field>
|
||||
<field name="model">account.journal</field>
|
||||
<field name="inherit_id" ref="account.view_account_journal_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<field name="allow_date" position="after">
|
||||
<field name="allow_date_fy"/>
|
||||
</field>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
Reference in New Issue
Block a user