Add patch for issue4443
This commit is contained in:
parent
19cbec1f57
commit
93500b9ab7
|
@ -0,0 +1,82 @@
|
|||
# HG changeset patch
|
||||
# User Sergi Almacellas Abellana <sergi@koolpi.com>
|
||||
Speedup fiscalyear closing process
|
||||
|
||||
issue4443
|
||||
review14841002
|
||||
|
||||
Index: trytond/trytond/modules/account/fiscalyear.py
|
||||
===================================================================
|
||||
|
||||
--- a/trytond/trytond/modules/account/fiscalyear.py
|
||||
+++ b/trytond/trytond/modules/account/fiscalyear.py
|
||||
@@ -4,7 +4,7 @@
|
||||
from trytond.model import ModelView, ModelSQL, fields
|
||||
from trytond.wizard import Wizard, StateView, StateTransition, StateAction, \
|
||||
Button
|
||||
-from trytond.tools import datetime_strftime
|
||||
+from trytond.tools import datetime_strftime, grouped_slice
|
||||
from trytond.pyson import Eval, If, PYSONEncoder
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.pool import Pool
|
||||
@@ -231,26 +231,33 @@
|
||||
return None
|
||||
return fiscalyears[0].id
|
||||
|
||||
- def _process_account(self, account):
|
||||
+ def _process_accounts(self, accounts):
|
||||
'''
|
||||
Process account for a fiscal year closed
|
||||
'''
|
||||
- Currency = Pool().get('currency.currency')
|
||||
- Deferral = Pool().get('account.account.deferral')
|
||||
+ pool = Pool()
|
||||
+ Currency = pool.get('currency.currency')
|
||||
+ Deferral = pool.get('account.account.deferral')
|
||||
|
||||
- if account.kind == 'view':
|
||||
- return
|
||||
- if not account.deferral:
|
||||
- if not Currency.is_zero(self.company.currency, account.balance):
|
||||
- self.raise_user_error('account_balance_not_zero',
|
||||
- error_args=(account.rec_name,))
|
||||
- else:
|
||||
- Deferral.create([{
|
||||
- 'account': account.id,
|
||||
- 'fiscalyear': self.id,
|
||||
- 'debit': account.debit,
|
||||
- 'credit': account.credit,
|
||||
- }])
|
||||
+ for sub_accounts in grouped_slice(accounts):
|
||||
+ to_create = []
|
||||
+ for account in sub_accounts:
|
||||
+ if account.kind == 'view':
|
||||
+ continue
|
||||
+ if not account.deferral:
|
||||
+ if not Currency.is_zero(self.company.currency,
|
||||
+ account.balance):
|
||||
+ self.raise_user_error('account_balance_not_zero',
|
||||
+ error_args=(account.rec_name,))
|
||||
+ else:
|
||||
+ to_create.append({
|
||||
+ 'account': account.id,
|
||||
+ 'fiscalyear': self.id,
|
||||
+ 'debit': account.debit,
|
||||
+ 'credit': account.credit,
|
||||
+ })
|
||||
+ if to_create:
|
||||
+ Deferral.create(to_create)
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
@@ -285,8 +292,7 @@
|
||||
accounts = Account.search([
|
||||
('company', '=', fiscalyear.company.id),
|
||||
])
|
||||
- for account in accounts:
|
||||
- fiscalyear._process_account(account)
|
||||
+ fiscalyear._process_accounts(accounts)
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
|
2
series
2
series
|
@ -15,6 +15,7 @@ issue9801002_40001.diff
|
|||
issue5731002_1.diff
|
||||
issue8791002_1.diff
|
||||
issue5881002_1.diff
|
||||
issue14841002_1.diff
|
||||
|
||||
# Multicompanyia! no borrar, no descomentar
|
||||
account_42b9acc4c201.patch
|
||||
|
@ -30,3 +31,4 @@ sale_23d0b5a3ceb1.patch
|
|||
stock_supply_780a8aaeaa78.patch
|
||||
timesheet_f8c45f1b4d7d.patch
|
||||
sale_fix_invoiced_quantity_calculation.diff
|
||||
|
||||
|
|
Loading…
Reference in New Issue