← Back to team overview

openerp-dev-web team mailing list archive

[Merge] lp:~openerp-commiter/openobject-addons/trunk-dev-addons3-psi2 into lp:~openerp-dev/openobject-addons/trunk-dev-addons3

 

psi (OpenERP) has proposed merging lp:~openerp-commiter/openobject-addons/trunk-dev-addons3-psi2 into lp:~openerp-dev/openobject-addons/trunk-dev-addons3.

Requested reviews:
  OpenERP R&D Team (openerp-dev)
Related bugs:
  #568537 The __compute method of account_account needs optmization to improve Accounting Performance!
  https://bugs.launchpad.net/bugs/568537
  #588776 Error when closing fiscal year
  https://bugs.launchpad.net/bugs/588776
  #686508 Not able to validate sales receipt
  https://bugs.launchpad.net/bugs/686508
  #686513 Not able to validate supplier vouchers
  https://bugs.launchpad.net/bugs/686513
  #691218 add an employee to a department
  https://bugs.launchpad.net/bugs/691218
  #692139 Account Journal onchange_type method context undefined error
  https://bugs.launchpad.net/bugs/692139
  #692962 In hr contract, shouldn't be able to enter an end date lower than a start date
  https://bugs.launchpad.net/bugs/692962
  #693476 [6.0] sale manager dashboard - "Sales by Customer" - incomplete
  https://bugs.launchpad.net/bugs/693476
  #693810 [RC1]Pay button when you pay directly in Sales receipt form
  https://bugs.launchpad.net/bugs/693810
  #694937 [6.0] account entry analysis - unreconciled does not filter 
  https://bugs.launchpad.net/bugs/694937
  #695439 membership: can't open members via GTK client
  https://bugs.launchpad.net/bugs/695439
  #697207 Bug when sending followups without specifying any email address
  https://bugs.launchpad.net/bugs/697207
  #697714 Unclear warning on cancel opening entries
  https://bugs.launchpad.net/bugs/697714

For more details, see:
https://code.launchpad.net/~openerp-commiter/openobject-addons/trunk-dev-addons3-psi2/+merge/45496

Hello sir,

Fixes:
https://bugs.launchpad.net/openobject-addons/trunk/+bug/588776
   Error when closing fiscal year

Thanks
PSI
-- 
https://code.launchpad.net/~openerp-commiter/openobject-addons/trunk-dev-addons3-psi2/+merge/45496
Your team OpenERP R&D Team is requested to review the proposed merge of lp:~openerp-commiter/openobject-addons/trunk-dev-addons3-psi2 into lp:~openerp-dev/openobject-addons/trunk-dev-addons3.
=== modified file 'account/account_move_line.py'
--- account/account_move_line.py	2011-01-06 04:56:09 +0000
+++ account/account_move_line.py	2011-01-07 08:06:18 +0000
@@ -102,9 +102,9 @@
 
     def _amount_residual(self, cr, uid, ids, field_names, args, context=None):
         """
-           This function returns the residual amount on a receivable or payable account.move.line. 
-           By default, it returns an amount in the currency of this journal entry (maybe different 
-           of the company currency), but if you pass 'residual_in_company_currency' = True in the 
+           This function returns the residual amount on a receivable or payable account.move.line.
+           By default, it returns an amount in the currency of this journal entry (maybe different
+           of the company currency), but if you pass 'residual_in_company_currency' = True in the
            context then the returned amount will be in company currency.
         """
         res = {}
@@ -116,13 +116,13 @@
                 'amount_residual': 0.0,
                 'amount_residual_currency': 0.0,
             }
- 
+
             if move_line.reconcile_id:
                 continue
             if not move_line.account_id.type in ('payable', 'receivable'):
                 #this function does not suport to be used on move lines not related to payable or receivable accounts
                 continue
-            
+
             if move_line.currency_id:
                 move_line_total = move_line.amount_currency
                 sign = move_line.amount_currency < 0 and -1 or 1

=== modified file 'account/wizard/account_fiscalyear_close.py'
--- account/wizard/account_fiscalyear_close.py	2011-01-04 13:28:53 +0000
+++ account/wizard/account_fiscalyear_close.py	2011-01-07 08:06:18 +0000
@@ -95,6 +95,7 @@
                 obj='account_move_line', context={'fiscalyear': fy_ids})
         cr.execute('select id from account_account WHERE active AND company_id = %s', (old_fyear.company_id.id,))
         ids = map(lambda x: x[0], cr.fetchall())
+        account_balanced = []
         for account in obj_acc_account.browse(cr, uid, ids,
             context={'fiscalyear': fy_id}):
             accnt_type_data = account.user_type
@@ -103,16 +104,7 @@
             if accnt_type_data.close_method=='none' or account.type == 'view':
                 continue
             if accnt_type_data.close_method=='balance':
-                if abs(account.balance)>0.0001:
-                    obj_acc_move_line.create(cr, uid, {
-                        'debit': account.balance>0 and account.balance,
-                        'credit': account.balance<0 and -account.balance,
-                        'name': data[0]['report_name'],
-                        'date': period.date_start,
-                        'journal_id': new_journal.id,
-                        'period_id': period.id,
-                        'account_id': account.id
-                    }, {'journal_id': new_journal.id, 'period_id':period.id})
+                account_balanced.append(account.id)
             if accnt_type_data.close_method == 'unreconciled':
                 offset = 0
                 limit = 100
@@ -198,6 +190,27 @@
                         })
                         obj_acc_move_line.create(cr, uid, move)
                     offset += limit
+
+        acc_set = ",".join(map(str, account_balanced))
+        cr.execute(("SELECT l.account_id as id, " \
+                        "COALESCE(SUM(l.debit),0) - COALESCE(SUM(l.credit), 0) as balance " \
+                        "FROM " \
+                            "account_move_line l " \
+                        "WHERE " \
+                            "l.account_id IN (%s) " \
+                        " GROUP BY l.account_id") % (acc_set, ))
+        for res in cr.dictfetchall():
+            if abs(res['balance']) > 0.0001:
+                    obj_acc_move_line.create(cr, uid, {
+                        'debit': res['balance'] > 0 and res['balance'],
+                        'credit': res['balance'] < 0 and -res['balance'],
+                        'name': data[0]['report_name'],
+                        'date': period.date_start,
+                        'journal_id': new_journal.id,
+                        'period_id': period.id,
+                        'account_id': res['id'],
+                        'fy_opening': True
+                    }, {'journal_id': new_journal.id, 'period_id': period.id})
         ids = obj_acc_move_line.search(cr, uid, [('journal_id','=',new_journal.id),
             ('period_id.fiscalyear_id','=',new_fyear.id)])
         context['fy_closing'] = True