← Back to team overview

openerp-community-reviewer team mailing list archive

[Merge] lp:~camptocamp/ocb-addons/lp1215897 into lp:ocb-addons

 

Frederic Clementi - Camptocamp.com has proposed merging lp:~camptocamp/ocb-addons/lp1215897 into lp:ocb-addons.

Requested reviews:
  Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c): code review, no tests
  Frederic Clementi - Camptocamp.com (frederic-clementi): functional only - no code review
Related bugs:
  Bug #1215897 in OpenERP Community Backports (Addons): "OpenERP do not prevent reconciliation of move lines with different accounts"
  https://bugs.launchpad.net/ocb-addons/+bug/1215897

For more details, see:
https://code.launchpad.net/~camptocamp/ocb-addons/lp1215897/+merge/187192

fix bug possibility to reconcile different accounts
+ only account flagged as 'reconcile=true' can be reconciled


-- 
https://code.launchpad.net/~camptocamp/ocb-addons/lp1215897/+merge/187192
Your team OpenERP Community Backports Team is subscribed to branch lp:ocb-addons.
=== modified file 'account/account.py'
--- account/account.py	2013-10-04 12:12:45 +0000
+++ account/account.py	2013-10-14 13:56:08 +0000
@@ -1712,8 +1712,40 @@
                     return False
         return True
 
+    # To reconcile journal items must have same account
+    def _check_same_account(self,cr,uid,ids,context=None):
+        for rec_line in self.browse(cr, uid, ids, context=context):
+            move_lines  = []
+            if not rec_line.opening_reconciliation:
+                if rec_line.line_id:
+                    first_account = rec_line.line_id[0].account_id.id
+                    move_lines = rec_line.line_id
+                elif rec_line.line_partial_ids:
+                    first_account = rec_line.line_partial_ids[0].account_id.id
+                    move_lines = rec_line.line_partial_ids
+                for line in move_lines:
+                    if line.account_id.id != first_account:
+                        return False
+        return True
+        
+    # To reconcile allow reconcilation must be True in account
+    def _check_allow_reconcile(self, cr, uid, ids, context=None):
+        for move_line in self.browse(cr ,uid ,ids ,context=context):
+            lines = []
+            if not move_line.opening_reconciliation:
+                if move_line.line_id:
+                    lines = move_line.line_id
+                elif move_line.line_partial_ids:
+                    lines = move_line.line_partial_ids
+                for line in lines:
+                    if not line.account_id.reconcile:
+                        return False
+        return True
+            
     _constraints = [
         (_check_same_partner, 'You can only reconcile journal items with the same partner.', ['line_id']),
+        (_check_same_account, 'You can only reconcile journal items with the same account.',['line_id']),
+        (_check_allow_reconcile,'To reconcile , allow reconcilation must be true in account.',['line_id']),
     ]
     
     def reconcile_partial_check(self, cr, uid, ids, type='auto', context=None):

=== modified file 'account/demo/account_minimal.xml'
--- account/demo/account_minimal.xml	2012-10-23 16:05:04 +0000
+++ account/demo/account_minimal.xml	2013-10-14 13:56:08 +0000
@@ -112,6 +112,7 @@
             <field name="name">Cash - (test)</field>
             <field ref="cas" name="parent_id"/>
             <field name="type">liquidity</field>
+            <field eval="True" name="reconcile"/>
             <field name="user_type" ref="data_account_type_asset"/>
         </record>
 

=== modified file 'account/wizard/account_reconcile.py'
--- account/wizard/account_reconcile.py	2012-10-23 16:05:04 +0000
+++ account/wizard/account_reconcile.py	2013-10-14 13:56:08 +0000
@@ -154,7 +154,6 @@
         ids = period_obj.find(cr, uid, dt=date, context=context)
         if ids:
             period_id = ids[0]
-
         account_move_line_obj.reconcile(cr, uid, context['active_ids'], 'manual', account_id,
                 period_id, journal_id, context=context)
         return {'type': 'ir.actions.act_window_close'}


Follow ups