← Back to team overview

openerp-community-reviewer team mailing list archive

[Merge] lp:~acsone-openerp/account-financial-tools/allow_date_fy-sbi into lp:account-financial-tools

 

Stéphane Bidoul (Acsone) has proposed merging lp:~acsone-openerp/account-financial-tools/allow_date_fy-sbi into lp:account-financial-tools.

Requested reviews:
  Account Core Editors (account-core-editors)

For more details, see:
https://code.launchpad.net/~acsone-openerp/account-financial-tools/allow_date_fy-sbi/+merge/213644

account_constraints: make the constraint checking the move date is within the move fiscal year configurable per journal.

See mailing list thread for reference:

https://lists.launchpad.net/openerp-expert-accounting/msg02153.html

-sbi
-- 
https://code.launchpad.net/~acsone-openerp/account-financial-tools/allow_date_fy-sbi/+merge/213644
Your team OpenERP Community Reviewer/Maintainer is subscribed to branch lp:account-financial-tools.
=== modified file 'account_constraints/__openerp__.py'
--- account_constraints/__openerp__.py	2013-01-21 16:07:58 +0000
+++ account_constraints/__openerp__.py	2014-04-01 12:50:40 +0000
@@ -19,7 +19,7 @@
 ##############################################################################
 {
     'name' : 'Account Constraints',
-    'version' : '1.0',
+    'version' : '1.1',
     'depends' : [
                  'account',
                  ],
@@ -37,7 +37,7 @@
 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 @@
   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@xxxxxxxxx>
+
     """,
     'website': 'http://www.camptocamp.com',
-    'data': [],
+    'data': [
+        'view/account_journal.xml',
+    ],
     'installable': True,
 }

=== modified file 'account_constraints/account_constraints.py'
--- account_constraints/account_constraints.py	2013-07-11 08:33:18 +0000
+++ account_constraints/account_constraints.py	2014-04-01 12:50:40 +0000
@@ -22,15 +22,32 @@
 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 = [

=== added directory 'account_constraints/view'
=== added file 'account_constraints/view/account_journal.xml'
--- account_constraints/view/account_journal.xml	1970-01-01 00:00:00 +0000
+++ account_constraints/view/account_journal.xml	2014-04-01 12:50:40 +0000
@@ -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>
\ No newline at end of file


Follow ups