diff --git a/__unported__/account_financial_report_webkit/__init__.py b/account_financial_report_webkit/__init__.py similarity index 100% rename from __unported__/account_financial_report_webkit/__init__.py rename to account_financial_report_webkit/__init__.py diff --git a/__unported__/account_financial_report_webkit/__openerp__.py b/account_financial_report_webkit/__openerp__.py similarity index 99% rename from __unported__/account_financial_report_webkit/__openerp__.py rename to account_financial_report_webkit/__openerp__.py index 38a374be..22de6562 100644 --- a/__unported__/account_financial_report_webkit/__openerp__.py +++ b/account_financial_report_webkit/__openerp__.py @@ -202,6 +202,6 @@ wkhtmltopdf. The texts are defined inside the report classes. 'tests/aged_trial_balance.yml'], # 'tests/account_move_line.yml' 'active': False, - 'installable': False, + 'installable': True, 'application': True, } diff --git a/__unported__/account_financial_report_webkit/account.py b/account_financial_report_webkit/account.py similarity index 96% rename from __unported__/account_financial_report_webkit/account.py rename to account_financial_report_webkit/account.py index 97a63797..4e1118ee 100644 --- a/__unported__/account_financial_report_webkit/account.py +++ b/account_financial_report_webkit/account.py @@ -39,7 +39,7 @@ class AccountAccount(orm.Model): 'Centralized', help="If flagged, no details will be displayed in " "the General Ledger report (the webkit one only), " - "only centralized amounts per period.") + "only centralized amounts per period."), } _defaults = { diff --git a/__unported__/account_financial_report_webkit/account_move_line.py b/account_financial_report_webkit/account_move_line.py similarity index 100% rename from __unported__/account_financial_report_webkit/account_move_line.py rename to account_financial_report_webkit/account_move_line.py diff --git a/__unported__/account_financial_report_webkit/account_view.xml b/account_financial_report_webkit/account_view.xml similarity index 100% rename from __unported__/account_financial_report_webkit/account_view.xml rename to account_financial_report_webkit/account_view.xml diff --git a/__unported__/account_financial_report_webkit/data/financial_webkit_header.xml b/account_financial_report_webkit/data/financial_webkit_header.xml similarity index 100% rename from __unported__/account_financial_report_webkit/data/financial_webkit_header.xml rename to account_financial_report_webkit/data/financial_webkit_header.xml diff --git a/__unported__/account_financial_report_webkit/i18n/account_financial_report_webkit.pot b/account_financial_report_webkit/i18n/account_financial_report_webkit.pot similarity index 100% rename from __unported__/account_financial_report_webkit/i18n/account_financial_report_webkit.pot rename to account_financial_report_webkit/i18n/account_financial_report_webkit.pot diff --git a/__unported__/account_financial_report_webkit/i18n/de.po b/account_financial_report_webkit/i18n/de.po similarity index 100% rename from __unported__/account_financial_report_webkit/i18n/de.po rename to account_financial_report_webkit/i18n/de.po diff --git a/__unported__/account_financial_report_webkit/i18n/en_US.po b/account_financial_report_webkit/i18n/en_US.po similarity index 100% rename from __unported__/account_financial_report_webkit/i18n/en_US.po rename to account_financial_report_webkit/i18n/en_US.po diff --git a/__unported__/account_financial_report_webkit/i18n/es.po b/account_financial_report_webkit/i18n/es.po similarity index 100% rename from __unported__/account_financial_report_webkit/i18n/es.po rename to account_financial_report_webkit/i18n/es.po diff --git a/__unported__/account_financial_report_webkit/i18n/fr.po b/account_financial_report_webkit/i18n/fr.po similarity index 100% rename from __unported__/account_financial_report_webkit/i18n/fr.po rename to account_financial_report_webkit/i18n/fr.po diff --git a/__unported__/account_financial_report_webkit/i18n/it.po b/account_financial_report_webkit/i18n/it.po similarity index 100% rename from __unported__/account_financial_report_webkit/i18n/it.po rename to account_financial_report_webkit/i18n/it.po diff --git a/__unported__/account_financial_report_webkit/i18n/nl.po b/account_financial_report_webkit/i18n/nl.po similarity index 100% rename from __unported__/account_financial_report_webkit/i18n/nl.po rename to account_financial_report_webkit/i18n/nl.po diff --git a/__unported__/account_financial_report_webkit/images/ledger.png b/account_financial_report_webkit/images/ledger.png similarity index 100% rename from __unported__/account_financial_report_webkit/images/ledger.png rename to account_financial_report_webkit/images/ledger.png diff --git a/__unported__/account_financial_report_webkit/report/__init__.py b/account_financial_report_webkit/report/__init__.py similarity index 100% rename from __unported__/account_financial_report_webkit/report/__init__.py rename to account_financial_report_webkit/report/__init__.py diff --git a/__unported__/account_financial_report_webkit/report/aged_partner_balance.py b/account_financial_report_webkit/report/aged_partner_balance.py similarity index 94% rename from __unported__/account_financial_report_webkit/report/aged_partner_balance.py rename to account_financial_report_webkit/report/aged_partner_balance.py index 721b787e..fd9cb550 100644 --- a/__unported__/account_financial_report_webkit/report/aged_partner_balance.py +++ b/account_financial_report_webkit/report/aged_partner_balance.py @@ -128,6 +128,7 @@ class AccountAgedTrialBalanceWebkit(PartnersOpenInvoicesWebkit): call to set_context """ + res = super(AccountAgedTrialBalanceWebkit, self).set_context( objects, data, @@ -135,21 +136,35 @@ class AccountAgedTrialBalanceWebkit(PartnersOpenInvoicesWebkit): report_type=report_type ) + agged_lines_accounts = {} + agged_totals_accounts = {} + agged_percents_accounts = {} + for acc in self.objects: - acc.aged_lines = {} - acc.agged_totals = {} - acc.agged_percents = {} - for part_id, partner_lines in acc.ledger_lines.items(): + agged_lines_accounts[acc.id] = {} + agged_totals_accounts[acc.id] = {} + agged_percents_accounts[acc.id] = {} + + for part_id, partner_lines in\ + self.localcontext['ledger_lines'][acc.id].items(): + aged_lines = self.compute_aged_lines(part_id, partner_lines, data) if aged_lines: - acc.aged_lines[part_id] = aged_lines - acc.aged_totals = totals = self.compute_totals( - acc.aged_lines.values()) - acc.aged_percents = self.compute_percents(totals) + agged_lines_accounts[acc.id][part_id] = aged_lines + agged_totals_accounts[acc.id] = totals = self.compute_totals( + agged_lines_accounts[acc.id].values()) + agged_percents_accounts[acc.id] = self.compute_percents(totals) + + self.localcontext.update({ + 'agged_lines_accounts': agged_lines_accounts, + 'agged_totals_accounts': agged_totals_accounts, + 'agged_percents_accounts': agged_percents_accounts, + }) + # Free some memory - del(acc.ledger_lines) + del(self.localcontext['ledger_lines']) return res def compute_aged_lines(self, partner_id, ledger_lines, data): diff --git a/__unported__/account_financial_report_webkit/report/common_balance_reports.py b/account_financial_report_webkit/report/common_balance_reports.py similarity index 88% rename from __unported__/account_financial_report_webkit/report/common_balance_reports.py rename to account_financial_report_webkit/report/common_balance_reports.py index c3017e3b..3d3be9ac 100644 --- a/__unported__/account_financial_report_webkit/report/common_balance_reports.py +++ b/account_financial_report_webkit/report/common_balance_reports.py @@ -276,24 +276,34 @@ class CommonBalanceReportHeaderWebkit(CommonReportHeaderWebkit): comparison_params.append(comp_params) comp_accounts_by_ids.append(comparison_result) - to_display = dict.fromkeys(account_ids, True) - objects = [] - for account in self.pool.get('account.account').browse(self.cursor, - self.uid, - account_ids): + objects = self.pool.get('account.account').browse(self.cursor, + self.uid, + account_ids) + + to_display_accounts = dict.fromkeys(account_ids, True) + init_balance_accounts = dict.fromkeys(account_ids, False) + comparisons_accounts = dict.fromkeys(account_ids, []) + debit_accounts = dict.fromkeys(account_ids, False) + credit_accounts = dict.fromkeys(account_ids, False) + balance_accounts = dict.fromkeys(account_ids, False) + + for account in objects: if not account.parent_id: # hide top level account continue if account.type == 'consolidation': - to_display.update( + to_display_accounts.update( dict([(a.id, False) for a in account.child_consol_ids])) elif account.type == 'view': - to_display.update( + to_display_accounts.update( dict([(a.id, True) for a in account.child_id])) - account.debit = accounts_by_ids[account.id]['debit'] - account.credit = accounts_by_ids[account.id]['credit'] - account.balance = accounts_by_ids[account.id]['balance'] - account.init_balance = accounts_by_ids[ - account.id].get('init_balance', 0.0) + debit_accounts['account_id'] = \ + accounts_by_ids[account.id]['debit'] + credit_accounts['account_id'] = \ + accounts_by_ids[account.id]['credit'] + balance_accounts['account_id'] = \ + accounts_by_ids[account.id]['balance'] + init_balance_accounts[account.id] = \ + accounts_by_ids[account.id].get('init_balance', 0.0) # if any amount is != 0 in comparisons, we have to display the # whole account @@ -308,21 +318,18 @@ class CommonBalanceReportHeaderWebkit(CommonReportHeaderWebkit): values.get('balance', 0.0), values.get('init_balance', 0.0))) comp_accounts.append(values) - account.comparisons = comp_accounts + comparisons_accounts[account.id] = comp_accounts # we have to display the account if a comparison as an amount or # if we have an amount in the main column # we set it as a property to let the data in the report if someone # want to use it in a custom report - display_account = display_account or any((account.debit, - account.credit, - account.balance, - account.init_balance)) - to_display.update( - {account.id: display_account and to_display[account.id]}) - objects.append(account) - - for account in objects: - account.to_display = to_display[account.id] + display_account = display_account\ + or any((account.debit, + account.credit, account.balance, + init_balance_accounts[account.id])) + to_display_accounts.update( + {account.id: display_account and + to_display_accounts[account.id]}) context_report_values = { 'fiscalyear': fiscalyear, @@ -336,5 +343,12 @@ class CommonBalanceReportHeaderWebkit(CommonReportHeaderWebkit): 'initial_balance': init_balance, 'initial_balance_mode': initial_balance_mode, 'comp_params': comparison_params, + 'to_display_accounts': to_display_accounts, + 'init_balance_accounts': init_balance_accounts, + 'comparisons_accounts': comparisons_accounts, + 'debit_accounts': debit_accounts, + 'credit_accounts': credit_accounts, + 'balance_accounts': balance_accounts, } + return objects, new_ids, context_report_values diff --git a/__unported__/account_financial_report_webkit/report/common_partner_balance_reports.py b/account_financial_report_webkit/report/common_partner_balance_reports.py similarity index 88% rename from __unported__/account_financial_report_webkit/report/common_partner_balance_reports.py rename to account_financial_report_webkit/report/common_partner_balance_reports.py index 08cc3818..b291a8bf 100644 --- a/__unported__/account_financial_report_webkit/report/common_partner_balance_reports.py +++ b/account_financial_report_webkit/report/common_partner_balance_reports.py @@ -278,19 +278,29 @@ class CommonPartnerBalanceReportHeaderWebkit(CommonBalanceReportHeaderWebkit, partner_filter_ids=partner_ids) comparison_params.append(comp_params) comp_accounts_by_ids.append(comparison_result) - objects = [] + objects = self.pool.get('account.account').browse(self.cursor, + self.uid, + account_ids) - for account in self.pool.get('account.account').browse(self.cursor, - self.uid, - account_ids): + init_balance_accounts = {} + comparisons_accounts = {} + partners_order_accounts = {} + partners_amounts_accounts = {} + debit_accounts = {} + credit_accounts = {} + balance_accounts = {} + + for account in objects: if not account.parent_id: # hide top level account continue - account.debit = accounts_by_ids[account.id]['debit'] - account.credit = accounts_by_ids[account.id]['credit'] - account.balance = accounts_by_ids[account.id]['balance'] - account.init_balance = accounts_by_ids[ + debit_accounts[account.id] = accounts_by_ids[account.id]['debit'] + credit_accounts[account.id] = accounts_by_ids[account.id]['credit'] + balance_accounts[account.id] = \ + accounts_by_ids[account.id]['balance'] + init_balance_accounts[account.id] = accounts_by_ids[ account.id].get('init_balance', 0.0) - account.partners_amounts = partner_details_by_ids[account.id] + partners_amounts_accounts[account.id] =\ + partner_details_by_ids[account.id] comp_accounts = [] for comp_account_by_id in comp_accounts_by_ids: values = comp_account_by_id.get(account.id) @@ -302,24 +312,25 @@ class CommonPartnerBalanceReportHeaderWebkit(CommonBalanceReportHeaderWebkit, for partner_id, partner_values in \ values['partners_amounts'].copy().iteritems(): - base_partner_balance = account.partners_amounts[ - partner_id]['balance'] if \ - account.partners_amounts.get(partner_id) else 0.0 + base_partner_balance = partners_amounts_accounts[account.id][partner_id]['balance']\ + if partners_amounts_accounts.get(account.id)\ + and partners_amounts_accounts.get(account.id)\ + .get(partner_id) else 0.0 partner_values.update(self._get_diff( base_partner_balance, partner_values.get('balance', 0.0))) values['partners_amounts'][ partner_id].update(partner_values) - account.comparisons = comp_accounts + comparisons_accounts[account.id] = comp_accounts all_partner_ids = reduce(add, [comp['partners_amounts'].keys() for comp in comp_accounts], - account.partners_amounts.keys()) + partners_amounts_accounts[account.id] + .keys()) - account.partners_order = self._order_partners(all_partner_ids) - - objects.append(account) + partners_order_accounts[account.id] = \ + self._order_partners(all_partner_ids) context_report_values = { 'fiscalyear': fiscalyear, @@ -333,6 +344,13 @@ class CommonPartnerBalanceReportHeaderWebkit(CommonBalanceReportHeaderWebkit, 'comp_params': comparison_params, 'initial_balance_mode': initial_balance_mode, 'compute_diff': self._get_diff, + 'init_balance_accounts': init_balance_accounts, + 'comparisons_accounts': comparisons_accounts, + 'partners_order_accounts': partners_order_accounts, + 'partners_amounts_accounts': partners_amounts_accounts, + 'debit_accounts': debit_accounts, + 'credit_accounts': credit_accounts, + 'balance_accounts': balance_accounts, } return objects, new_ids, context_report_values diff --git a/__unported__/account_financial_report_webkit/report/common_partner_reports.py b/account_financial_report_webkit/report/common_partner_reports.py similarity index 100% rename from __unported__/account_financial_report_webkit/report/common_partner_reports.py rename to account_financial_report_webkit/report/common_partner_reports.py diff --git a/__unported__/account_financial_report_webkit/report/common_reports.py b/account_financial_report_webkit/report/common_reports.py similarity index 100% rename from __unported__/account_financial_report_webkit/report/common_reports.py rename to account_financial_report_webkit/report/common_reports.py diff --git a/__unported__/account_financial_report_webkit/report/general_ledger.py b/account_financial_report_webkit/report/general_ledger.py similarity index 93% rename from __unported__/account_financial_report_webkit/report/general_ledger.py rename to account_financial_report_webkit/report/general_ledger.py index 0f62a270..df7e60bf 100644 --- a/__unported__/account_financial_report_webkit/report/general_ledger.py +++ b/account_financial_report_webkit/report/general_ledger.py @@ -119,20 +119,22 @@ class GeneralLedgerWebkit(report_sxw.rml_parse, CommonReportHeaderWebkit): ledger_lines_memoizer = self._compute_account_ledger_lines( accounts, init_balance_memoizer, main_filter, target_move, start, stop) - objects = [] - for account in self.pool.get('account.account').browse(self.cursor, - self.uid, - accounts): + objects = self.pool.get('account.account').browse(self.cursor, + self.uid, + accounts) + + init_balance = {} + ledger_lines = {} + for account in objects: if do_centralize and account.centralized \ and ledger_lines_memoizer.get(account.id): - account.ledger_lines = self._centralize_lines( + ledger_lines[account.id] = self._centralize_lines( main_filter, ledger_lines_memoizer.get(account.id, [])) else: - account.ledger_lines = ledger_lines_memoizer.get( + ledger_lines[account.id] = ledger_lines_memoizer.get( account.id, []) - account.init_balance = init_balance_memoizer.get(account.id, {}) - - objects.append(account) + init_balance[account.id] = init_balance_memoizer.get(account.id, + {}) self.localcontext.update({ 'fiscalyear': fiscalyear, @@ -142,6 +144,8 @@ class GeneralLedgerWebkit(report_sxw.rml_parse, CommonReportHeaderWebkit): 'stop_period': stop_period, 'chart_account': chart_account, 'initial_balance_mode': initial_balance_mode, + 'init_balance': init_balance, + 'ledger_lines': ledger_lines, }) return super(GeneralLedgerWebkit, self).set_context( diff --git a/__unported__/account_financial_report_webkit/report/open_invoices.py b/account_financial_report_webkit/report/open_invoices.py similarity index 90% rename from __unported__/account_financial_report_webkit/report/open_invoices.py rename to account_financial_report_webkit/report/open_invoices.py index 4e58d4ad..3afdd099 100644 --- a/__unported__/account_financial_report_webkit/report/open_invoices.py +++ b/account_financial_report_webkit/report/open_invoices.py @@ -26,7 +26,6 @@ from operator import itemgetter from mako.template import Template -import openerp.addons from openerp import pooler from openerp.osv import osv from openerp.report import report_sxw @@ -34,10 +33,11 @@ from openerp.tools.translate import _ from openerp.addons.report_webkit import report_helper from .common_partner_reports import CommonPartnersReportHeaderWebkit from .webkit_parser_header_fix import HeaderFooterTextWebKitParser +from openerp.modules.module import get_module_resource def get_mako_template(obj, *args): - template_path = openerp.addons.get_module_resource(*args) + template_path = get_module_resource(*args) return Template(filename=template_path, input_encoding='utf-8') report_helper.WebKitHelper.get_mako_template = get_mako_template @@ -145,29 +145,35 @@ class PartnersOpenInvoicesWebkit(report_sxw.rml_parse, ledger_lines_memoizer = self._compute_open_transactions_lines( account_ids, main_filter, target_move, start, stop, date_until, partner_filter=partner_ids) - objects = [] - for account in self.pool.get('account.account').browse(self.cursor, - self.uid, - account_ids): - account.ledger_lines = ledger_lines_memoizer.get(account.id, {}) - account.init_balance = init_balance_memoizer.get(account.id, {}) + objects = self.pool.get('account.account').browse(self.cursor, + self.uid, + account_ids) + + ledger_lines = {} + init_balance = {} + partners_order = {} + for account in objects: + ledger_lines[account.id] = ledger_lines_memoizer.get(account.id, + {}) + init_balance[account.id] = init_balance_memoizer.get(account.id, + {}) # we have to compute partner order based on inital balance # and ledger line as we may have partner with init bal # that are not in ledger line and vice versa ledg_lines_pids = ledger_lines_memoizer.get(account.id, {}).keys() non_null_init_balances = dict([ (ib, amounts) for ib, amounts - in account.init_balance.iteritems() + in init_balance[account.id].iteritems() if amounts['init_balance'] or amounts['init_balance_currency']]) init_bal_lines_pids = non_null_init_balances.keys() - account.partners_order = self._order_partners( + partners_order[account.id] = self._order_partners( ledg_lines_pids, init_bal_lines_pids) - account.ledger_lines = ledger_lines_memoizer.get(account.id, {}) + ledger_lines[account.id] = ledger_lines_memoizer.get(account.id, + {}) if group_by_currency: self._group_lines_by_currency(account) - objects.append(account) self.localcontext.update({ 'fiscalyear': fiscalyear, @@ -178,6 +184,9 @@ class PartnersOpenInvoicesWebkit(report_sxw.rml_parse, 'date_until': date_until, 'partner_ids': partner_ids, 'chart_account': chart_account, + 'ledger_lines': ledger_lines, + 'init_balance': init_balance, + 'partners_order': partners_order }) return super(PartnersOpenInvoicesWebkit, self).set_context( diff --git a/__unported__/account_financial_report_webkit/report/partner_balance.py b/account_financial_report_webkit/report/partner_balance.py similarity index 100% rename from __unported__/account_financial_report_webkit/report/partner_balance.py rename to account_financial_report_webkit/report/partner_balance.py diff --git a/__unported__/account_financial_report_webkit/report/partners_ledger.py b/account_financial_report_webkit/report/partners_ledger.py similarity index 91% rename from __unported__/account_financial_report_webkit/report/partners_ledger.py rename to account_financial_report_webkit/report/partners_ledger.py index 55c22ce4..df66efac 100644 --- a/__unported__/account_financial_report_webkit/report/partners_ledger.py +++ b/account_financial_report_webkit/report/partners_ledger.py @@ -146,12 +146,17 @@ class PartnersLedgerWebkit(report_sxw.rml_parse, ledger_lines = self._compute_partner_ledger_lines( accounts, main_filter, target_move, start, stop, partner_filter=partner_ids) - objects = [] - for account in self.pool.get('account.account').browse(self.cursor, - self.uid, - accounts): - account.ledger_lines = ledger_lines.get(account.id, {}) - account.init_balance = initial_balance_lines.get(account.id, {}) + objects = self.pool.get('account.account').browse(self.cursor, + self.uid, + accounts) + + init_balance = {} + ledger_lines_dict = {} + partners_order = {} + for account in objects: + ledger_lines_dict[account.id] = ledger_lines.get(account.id, {}) + init_balance[account.id] = initial_balance_lines.get(account.id, + {}) # we have to compute partner order based on inital balance # and ledger line as we may have partner with init bal # that are not in ledger line and vice versa @@ -159,17 +164,16 @@ class PartnersLedgerWebkit(report_sxw.rml_parse, if initial_balance_mode: non_null_init_balances = dict( [(ib, amounts) for ib, amounts - in account.init_balance.iteritems() + in init_balance[account.id].iteritems() if amounts['init_balance'] or amounts['init_balance_currency']]) init_bal_lines_pids = non_null_init_balances.keys() else: - account.init_balance = {} + init_balance[account.id] = {} init_bal_lines_pids = [] - account.partners_order = self._order_partners( + partners_order[account.id] = self._order_partners( ledg_lines_pids, init_bal_lines_pids) - objects.append(account) self.localcontext.update({ 'fiscalyear': fiscalyear, @@ -180,6 +184,9 @@ class PartnersLedgerWebkit(report_sxw.rml_parse, 'partner_ids': partner_ids, 'chart_account': chart_account, 'initial_balance_mode': initial_balance_mode, + 'init_balance': init_balance, + 'ledger_lines': ledger_lines_dict, + 'partners_order': partners_order }) return super(PartnersLedgerWebkit, self).set_context( diff --git a/__unported__/account_financial_report_webkit/report/print_journal.py b/account_financial_report_webkit/report/print_journal.py similarity index 100% rename from __unported__/account_financial_report_webkit/report/print_journal.py rename to account_financial_report_webkit/report/print_journal.py diff --git a/__unported__/account_financial_report_webkit/report/report.xml b/account_financial_report_webkit/report/report.xml similarity index 100% rename from __unported__/account_financial_report_webkit/report/report.xml rename to account_financial_report_webkit/report/report.xml diff --git a/__unported__/account_financial_report_webkit/report/templates/account_report_general_ledger.mako b/account_financial_report_webkit/report/templates/account_report_general_ledger.mako similarity index 94% rename from __unported__/account_financial_report_webkit/report/templates/account_report_general_ledger.mako rename to account_financial_report_webkit/report/templates/account_report_general_ledger.mako index f99f7283..4a39e91a 100644 --- a/__unported__/account_financial_report_webkit/report/templates/account_report_general_ledger.mako +++ b/account_financial_report_webkit/report/templates/account_report_general_ledger.mako @@ -75,8 +75,8 @@ %for account in objects: <% - display_initial_balance = account.init_balance and (account.init_balance.get('debit', 0.0) != 0.0 or account.init_balance.get('credit', 0.0) != 0.0) - display_ledger_lines = account.ledger_lines + display_initial_balance = init_balance[account.id] and (init_balance[account.id].get('debit') != 0.0 or init_balance[account.id].get('credit', 0.0) != 0.0) + display_ledger_lines = ledger_lines[account.id] %> %if display_account_raw(data) == 'all' or (display_ledger_lines or display_initial_balance): <% @@ -128,10 +128,10 @@