← 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:
  OpenERP Community Backports Team (ocb)
Related bugs:
  Bug #1215897 in OpenERP Addons: "OpenERP do not prevent reconciliation of move lines with different accounts"
  https://bugs.launchpad.net/openobject-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 requested to review the proposed merge of lp:~camptocamp/ocb-addons/lp1215897 into lp:ocb-addons.
=== modified file 'account/account.py'
--- account/account.py	2013-09-18 14:31:46 +0000
+++ account/account.py	2013-09-24 10:18:55 +0000
@@ -1712,8 +1712,29 @@
                     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
+                    print first_account
+                    move_lines = rec_line.line_partial_ids
+                for line in move_lines:
+                    if line.account_id.id != first_account:
+                        return False
+                    else:
+                        if line.account_id.reconcile == False:
+                            raise osv.except_osv(_('Error!'), _("Allow reconcilation should be checked in account"))
+        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']),
     ]
     
     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-09-24 10:18:55 +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-09-24 10:18:55 +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