diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py index 7045f5c069c..e01dbc70f07 100644 --- a/addons/account/__openerp__.py +++ b/addons/account/__openerp__.py @@ -104,6 +104,7 @@ module named account_voucher. 'account_invoice_view.xml', 'partner_view.xml', 'data/account_data.xml', + 'data/data_financial_report.xml', 'data/data_account_type.xml', 'account_invoice_workflow.xml', 'project/project_view.xml', @@ -122,8 +123,6 @@ module named account_voucher. 'ir_sequence_view.xml', 'company_view.xml', 'board_account_view.xml', - "wizard/account_report_profit_loss_view.xml", - "wizard/account_report_balance_sheet_view.xml", "edi/invoice_action_data.xml", "account_bank_view.xml", "account_pre_install.yml" diff --git a/addons/account/account.py b/addons/account/account.py index fd8a0506d01..fd69058ffab 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -130,6 +130,43 @@ account_payment_term_line() class account_account_type(osv.osv): _name = "account.account.type" _description = "Account Type" + + def _get_current_report_type(self, cr, uid, ids, name, arg, context=None): + obj_data = self.pool.get('ir.model.data') + obj_financial_report = self.pool.get('account.financial.report') + res = {} + financial_report_ref = { + 'asset': obj_financial_report.browse(cr, uid, obj_data.get_object_reference(cr, uid, 'account','account_financial_report_assets0')[1], context=context), + 'liability': obj_financial_report.browse(cr, uid, obj_data.get_object_reference(cr, uid, 'account','account_financial_report_liability0')[1], context=context), + 'income': obj_financial_report.browse(cr, uid, obj_data.get_object_reference(cr, uid, 'account','account_financial_report_income0')[1], context=context), + 'expense': obj_financial_report.browse(cr, uid, obj_data.get_object_reference(cr, uid, 'account','account_financial_report_expense0')[1], context=context), + } + for record in self.browse(cr, uid, ids, context=context): + res[record.id] = 'none' + for key, financial_report in financial_report_ref.items(): + list_ids = [x.id for x in financial_report.account_type_ids] + if record.id in list_ids: + res[record.id] = key + return res + + def _save_report_type(self, cr, uid, account_type_id, field_name, field_value, arg, context=None): + obj_data = self.pool.get('ir.model.data') + obj_financial_report = self.pool.get('account.financial.report') + #unlink if it exists somewhere in the financial reports related to BS or PL + financial_report_ref = { + 'asset': obj_financial_report.browse(cr, uid, obj_data.get_object_reference(cr, uid, 'account','account_financial_report_assets0')[1], context=context), + 'liability': obj_financial_report.browse(cr, uid, obj_data.get_object_reference(cr, uid, 'account','account_financial_report_liability0')[1], context=context), + 'income': obj_financial_report.browse(cr, uid, obj_data.get_object_reference(cr, uid, 'account','account_financial_report_income0')[1], context=context), + 'expense': obj_financial_report.browse(cr, uid, obj_data.get_object_reference(cr, uid, 'account','account_financial_report_expense0')[1], context=context), + } + for key, financial_report in financial_report_ref.items(): + list_ids = [x.id for x in financial_report.account_type_ids] + if account_type_id in list_ids: + obj_financial_report.write(cr, uid, [financial_report.id], {'account_type_ids': [(3, account_type_id)]}) + #write it in the good place + if field_value != 'none': + return obj_financial_report.write(cr, uid, [financial_report_ref[field_value].id], {'account_type_ids': [(4, account_type_id)]}) + _columns = { 'name': fields.char('Account Type', size=64, required=True, translate=True), 'code': fields.char('Code', size=32, required=True), @@ -139,19 +176,16 @@ class account_account_type(osv.osv): 'Balance' will generally be used for cash accounts. 'Detail' will copy each existing journal item of the previous year, even the reconciled ones. 'Unreconciled' will copy only the journal items that were unreconciled on the first day of the new fiscal year."""), - 'sign': fields.selection([(-1, 'Reverse balance sign'), (1, 'Preserve balance sign')], 'Sign on Reports', required=True, help='For accounts that are typically more debited than credited and that you would like to print as negative amounts in your reports, you should reverse the sign of the balance; e.g.: Expense account. The same applies for accounts that are typically more credited than debited and that you would like to print as positive amounts in your reports; e.g.: Income account.'), - 'report_type':fields.selection([ - ('none','/'), - ('income','Profit & Loss (Income Accounts)'), - ('expense','Profit & Loss (Expense Accounts)'), - ('asset','Balance Sheet (Asset Accounts)'), - ('liability','Balance Sheet (Liability Accounts)') - ],'P&L / BS Category', select=True, readonly=False, help="This field is used to generate legal reports: profit and loss, balance sheet.", required=True), + 'report_type': fields.function(_get_current_report_type, fnct_inv=_save_report_type, type='selection', string='P&L / BS Category', + selection= [('none','/'), + ('income', _('Profit & Loss (Income account)')), + ('expense', _('Profit & Loss (Expense account)')), + ('asset', _('Balance Sheet (Asset account)')), + ('liability', _('Balance Sheet (Liability account)'))], help="This field is used to generate legal reports: profit and loss, balance sheet.", required=True), 'note': fields.text('Description'), } _defaults = { 'close_method': 'none', - 'sign': 1, 'report_type': 'none', } _order = "code" @@ -422,6 +456,7 @@ class account_account(osv.osv): 'user_type': fields.many2one('account.account.type', 'Account Type', required=True, help="Account Type is used for information purpose, to generate " "country-specific legal reports, and set the rules to close a fiscal year and generate opening entries."), + 'financial_report_ids': fields.many2many('account.financial.report', 'account_account_financial_report', 'account_id', 'report_line_id', 'Financial Reports'), 'parent_id': fields.many2one('account.account', 'Parent', ondelete='cascade', domain=[('type','=','view')]), 'child_parent_ids': fields.one2many('account.account','parent_id','Children'), 'child_consol_ids': fields.many2many('account.account', 'account_account_consol_rel', 'child_id', 'parent_id', 'Consolidated Children'), @@ -2424,6 +2459,7 @@ class account_account_template(osv.osv): 'user_type': fields.many2one('account.account.type', 'Account Type', required=True, help="These types are defined according to your country. The type contains more information "\ "about the account and its specificities."), + 'financial_report_ids': fields.many2many('account.financial.report', 'account_template_financial_report', 'account_template_id', 'report_line_id', 'Financial Reports'), 'reconcile': fields.boolean('Allow Reconciliation', help="Check this option if you want the user to reconcile entries in this account."), 'shortcut': fields.char('Shortcut', size=12), 'note': fields.text('Note'), @@ -2510,6 +2546,7 @@ class account_account_template(osv.osv): 'reconcile': account_template.reconcile, 'shortcut': account_template.shortcut, 'note': account_template.note, + 'financial_report_ids': account_template.financial_report_ids and [(6,0,[x.id for x in account_template.financial_report_ids])] or False, 'parent_id': account_template.parent_id and ((account_template.parent_id.id in acc_template_ref) and acc_template_ref[account_template.parent_id.id]) or False, 'tax_ids': [(6,0,tax_ids)], 'company_id': company_id, @@ -2912,6 +2949,7 @@ class account_financial_report(osv.osv): return res def _get_balance(self, cr, uid, ids, name, args, context=None): + account_obj = self.pool.get('account.account') res = {} res_all = {} for report in self.browse(cr, uid, ids, context=context): @@ -2922,6 +2960,12 @@ class account_financial_report(osv.osv): # it's the sum of balance of the linked accounts for a in report.account_ids: balance += a.balance + elif report.type == 'account_type': + # it's the sum of balance of the leaf accounts with such an account type + report_types = [x.id for x in report.account_type_ids] + account_ids = account_obj.search(cr, uid, [('user_type','in', report_types), ('type','!=','view')], context=context) + for a in account_obj.browse(cr, uid, account_ids, context=context): + balance += a.balance elif report.type == 'account_report' and report.account_report_id: # it's the amount of the linked report res2 = self._get_balance(cr, uid, [report.account_report_id.id], 'balance', False, context=context) @@ -2944,7 +2988,6 @@ class account_financial_report(osv.osv): 'parent_id': fields.many2one('account.financial.report', 'Parent'), 'children_ids': fields.one2many('account.financial.report', 'parent_id', 'Account Report'), 'sequence': fields.integer('Sequence'), - 'note': fields.text('Notes'), 'balance': fields.function(_get_balance, 'Balance'), 'level': fields.function(_get_level, string='Level', store=True, type='integer'), 'type': fields.selection([ @@ -2954,13 +2997,20 @@ class account_financial_report(osv.osv): ('account_report','Report Value'), ],'Type'), 'account_ids': fields.many2many('account.account', 'account_account_financial_report', 'report_line_id', 'account_id', 'Accounts'), - 'display_detail': fields.boolean('Display details', help='Display every account with its balance instead of the sum.'), + 'display_detail': fields.selection([ + ('no_detail','No detail'), + ('detail_flat','Display children flat'), + ('detail_with_hierarchy','Display children with hierarchy') + ], 'Display details'), 'account_report_id': fields.many2one('account.financial.report', 'Report Value'), 'account_type_ids': fields.many2many('account.account.type', 'account_account_financial_report_type', 'report_id', 'account_type_id', 'Account Types'), + 'sign': fields.selection([(-1, 'Reverse balance sign'), (1, 'Preserve balance sign')], 'Sign on Reports', required=True, help='For accounts that are typically more debited than credited and that you would like to print as negative amounts in your reports, you should reverse the sign of the balance; e.g.: Expense account. The same applies for accounts that are typically more credited than debited and that you would like to print as positive amounts in your reports; e.g.: Income account.'), } _defaults = { 'type': 'sum', + 'display_detail': 'detail_flat', + 'sign': 1, } account_financial_report() @@ -3372,7 +3422,15 @@ class wizard_multi_charts_accounts(osv.osv_memory): # Create Bank journals self._create_bank_journals_from_o2m(cr, uid, obj_wizard, company_id, acc_template_ref, context=context) - return True + action = { + 'type': 'ir.actions.act_window', + 'view_type': 'form', + 'view_mode': 'form', + 'res_model': 'board.board', + 'view_id': self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account', 'board_account_form')[1], + 'menu_id': self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account', 'menu_finance')[1] + } + return action def _prepare_bank_journal(self, cr, uid, line, current_num, default_account_id, company_id, context=None): ''' diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index ab36586fe2f..53195c345f9 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -127,7 +127,7 @@ class account_bank_statement(osv.osv): _name = "account.bank.statement" _description = "Bank Statement" _columns = { - 'name': fields.char('Name', size=64, required=True, states={'draft': [('readonly', False)]}, readonly=True, help='if you give the Name other then /, its created Accounting Entries Move will be with same name as statement name. This allows the statement entries to have the same references than the statement itself'), # readonly for account_cash_statement + 'name': fields.char('Name', size=64, required=True, states={'draft': [('readonly', False)]}, readonly=True, help='If you enter a statement name other than /, its created accounting entries move name will be the statement name appended with /1, /2, /3, etc. This allows statement entries to have a reference to the bank statement they appeared on.'), # readonly for account_cash_statement 'date': fields.date('Date', required=True, states={'confirm': [('readonly', True)]}), 'journal_id': fields.many2one('account.journal', 'Journal', required=True, readonly=True, states={'draft':[('readonly',False)]}), diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 39cc471c2f6..6fcc211bd84 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -261,7 +261,7 @@ class account_invoice(osv.osv): 'partner_bank_id': fields.many2one('res.partner.bank', 'Bank Account', help='Bank Account Number, Company bank account if Invoice is customer or supplier refund, otherwise Partner bank account number.', readonly=True, states={'draft':[('readonly',False)]}), 'move_lines':fields.function(_get_lines, type='many2many', relation='account.move.line', string='Entry Lines'), - 'residual': fields.function(_amount_residual, digits_compute=dp.get_precision('Account'), string='Residual', + 'residual': fields.function(_amount_residual, digits_compute=dp.get_precision('Account'), string='To Pay', store={ 'account.invoice': (lambda self, cr, uid, ids, c={}: ids, ['invoice_line','move_id'], 50), 'account.invoice.tax': (_get_invoice_tax, None, 50), @@ -610,15 +610,15 @@ class account_invoice(osv.osv): res[r[0]].append( r[1] ) return res - def copy(self, cr, uid, id, default={}, context=None): - if context is None: - context = {} + def copy(self, cr, uid, id, default=None, context=None): + default = default or {} default.update({ 'state':'draft', 'number':False, 'move_id':False, 'move_name':False, 'internal_number': False, + 'period_id': False, }) if 'date_invoice' not in default: default.update({ @@ -1642,12 +1642,7 @@ class res_partner(osv.osv): } def copy(self, cr, uid, id, default=None, context=None): - if default is None: - default = {} - - if context is None: - context = {} - + default = default or {} default.update({'invoice_ids' : []}) return super(res_partner, self).copy(cr, uid, id, default, context) diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index d14106bab5f..55d27e2e842 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -120,7 +120,7 @@ - + @@ -269,15 +269,13 @@ - - + + + + - - - diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 55e154eed6d..e54024a6dcb 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -581,14 +581,14 @@ class account_move_line(osv.osv): lines = self.browse(cr, uid, ids, context=context) for l in lines: if l.account_id.type == 'view': - return False + raise osv.except_osv(_('Error :'), _('You can not create move line on view account %s %s') % (l.account_id.code, l.account_id.name)) return True def _check_no_closed(self, cr, uid, ids, context=None): lines = self.browse(cr, uid, ids, context=context) for l in lines: if l.account_id.type == 'closed': - return False + raise osv.except_osv(_('Error :'), _('You can not create move line on closed account %s %s') % (l.account_id.code, l.account_id.name)) return True def _check_company_id(self, cr, uid, ids, context=None): @@ -1249,6 +1249,8 @@ class account_move_line(osv.osv): if len(period_candidate_ids) != 1: raise osv.except_osv(_('Encoding error'), _('No period found or period given is ambigous.')) context['period_id'] = period_candidate_ids[0][0] + if not context.get('journal_id', False) and context.get('search_default_journal_id', False): + context['journal_id'] = context.get('search_default_journal_id') self._update_journal_check(cr, uid, context['journal_id'], context['period_id'], context) move_id = vals.get('move_id', False) journal = journal_obj.browse(cr, uid, context['journal_id'], context=context) diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index d25190e01b2..9ae59f62456 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -303,6 +303,9 @@ + + + @@ -787,7 +790,6 @@ - @@ -2781,10 +2783,14 @@ action = pool.get('res.config').next(cr, uid, [], context) + - - - + + + + + @@ -2793,9 +2799,6 @@ action = pool.get('res.config').next(cr, uid, [], context) - - - diff --git a/addons/account/configurable_account_chart.xml b/addons/account/configurable_account_chart.xml index 0ac7a51405d..7e1de5b5f7e 100644 --- a/addons/account/configurable_account_chart.xml +++ b/addons/account/configurable_account_chart.xml @@ -1,26 +1,6 @@ - + - - Receivable - receivable - income - unreconciled - - - - Payable - payable - expense - unreconciled - - - - View - view - none - - Income View view @@ -41,78 +21,32 @@ liability liability - - - Income - income - income - none - - - - Expense - expense - expense - none - - Tax tax - expense unreconciled + expense - - - Cash - cash - asset - balance - - - - Liability - liability - liability - balance - - - - Asset - asset - asset - balance - - Equity equity + balance liability - balance - - - Bank - bank - asset - balance - - + Check check - asset balance + asset - - 0 Configurable Account Chart view - + @@ -122,7 +56,7 @@ Balance Sheet view - + @@ -162,7 +96,7 @@ Purchased Stocks other - + @@ -171,7 +105,7 @@ receivable - + @@ -179,7 +113,7 @@ Tax Paid other - + @@ -195,7 +129,7 @@ Opening Income Account other - + @@ -212,7 +146,7 @@ payable - + @@ -220,7 +154,7 @@ Tax Received other - + @@ -229,7 +163,7 @@ other - + @@ -237,7 +171,7 @@ Opening Expense Account other - + @@ -247,7 +181,7 @@ Profit and Loss view - + @@ -263,7 +197,7 @@ Product Sales other - + @@ -279,7 +213,7 @@ Cost of Goods Sold other - + @@ -295,7 +229,7 @@ Expenses other - + @@ -303,7 +237,7 @@ Salary Expenses other - + diff --git a/addons/account/data/data_account_type.xml b/addons/account/data/data_account_type.xml index ebed0ebb5de..590357ef080 100644 --- a/addons/account/data/data_account_type.xml +++ b/addons/account/data/data_account_type.xml @@ -30,21 +30,25 @@ Asset asset balance + asset Liability liability balance + liability Income income none + income Expense expense none + expense diff --git a/addons/account/data/data_financial_report.xml b/addons/account/data/data_financial_report.xml new file mode 100644 index 00000000000..18624f94749 --- /dev/null +++ b/addons/account/data/data_financial_report.xml @@ -0,0 +1,43 @@ + + + + + + Balance Sheet + sum + + + Assets + + detail_with_hierarchy + account_type + + + Liability + + detail_with_hierarchy + account_type + + + + Profit and Loss + sum + + + Income + + detail_with_hierarchy + account_type + + + Expense + + detail_with_hierarchy + account_type + + + + + diff --git a/addons/account/demo/account_minimal.xml b/addons/account/demo/account_minimal.xml index 50b597c8e49..baa94450f02 100644 --- a/addons/account/demo/account_minimal.xml +++ b/addons/account/demo/account_minimal.xml @@ -5,58 +5,11 @@ Account Type --> - - View - view - none - - - Asset - asset - asset - balance - - - Receivable - receivable - asset - unreconciled - - - Liability - liability - liability - balance - - - Payable - payable - liability - unreconciled - - - Income - income - income - none - - - Expense - expense - expense - none - Equity equity + balance liability - balance - - - Cash - cash - asset - balance @@ -78,14 +31,14 @@ Balance Sheet - (test) view - + Assets - (test) X10 view - + @@ -95,7 +48,7 @@ Fixed Assets - (test) view - + @@ -103,7 +56,7 @@ Fixed Asset Account - (test) other - + @@ -111,7 +64,7 @@ Net Current Assets - (test) view - + @@ -119,7 +72,7 @@ Current Assets - (test) view - + @@ -127,7 +80,7 @@ Purchased Stocks - (test) other - + @@ -136,7 +89,7 @@ receivable - + @@ -144,7 +97,7 @@ Output VAT - (test) other - + @@ -152,7 +105,7 @@ Bank Current Account - (test) liquidity - + @@ -160,7 +113,7 @@ Cash - (test) liquidity - + @@ -168,14 +121,14 @@ Opening Income - (test) other - + Liabilities - (test) X11 view - + @@ -185,7 +138,7 @@ Current Liabilities - (test) view - + @@ -194,7 +147,7 @@ payable - + @@ -202,7 +155,7 @@ Input VAT - (test) other - + @@ -210,7 +163,7 @@ Reserve and Profit/Loss - (test) other - + @@ -218,7 +171,7 @@ Opening Expense - (test) other - + @@ -228,14 +181,14 @@ Profit and Loss - (test) view - + Income - (test) X20 view - + @@ -244,7 +197,7 @@ Foreign Exchange Gain - (test) X201 other - + @@ -254,7 +207,7 @@ Revenue - (test) view - + @@ -262,14 +215,14 @@ Product Sales - (test) other - + Expense - (test) X21 view - + @@ -280,7 +233,7 @@ Cost of Sales - (test) view - + @@ -288,7 +241,7 @@ Cost of Goods Sold - (test) other - + @@ -296,7 +249,7 @@ Overheads - (test) view - + @@ -304,14 +257,14 @@ Expenses - (test) other - + Foreign Exchange Loss - (test) X2111 other - + @@ -321,7 +274,7 @@ Salary Expenses - (test) other - + diff --git a/addons/account/project/project_view.xml b/addons/account/project/project_view.xml index d6df834f4e8..da6ec7f73a1 100644 --- a/addons/account/project/project_view.xml +++ b/addons/account/project/project_view.xml @@ -10,7 +10,7 @@ - + @@ -59,7 +59,7 @@ - + @@ -82,8 +82,8 @@
- - + + diff --git a/addons/account/report/__init__.py b/addons/account/report/__init__.py index 90254c53bda..70ceb4b8f83 100644 --- a/addons/account/report/__init__.py +++ b/addons/account/report/__init__.py @@ -33,13 +33,10 @@ import account_print_overdue import account_aged_partner_balance #import tax_report import account_tax_report -import account_balance_landscape import account_invoice_report import account_report import account_entries_report import account_analytic_entries_report -import account_balance_sheet -import account_profit_loss import account_treasury_report import account_financial_report diff --git a/addons/account/report/account_balance_landscape.py b/addons/account/report/account_balance_landscape.py deleted file mode 100644 index 4e62a9777c9..00000000000 --- a/addons/account/report/account_balance_landscape.py +++ /dev/null @@ -1,393 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2010 Tiny SPRL (). -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - -import time -import locale -from report import report_sxw - -parents = { - 'tr':1, - 'li':1, - 'story': 0, - 'section': 0 -} - -class account_balance_landscape(report_sxw.rml_parse): - def __init__(self, cr, uid, name, context): - super(account_balance_landscape, self).__init__(cr, uid, name, context=context) - self.flag=1 - self.dr_total= 0.00 - self.cr_total= 0.00 - self.parent_bal=0 - self.status=0 - self.done_total=0 - self.baldiv={} - self.empty_parent=0 - self.result_total = {} - self.total_for_perc=[] - self.localcontext.update({ - 'time': time, - 'lines': self.lines, - 'get_lines':self.get_lines, - 'linesForTotal': self.linesForTotal, - 'linesForYear': self.linesForYear, - 'get_years':self.get_years, - 'cal_total':self.cal_total, - 'total_dr':self.total_dr, - 'total_cr':self.total_cr - }) - self.context = context - - def linesForYear(self,form): - temp=0 - years={} - - global pattern - global show - global perc - global bal_zero - global ref_bal - - pattern=form['compare_pattern'] - - if form['show_columns']!=1: - show=0 - else: - show=form['show_columns'] - - if form['format_perc']!=1: - perc=0 - else: - perc=form['format_perc'] - - if form['account_choice']=='bal_zero': - bal_zero=0 - else: - bal_zero=1 - - ctx = self.context.copy() - - if perc==1: - if form['select_account']!=False: - ref_ac=self.pool.get('account.account').browse(self.cr, self.uid, form['select_account'], ctx.copy()) - if ref_ac.balance<>0.00: - ref_bal=ref_ac.balance - else: - ref_bal=1.00 - else: - ref_bal='nothing' - else: - ref_bal='nothing' - - - self.done_total=1 - self.total_for_perc=self.linesForTotal(form, ids={}, doneAccount={}, level=1) - self.done_total=0 - - for t1 in range(0,len(form['fiscalyear'])): - locale.setlocale(locale.LC_ALL, '') - self.result_total["sum_credit" + str(t1)]=locale.format("%.2f", self.result_total["sum_credit" + str(t1)], grouping=True) - self.result_total["sum_debit" + str(t1)]=locale.format("%.2f", self.result_total["sum_debit" + str(t1)], grouping=True) - - for temp in range(0,len(form['fiscalyear'])): - fy=self.pool.get('account.fiscalyear').name_get(self.cr, self.uid, form['fiscalyear'][temp]) - years["year"+str(temp)]=fy[0][1][12:16] - - return [years] - - - def linesForTotal(self, form, ids={}, doneAccount={}, level=1): - if not self.done_total==1: - return [self.result_total] - accounts=[] - if not ids: - ids = self.ids - if not ids: - return [] - - ctx = self.context.copy() - - for id in form['fiscalyear']: - tmp=[] - - ctx['fiscalyear'] = id - ctx['periods'] = form['periods'] - ctx['period_manner'] = form['period_manner'] - ctx['state'] = form['context'].get('state','all') - tmp = self.pool.get('account.account').browse(self.cr, self.uid, ids, ctx.copy()) - - if tmp: - accounts.append(tmp) - - merged_accounts=zip(*accounts) - # used to check for the frst record so all sum_credit and sum_debit r set to 0.00 - if level==1: - doneAccount={} - for entry in merged_accounts: - - if entry[0].id in doneAccount: - continue - doneAccount[entry[0].id] = 1 - - for k in range(0,len(entry)): - temp_credit=0.00 - temp_debit=0.00 - if entry[0].type <> 'view': - temp_credit+=entry[k].credit - temp_debit+=entry[k].debit - - if self.flag==1: - self.result_total["sum_credit" + str(k)]=0.00 - self.result_total["sum_debit" + str(k)]=0.00 - - if form['account_choice']=='bal_zero': - if temp_credit<>temp_debit: - self.result_total["sum_credit" + str(k)]+=temp_credit - self.result_total["sum_debit" + str(k)]+=temp_debit - else: - self.result_total["sum_credit" + str(k)]+=temp_credit - self.result_total["sum_debit" + str(k)]+=temp_debit - - self.flag=2 - - if entry[0].child_id: - ids2 = [(x.code,x.id) for x in entry[0].child_id] - ids2.sort() - - result_total_parent = self.linesForTotal(form, [x[1] for x in ids2], doneAccount, level+1) - - return [self.result_total] - - def lines(self, form, ids={}, done={}, level=1): - accounts=[] - if not ids: - ids = self.ids - if not ids: - return [] - result = [] - ctx = self.context.copy() - tmp1=[] - for id in form['fiscalyear']: - - ctx['fiscalyear'] = id - ctx['periods'] = form['periods'] - ctx['period_manner']=form['period_manner'] - ctx['state'] = form['context'].get('state','all') - tmp1 = self.pool.get('account.account').browse(self.cr, self.uid, ids, ctx.copy()) - - if tmp1: - accounts.append(tmp1) - - if level==1: #if parent is called,done is not empty when called again. - done={} - - def cmp_code(x, y): - return cmp(x.code, y.code) - for n in range(0,len(accounts)): - accounts[n].sort(cmp_code) - merged_accounts=zip(*accounts) - - for entry in merged_accounts: - j=0 - checked=1 - - if form['account_choice']!='all': # if checked,include empty a/c;not otherwise - checked=0 - - if entry[0].id in done: - continue - done[entry[0].id] = 1 - - if entry[0].child_id: # this is for parent account,dont check 0 for it - checked=4 - self.status=1 # for displaying it Bold - else: - self.status=0 - if checked==0: - i=0 - for i in range(0,len(entry)): - if bal_zero==0: - if entry[i].balance<>0.0: - checked=4 - break - else: - checked=3 - i=i+1 - else: - if entry[i].credit <> 0.0 or entry[i].debit <> 0.0: - checked=4 - break - else: - checked=3 - i=i+1 - - if checked==3: - # this is the point where we skip those accounts which are encountered as empty ones - continue - self.empty_parent=0 - else: - self.empty_parent=1 - res = { - 'code': entry[0].code, - 'name': entry[0].name, - 'level': level, - 'status': self.status, - } - - for j in range(0,len(entry)): - - locale.setlocale(locale.LC_ALL, '') - res["debit"+str(j)]=locale.format("%.2f", entry[j].debit, grouping=True) - res["credit"+str(j)]=locale.format("%.2f", entry[j].credit, grouping=True) - res["balance"+str(j)]=locale.format("%.2f", entry[j].balance, grouping=True) - - - if j==0: - res["bal_cash"+str(j)]="0.00" - res["bal_perc"+str(j)]="0.00%" - else: - temp_cash=entry[j].balance - entry[j-1].balance - res["bal_cash"+str(j)]=locale.format("%.2f", temp_cash, grouping=True) - if entry[j-1].balance<>0.00: - temp_perc=(entry[j].balance - entry[j-1].balance )*100/entry[j-1].balance - else: - temp_perc=(entry[j].balance) *100 - - res["bal_perc"+str(j)]=locale.format("%.2f", temp_perc) + "%" - - - if ref_bal=='nothing': - if level==1: - self.parent_bal=1 - else: - self.parent_bal=0 - - if self.parent_bal==1: - res["balance_perc"+str(j)]="/" - else: - if entry[j].balance==0.00: - if self.baldiv["baldiv"+str(level-1)+str(j)]<>0.00: - res["balance_perc"+str(j)]="0.00%" - else: - res["balance_perc"+str(j)]="/" - else: - if self.baldiv["baldiv"+str(level-1)+str(j)]<>0.00: - temp=self.baldiv["baldiv"+str(level-1)+str(j)] - temp1=(entry[j].balance * 100 )/ float(temp) - temp1=round(temp1,2) - res["balance_perc" + str(j)]=str(temp1)+"%" - else: - res["balance_perc"+str(j)]="/" - else: - res["balance_perc"+str(j)]=str( (entry[j].balance * 100 )/ float(ref_bal)) + "%" - - result.append(res) - - if entry[0].child_id: - - for q in range(0,len(form['fiscalyear'])): - self.baldiv["baldiv"+str(level)+str(q)]=entry[q].balance - - ids2 = [(x.code,x.id) for x in entry[0].child_id] - ids2.sort() - dir=[] - dir += self.lines(form, [x[1] for x in ids2], done, level+1) - if dir==[]: - for w in range(0,len(form['fiscalyear'])): - if entry[w].credit <> 0.0 or entry[w].debit <> 0.0 or entry[w].balance<>0.00: - dont_pop=1 - break - else: - dont_pop=0 - if dont_pop==1: - result +=dir - else: - result.pop(-1) # here we pop up the parent having its children as emprty accounts - else: - result +=dir - - return result - - def get_years(self, form): - result =[] - res={} - for temp in range(0, len(form['fiscalyear'])): - res={} - fy=self.pool.get('account.fiscalyear').name_get(self.cr, self.uid, form['fiscalyear'][temp]) - res['year']=fy[0][1] - res['last_str']=temp - - result.append(res) - self.linesForYear(form) - return result - - def get_lines(self, year_dict, form): - final_result = [] - res = {} - line_l = self.lines(form) - self.cal_total(year_dict) - if line_l: - for l in line_l: - res = {} - res['code'] = l['code'] - res['name'] = l['name'] - res['level'] = l['level'] - for k,v in l.items(): - if k.startswith('debit'+str(year_dict['last_str'])): - res['debit'] = v - if k.startswith('credit'+str(year_dict['last_str'])): - res['credit'] = v - if k.startswith('balance'+str(year_dict['last_str'])) and not k.startswith('balance_perc'+str(year_dict['last_str'])): - res['balance'] =v - if k.startswith('balance_perc'+str(year_dict['last_str'])) and not k.startswith('balance'+str(year_dict['last_str'])): - res['balance_perc'] = v - if form['compare_pattern'] == 'bal_perc': - if k.startswith('bal_perc'+str(year_dict['last_str'])): - res['pattern'] = v - elif form['compare_pattern'] == 'bal_cash': - if k.startswith('bal_cash'+str(year_dict['last_str'])): - res['pattern'] = v - else: - res['pattern'] = '' - final_result.append(res) - return final_result - - def cal_total(self, year_dict): - total_l = self.result_total - if total_l: - for k,v in total_l.items(): - if k.startswith('sum_debit'+str(year_dict['last_str'])): - self.dr_total = v - elif k.startswith('sum_credit'+str(year_dict['last_str'])): - self.cr_total = v - else: - continue - return True - - def total_dr(self): - return self.dr_total - - def total_cr(self): - return self.cr_total - -report_sxw.report_sxw('report.account.account.balance.landscape', 'account.account', 'addons/account/report/account_balance_landscape.rml', parser=account_balance_landscape, header="internal landscape") -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/addons/account/report/account_balance_landscape.rml b/addons/account/report/account_balance_landscape.rml deleted file mode 100644 index d8e4881bbbe..00000000000 --- a/addons/account/report/account_balance_landscape.rml +++ /dev/null @@ -1,317 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [[ repeatIn(get_years(data['form']), 'y') ]] - - - - Account Balance - [[ company.currency_id.name ]] - - - - - - - Year : [[ y['year'] ]] - - - - [[ data['form']['show_columns'] and 'Code' or removeParentNode('blockTable') ]] - - - Account Name - - - [[ data['form']['compare_pattern']!='none' and 'C.S.Y.T.(C./P)' or removeParentNode('font') ]] - - - Debit - - - Credit - - - Balance - - - - - - - - - - [[ data['form']['show_columns'] and removeParentNode('blockTable') or 'Code' ]] - - - Account Name - - - [[ data['form']['compare_pattern']!='none' and 'C.S.Y.T.(C./P)' or removeParentNode('font') ]] - - - Balance - - - - - - -
- [[ repeatIn(get_lines(y,data['form']), 'a') ]] - - - - [[ (data['form']['format_perc'] or not data['form']['show_columns']) and removeParentNode('blockTable') ]] [[ a['code'] ]] - - - [['.....'*(a['level']-1) ]][[ a['name'] ]] - - - [[ a['pattern'] ]] - - - [[ a['debit'] ]] - - - [[ a['credit'] ]] - - - [[ a['balance'] ]] - - - - - - - - [[ (not data['form']['format_perc'] or not data['form']['show_columns']) and removeParentNode('blockTable') ]] [[ a['code'] ]] - - - [['.....'*(a['level']-1) ]] [[ a['name'] ]] - - - [[ a['pattern'] ]] - - - [[ a['debit'] ]] - - - [[ a['credit'] ]] - - - [[ a['balance'] ]] - - - [[ a['balance_perc'] ]] - - - - - - - - - - [[ (data['form']['format_perc'] or data['form']['show_columns']) and removeParentNode('blockTable') ]] [[ a['code'] ]] - - - [['.....'*(a['level']-1) ]] [[ a['name'] ]] - - - [[ a['pattern'] ]] - - - [[ a['balance'] ]] - - - - - - - - - - [[ (not data['form']['format_perc'] or data['form']['show_columns']) and removeParentNode('blockTable') ]] [[ a['code'] ]] - - - [['.....'*(a['level']-1) ]] [[ a['name'] ]] - - - [[ a['pattern'] ]] - - - [[ a['balance'] ]] - - - [[ a['balance_perc'] ]] - - - - -
- - - - - - - [[ not data['form']['show_columns'] and removeParentNode('blockTable') ]] - - - Total : - - - [[ total_dr() ]] - - - [[ total_cr() ]] - - - - - - - - - - - - [[ data['form']['compare_pattern']!='none' and "C.S.Y.T.(C./P) : Compare Selected Years In Terms of Cash/Perc" or removeParentNode('font') ]] -
-
\ No newline at end of file diff --git a/addons/account/report/account_balance_landscape_old_backup.rml b/addons/account/report/account_balance_landscape_old_backup.rml deleted file mode 100644 index 6790082f8dd..00000000000 --- a/addons/account/report/account_balance_landscape_old_backup.rml +++ /dev/null @@ -1,182 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Account Balance - - - - - - - - - - [[ company.name ]] - - - - - - - - Currency: [[ company.currency_id.name ]] - - - - - - - Printing date: [[ time.strftime('%Y-%m-%d') ]] at [[ time.strftime('%H:%M:%S') ]] - - - -
- [[repeatIn(linesForYear(data['form']),'year_header',td=len(data['form']['fiscalyear'][0][2]),width=[126],value=['year'],type=['string']) ]] - - - - Account Information - - - -
-
- [[ repeatIn([],'title',td=len(data['form']['fiscalyear'][0][2]),width=[42,42,42],value=['Debit','Credit','Balance'],type=['lable','lable','lable']) ]] - - - - Code - - - Account Name - - - -
-
- [[ repeatIn([],'title',td=len(data['form']['fiscalyear'][0][2]),width=[84,42],value=['Cash','%'],type=['lable','lable']) ]] - - - - - - - -
- - - -
- [[ repeatIn(lines(data['form']),'a',td=len(data['form']['fiscalyear'][0][2]),width=[42,42,42],value=['debit','credit','balance'],type=['string','string','string']) ]] - - - - - - - [[ a['status']==1 and ( setTag('para','para',{'fontName':'Helvetica-bold'})) ]][[ a['code'] ]] - - - [['.....'*(a['level']-1) ]][[ a['status']==1 and ( setTag('font','font',{'name':'Helvetica-bold'})) ]][[ a['name'] ]] - - - -
- - - -
- [[ repeatIn(linesForTotal(data['form']),'total',td=len(data['form']['fiscalyear'][0][2]),width=[42,42,42],value=['sum_debit','sum_credit',''],type=['string','string','lable'] ) ]] - - - - Total:[[ data['form']['show_columns']==0 and removeParentNode('section')]] - - - -
- - - - -
-
diff --git a/addons/account/report/account_balance_old_backup.rml b/addons/account/report/account_balance_old_backup.rml deleted file mode 100644 index cf67cb6bc3d..00000000000 --- a/addons/account/report/account_balance_old_backup.rml +++ /dev/null @@ -1,179 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Account balance - - - - - - - - [[ company.name ]] - - - - - - Currency: [[ company.currency_id.name ]] - - - - - - - Printing date: [[ time.strftime('%Y-%m-%d') ]] at [[ time.strftime('%H:%M:%S') ]] - - - -
- [[repeatIn(linesForYear(data['form']),'year_header',td=len(data['form']['fiscalyear'][0][2]),width=[126],value=['year'],type=['string']) ]] - - - - Account Information - - - -
-
- [[ repeatIn([],'title',td=len(data['form']['fiscalyear'][0][2]),width=[42,42,42],value=['Debit','Credit','Balance'],type=['lable','lable','lable']) ]] - - - - Code - - - Account Name - - - -
-
- [[ repeatIn([],'title',td=len(data['form']['fiscalyear'][0][2]),width=[84,42],value=['Cash','%'],type=['lable','lable']) ]] - - - - - - - -
- - - -
- [[ repeatIn(lines(data['form']),'a',td=len(data['form']['fiscalyear'][0][2]),width=[42,42,42],value=['debit','credit','balance'],type=['string','string','string']) ]] - - - - - - - - - - [[ a['status']==1 and ( setTag('para','para',{'fontName':'Helvetica-bold'})) ]][[ a['code'] ]] - - - [['.....'*(a['level']-1) ]][[ a['status']==1 and ( setTag('font','font',{'name':'Helvetica-bold'})) ]][[ a['name'] ]] - - - -
- - - -
- [[ repeatIn(linesForTotal(data['form']),'total',td=len(data['form']['fiscalyear'][0][2]),width=[42,42,42],value=['sum_debit','sum_credit',''],type=['string','string','lable'] ) ]] - - - - Total:[[ data['form']['show_columns']==0 and removeParentNode('section')]] - - - -
- - - -
-
diff --git a/addons/account/report/account_balance_sheet.py b/addons/account/report/account_balance_sheet.py deleted file mode 100644 index ce9e3c51f06..00000000000 --- a/addons/account/report/account_balance_sheet.py +++ /dev/null @@ -1,224 +0,0 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2009 Tiny SPRL (). -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - -import time - -import pooler -from report import report_sxw -from account.report import account_profit_loss -from common_report_header import common_report_header -from tools.translate import _ - -class report_balancesheet_horizontal(report_sxw.rml_parse, common_report_header): - def __init__(self, cr, uid, name, context=None): - super(report_balancesheet_horizontal, self).__init__(cr, uid, name, context=context) - self.obj_pl = account_profit_loss.report_pl_account_horizontal(cr, uid, name, context=context) - self.result_sum_dr = 0.0 - self.result_sum_cr = 0.0 - self.result = {} - self.res_bl = {} - self.result_temp = [] - self.localcontext.update({ - 'time': time, - 'get_lines': self.get_lines, - 'get_lines_another': self.get_lines_another, - 'get_company': self._get_company, - 'get_currency': self._get_currency, - 'sum_dr': self.sum_dr, - 'sum_cr': self.sum_cr, - 'get_data':self.get_data, - 'get_pl_balance':self.get_pl_balance, - 'get_fiscalyear': self._get_fiscalyear, - 'get_account': self._get_account, - 'get_start_period': self.get_start_period, - 'get_end_period': self.get_end_period, - 'get_sortby': self._get_sortby, - 'get_filter': self._get_filter, - 'get_journal': self._get_journal, - 'get_start_date':self._get_start_date, - 'get_end_date':self._get_end_date, - 'get_company':self._get_company, - 'get_target_move': self._get_target_move, - }) - self.context = context - - def set_context(self, objects, data, ids, report_type=None): - new_ids = ids - if (data['model'] == 'ir.ui.menu'): - new_ids = 'chart_account_id' in data['form'] and [data['form']['chart_account_id']] or [] - objects = self.pool.get('account.account').browse(self.cr, self.uid, new_ids) - return super(report_balancesheet_horizontal, self).set_context(objects, data, new_ids, report_type=report_type) - - def sum_dr(self): - if self.res_bl['type'] == _('Net Profit'): - self.result_sum_dr += self.res_bl['balance']*-1 - return self.result_sum_dr - - def sum_cr(self): - if self.res_bl['type'] == _('Net Loss'): - self.result_sum_cr += self.res_bl['balance'] - return self.result_sum_cr - - def get_pl_balance(self): - return self.res_bl - - def get_data(self,data): - cr, uid = self.cr, self.uid - db_pool = pooler.get_pool(self.cr.dbname) - - #Getting Profit or Loss Balance from profit and Loss report - self.obj_pl.get_data(data) - self.res_bl = self.obj_pl.final_result() - - account_pool = db_pool.get('account.account') - currency_pool = db_pool.get('res.currency') - - types = [ - 'liability', - 'asset' - ] - - ctx = self.context.copy() - ctx['fiscalyear'] = data['form'].get('fiscalyear_id', False) - - if data['form']['filter'] == 'filter_period': - ctx['period_from'] = data['form'].get('period_from', False) - ctx['period_to'] = data['form'].get('period_to', False) - elif data['form']['filter'] == 'filter_date': - ctx['date_from'] = data['form'].get('date_from', False) - ctx['date_to'] = data['form'].get('date_to', False) - ctx['state'] = data['form'].get('target_move', 'all') - cal_list = {} - pl_dict = {} - account_dict = {} - account_id = data['form'].get('chart_account_id', False) - account_ids = account_pool._get_children_and_consol(cr, uid, account_id, context=ctx) - accounts = account_pool.browse(cr, uid, account_ids, context=ctx) - - if not self.res_bl: - self.res_bl['type'] = _('Net Profit') - self.res_bl['balance'] = 0.0 - - if self.res_bl['type'] == _('Net Profit'): - self.res_bl['type'] = _('Net Profit') - else: - self.res_bl['type'] = _('Net Loss') - pl_dict = { - 'code': self.res_bl['type'], - 'name': self.res_bl['type'], - 'level': False, - 'balance':self.res_bl['balance'], - } - for typ in types: - accounts_temp = [] - for account in accounts: - if (account.user_type.report_type) and (account.user_type.report_type == typ): - account_dict = { - 'id': account.id, - 'code': account.code, - 'name': account.name, - 'level': account.level, - 'balance': account.balance != 0 and account.balance * account.user_type.sign or account.balance, - 'type': account.type, - } - currency = account.currency_id and account.currency_id or account.company_id.currency_id - if typ == 'liability' and account.type <> 'view' and (account.debit <> account.credit): - self.result_sum_dr += account.balance - if typ == 'asset' and account.type <> 'view' and (account.debit <> account.credit): - self.result_sum_cr += account.balance - if data['form']['display_account'] == 'movement': - if not currency_pool.is_zero(self.cr, self.uid, currency, account.credit) or not currency_pool.is_zero(self.cr, self.uid, currency, account.debit) or not currency_pool.is_zero(self.cr, self.uid, currency, account.balance): - accounts_temp.append(account_dict) - elif data['form']['display_account'] == 'not_zero': - if not currency_pool.is_zero(self.cr, self.uid, currency, account.balance): - accounts_temp.append(account_dict) - else: - accounts_temp.append(account_dict) - if account.id == data['form']['reserve_account_id']: - pl_dict['level'] = account['level'] + 1 - accounts_temp.append(pl_dict) - - self.result[typ] = accounts_temp - cal_list[typ]=self.result[typ] - - if cal_list: - temp = {} - for i in range(0,max(len(cal_list['liability']),len(cal_list['asset']))): - if i < len(cal_list['liability']) and i < len(cal_list['asset']): - temp={ - 'type': cal_list['liability'][i]['type'], - 'code': cal_list['liability'][i]['code'], - 'name': cal_list['liability'][i]['name'], - 'level': cal_list['liability'][i]['level'], - 'balance':cal_list['liability'][i]['balance'], - 'type1': cal_list['asset'][i]['type'], - 'code1': cal_list['asset'][i]['code'], - 'name1': cal_list['asset'][i]['name'], - 'level1': cal_list['asset'][i]['level'], - 'balance1':cal_list['asset'][i]['balance'], - } - self.result_temp.append(temp) - else: - if i < len(cal_list['asset']): - temp={ - 'type': '', - 'code': '', - 'name': '', - 'level': False, - 'balance':False, - 'type1': cal_list['asset'][i]['type'], - 'code1': cal_list['asset'][i]['code'], - 'name1': cal_list['asset'][i]['name'], - 'level1': cal_list['asset'][i]['level'], - 'balance1':cal_list['asset'][i]['balance'], - } - self.result_temp.append(temp) - if i < len(cal_list['liability']): - temp={ - 'type': cal_list['liability'][i]['type'], - 'code': cal_list['liability'][i]['code'], - 'name': cal_list['liability'][i]['name'], - 'level': cal_list['liability'][i]['level'], - 'balance':cal_list['liability'][i]['balance'], - 'type1': '', - 'code1': '', - 'name1': '', - 'level1': False, - 'balance1':False, - } - self.result_temp.append(temp) - return None - - def get_lines(self): - return self.result_temp - - def get_lines_another(self, group): - return self.result.get(group, []) - -report_sxw.report_sxw('report.account.balancesheet.horizontal', 'account.account', - 'addons/account/report/account_balance_sheet_horizontal.rml',parser=report_balancesheet_horizontal, - header='internal landscape') - -report_sxw.report_sxw('report.account.balancesheet', 'account.account', - 'addons/account/report/account_balance_sheet.rml',parser=report_balancesheet_horizontal, - header='internal') - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/report/account_balance_sheet.rml b/addons/account/report/account_balance_sheet.rml deleted file mode 100644 index 620ec05b16a..00000000000 --- a/addons/account/report/account_balance_sheet.rml +++ /dev/null @@ -1,303 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Balance Sheet - - - - [[ get_data(data) or removeParentNode('para') ]] - - - - - - Chart of Accounts - Fiscal Year - Filter By [[ data['form']['filter']!='filter_no' and get_filter(data) ]] - Display Account - Target Moves - - - [[ get_account(data) or removeParentNode('para') ]] - [[ get_fiscalyear(data) or '' ]] - [[ data['form']['filter']=='filter_no' and get_filter(data) or removeParentNode('para') ]] - [[ data['form']['filter']=='filter_date' or removeParentNode('blockTable') ]] - - Start Date - End Date - - - [[ formatLang(get_start_date(data),date=True) ]] - [[ formatLang(get_end_date(data),date=True) ]] - - - [[ data['form']['filter']=='filter_period' or removeParentNode('blockTable') ]] - - Start Period - End Period - - - [[ get_start_period(data) or removeParentNode('para') ]] - [[ get_end_period(data) or removeParentNode('para') ]] - - - - [[ (data['form']['display_account']=='all' and 'All') or (data['form']['display_account']=='movement' and 'With movements') or 'With balance is not equal to 0']] - [[ get_target_move(data) ]] - - - - - - - - - - - - Assets - - - - - - - - - - Code - - - Account - - - Balance - - - - [[ repeatIn(get_lines_another('asset'),'a' ) ]] - [[ setTag('tr','tr',{'style': 'Table'+str(min(3,a['level']))}) ]] - [[ (a['type'] =='view' and a['level'] >= 3) and setTag('para','para',{'style': 'terp_level_3_code_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(3,a['level']))+'_code'}) ]][[ a['code'] ]] - [[ (a['type'] =='view' and a['level'] >= 3) and setTag('para','para',{'style': 'terp_level_'+str(min(3,a['level']))+'_name_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(4,a['level']))+'_name'}) ]][[ a['name'] ]] - [[ (a['level'] <>2) or removeParentNode('td') ]][[ (a['type'] =='view' and a['level'] >= 3) and setTag('para','para',{'style': 'terp_level_3_balance_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(3,a['level']))+'_balance'}) ]][[ formatLang(a['balance'], currency_obj = company.currency_id) ]] - [[ a['level'] == 2 or removeParentNode('td') ]][[ formatLang(a['balance'], currency_obj = company.currency_id) ]] - - - - - - Balance: - - - [[ formatLang(sum_cr(), currency_obj = company.currency_id) ]] - - - - - - - - - - - Liabilities - - - - - - - Code - - - Account - - - Balance - - - - [[ repeatIn(get_lines_another('liability'),'a' ) ]] - [[ setTag('tr','tr',{'style': 'Table'+str(min(3,a['level']))}) ]] - [[ (a['type'] =='view' and a['level'] >= 3) and setTag('para','para',{'style': 'terp_level_3_code_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(3,a['level']))+'_code'}) ]][[ a['code'] ]] - [[ (a['type'] =='view' and a['level'] >= 3) and setTag('para','para',{'style': 'terp_level_'+str(min(3,a['level']))+'_name_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(4,a['level']))+'_name'}) ]][[ a['name'] ]] - [[ (a['level'] <>2) or removeParentNode('td') ]][[ (a['type'] =='view' and a['level'] >= 3) and setTag('para','para',{'style': 'terp_level_3_balance_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(3,a['level']))+'_balance'}) ]][[ formatLang(a['balance'], currency_obj = company.currency_id) ]] - [[ a['level'] == 2 or removeParentNode('td') ]][[ formatLang(a['balance'], currency_obj = company.currency_id) ]] - - - - - - Balance: - - - [[ formatLang(sum_dr(), currency_obj = company.currency_id) ]] - - - - - - - - diff --git a/addons/account/report/account_balance_sheet_horizontal.rml b/addons/account/report/account_balance_sheet_horizontal.rml deleted file mode 100644 index b2d54e33466..00000000000 --- a/addons/account/report/account_balance_sheet_horizontal.rml +++ /dev/null @@ -1,250 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Balance Sheet - - - - [[ get_data(data) or removeParentNode('para') ]] - - - - Chart of Accounts - Fiscal Year - Filter By [[ data['form']['filter']!='filter_no' and get_filter(data) ]] - Display Account - Target Moves - - - [[ get_account(data) or removeParentNode('para') ]] - [[ get_fiscalyear(data) or '' ]] - [[ data['form']['filter']=='filter_no' and get_filter(data) or removeParentNode('para') ]] - [[ data['form']['filter']=='filter_date' or removeParentNode('blockTable') ]] - - Start Date - End Date - - - [[ formatLang(get_start_date(data),date=True) ]] - [[ formatLang(get_end_date(data),date=True) ]] - - - [[ data['form']['filter']=='filter_period' or removeParentNode('blockTable') ]] - - Start Period - End Period - - - [[ get_start_period(data) or removeParentNode('para') ]] - [[ get_end_period(data) or removeParentNode('para') ]] - - - - [[ (data['form']['display_account']=='all' and 'All') or (data['form']['display_account']=='movement' and 'With movements') or 'With balance is not equal to 0']] - [[ get_target_move(data) ]] - - - - - - - - - - - - Code - - - Assets - - - Balance - - - Code - - - Liabilities - - - Balance - - - - - - [[ repeatIn(get_lines(),'a' ) ]] [[ a['code1'] ]][[ a['level1']<4 and ( setTag('para','para',{'style':'terp_default_Bold_9'})) or removeParentNode('font') ]] - - - - - [[ '. '*(a['level1']-1) ]][[ a['level1']<4 and ( setTag('para','para',{'style':'terp_default_Bold_9'})) or removeParentNode('font') ]][[ a['name1'] ]] - - - - - [[ a['level1']<4 and ( setTag('para','para',{'style':'terp_default_Right_9_Bold'})) or removeParentNode('font') ]][[ formatLang(a['balance1'], currency_obj=company.currency_id) ]] - - - - - [[ a['code'] ]][[ ( a['level']<4 or a['name']=='Net Profit') and ( setTag('para','para',{'style':'terp_default_Bold_9'})) or removeParentNode('font') ]] - - - - - [[ '. '*(a['level']-1) ]] - [[ ( a['level']<4 or a['name']=='Net Profit') and ( setTag('para','para',{'style':'terp_default_Bold_9'})) or removeParentNode('font') ]][[ a['name'] ]] - - - - - [[ ( a['level']<4 or a['name']=='Net Profit') and ( setTag('para','para',{'style':'terp_default_Right_9_Bold'})) or removeParentNode('font') ]] - [[(a['code'] and a['name']) and formatLang(a['balance'], currency_obj=company.currency_id) or removeParentNode('font')]] - - - - - - - - Balance: - - - [[ formatLang(sum_cr(), currency_obj=company.currency_id) ]] - - - Balance: - - - [[ formatLang(sum_dr(), currency_obj=company.currency_id) ]] - - - - - - diff --git a/addons/account/report/account_financial_report.py b/addons/account/report/account_financial_report.py index e9da0a1cd7b..c3b1f5e2e1a 100644 --- a/addons/account/report/account_financial_report.py +++ b/addons/account/report/account_financial_report.py @@ -64,29 +64,30 @@ class report_account_common(report_sxw.rml_parse, common_report_header): vals['balance_cmp'] = self.pool.get('account.financial.report').browse(self.cr, self.uid, report.id, context=data['form']['comparison_context']).balance lines.append(vals) account_ids = [] - if report.type == 'accounts' and report.display_detail and report.account_ids: + if report.type == 'accounts' and report.account_ids: account_ids = account_obj._get_children_and_consol(self.cr, self.uid, [x.id for x in report.account_ids]) elif report.type == 'account_type' and report.account_type_ids: account_ids = account_obj.search(self.cr, self.uid, [('user_type','in', [x.id for x in report.account_type_ids])]) if account_ids: for account in account_obj.browse(self.cr, self.uid, account_ids, context=data['form']['used_context']): - if account.type != 'view': - flag = False - vals = { - 'name': account.code + ' ' + account.name, - 'balance': account.balance != 0 and account.balance * account.user_type.sign or account.balance, - 'type': 'account', - 'level': 6, - 'account_type': account.type, - } - if not currency_obj.is_zero(self.cr, self.uid, account.company_id.currency_id, vals['balance']): + if report.display_detail == 'detail_flat' and account.type == 'view': + continue + flag = False + vals = { + 'name': account.code + ' ' + account.name, + 'balance': account.balance != 0 and account.balance * report.sign or account.balance, + 'type': 'account', + 'level': report.display_detail == 'detail_with_hierarchy' and min(account.level,6) or 6, + 'account_type': account.type, + } + if not currency_obj.is_zero(self.cr, self.uid, account.company_id.currency_id, vals['balance']): + flag = True + if data['form']['enable_filter']: + vals['balance_cmp'] = account_obj.browse(self.cr, self.uid, account.id, context=data['form']['comparison_context']).balance + if not currency_obj.is_zero(self.cr, self.uid, account.company_id.currency_id, vals['balance_cmp']): flag = True - if data['form']['enable_filter']: - vals['balance_cmp'] = account_obj.browse(self.cr, self.uid, account.id, context=data['form']['comparison_context']).balance - if not currency_obj.is_zero(self.cr, self.uid, account.company_id.currency_id, vals['balance_cmp']): - flag = True - if flag: - lines.append(vals) + if flag: + lines.append(vals) return lines report_sxw.report_sxw('report.account.financial.report', 'account.financial.report', diff --git a/addons/account/report/account_financial_report.rml b/addons/account/report/account_financial_report.rml index 6a94f02c719..e3b5f3663f9 100644 --- a/addons/account/report/account_financial_report.rml +++ b/addons/account/report/account_financial_report.rml @@ -130,15 +130,13 @@ - - - + + + + + - - - - - + @@ -229,13 +227,13 @@ Balance - + [[ repeatIn(get_lines(data), 'a') ]] [[ (a.get('level') <> 0) or removeParentNode('tr') ]] [[ setTag('tr','tr',{'style': 'Table'+str(min(3,'level' in a and a.get('level') or 1))}) ]] - [[ setTag('para','para',{'style': 'terp_level_'+str(min(6,a['level']))+'_name'}) ]] [[ a.get('name') ]] - [[ a.get('level') == 4 or removeParentNode('td') ]][[ setTag('para','para',{'style': 'terp_level_'+str(min(6,a['level']))+'_balance'}) ]][[ formatLang(a.get('balance'))]] [[company.currency_id.symbol]] - [[ a.get('level') <> 4 or removeParentNode('td') ]][[ setTag('para','para',{'style': 'terp_level_'+str(min(6,a['level']))+'_balance'}) ]][[ formatLang(a.get('balance'))]] [[company.currency_id.symbol]] + [[ (a.get('account_type') =='view' and a.get('level') >= 3) and setTag('para','para',{'style': 'terp_level_'+str(min(3,a.get('level')))+'_name_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(4,a.get('level')))+'_name'}) ]][[ a.get('name') ]] + [[ (a.get('level') <>2) or removeParentNode('td') ]][[ (a.get('account_type') =='view' and a.get('level') >= 3) and setTag('para','para',{'style': 'terp_level_3_balance_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(3,a.get('level')))+'_balance'}) ]][[ formatLang(a.get('balance'), currency_obj = company.currency_id) ]] + [[ a.get('level') == 2 or removeParentNode('td') ]][[ formatLang(a.get('balance'), currency_obj = company.currency_id) ]] @@ -258,11 +256,11 @@ [[ repeatIn(get_lines(data), 'a') ]] [[ (a.get('level') <> 0) or removeParentNode('tr') ]] [[ setTag('tr','tr',{'style': 'Table'+str(min(3,'level' in a and a.get('level') or 1))}) ]] - [[ setTag('para','para',{'style': 'terp_level_'+str(min(6,a['level']))+'_name'}) ]] [[ a.get('name') ]] - [[ a.get('level') == 4 or removeParentNode('td') ]][[ setTag('para','para',{'style': 'terp_level_'+str(min(6,a['level']))+'_balance'}) ]][[ formatLang(a.get('balance'))]] [[company.currency_id.symbol]] - [[ a.get('level') <> 4 or removeParentNode('td') ]][[ setTag('para','para',{'style': 'terp_level_'+str(min(6,a['level']))+'_balance'}) ]][[ formatLang(a.get('balance'))]] [[company.currency_id.symbol]] - [[ a.get('level') == 4 or removeParentNode('td') ]][[ setTag('para','para',{'style': 'terp_level_'+str(min(6,a['level']))+'_balance'}) ]][[ formatLang(a.get('balance_cmp'))]] [[company.currency_id.symbol]] - [[ a.get('level') <> 4 or removeParentNode('td') ]][[ setTag('para','para',{'style': 'terp_level_'+str(min(6,a['level']))+'_balance'}) ]][[ formatLang(a.get('balance_cmp'))]] [[company.currency_id.symbol]] + [[ (a.get('account_type') =='view' and a.get('level') >= 3) and setTag('para','para',{'style': 'terp_level_'+str(min(3,a.get('level')))+'_name_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(4,a.get('level')))+'_name'}) ]][[ a.get('name') ]] + [[ (a.get('level') <>2) or removeParentNode('td') ]][[ (a.get('account_type') =='view' and a.get('level') >= 3) and setTag('para','para',{'style': 'terp_level_3_balance_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(3,a.get('level')))+'_balance'}) ]][[ formatLang(a.get('balance'), currency_obj = company.currency_id) ]] + [[ a.get('level') == 2 or removeParentNode('td') ]][[ formatLang(a.get('balance'), currency_obj = company.currency_id) ]] + [[ (a.get('level') <>2) or removeParentNode('td') ]][[ (a.get('account_type') =='view' and a.get('level') >= 3) and setTag('para','para',{'style': 'terp_level_3_balance_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(3,a.get('level')))+'_balance'}) ]][[ formatLang(a.get('balance_cmp'), currency_obj = company.currency_id) ]] + [[ a.get('level') == 2 or removeParentNode('td') ]][[ formatLang(a.get('balance_cmp'), currency_obj = company.currency_id) ]] diff --git a/addons/account/report/account_profit_horizontal.rml b/addons/account/report/account_profit_horizontal.rml deleted file mode 100644 index 0918dcb2699..00000000000 --- a/addons/account/report/account_profit_horizontal.rml +++ /dev/null @@ -1,282 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Profit And Loss - - - - - - - [[ get_data(data) or removeParentNode('para')]] - - - Chart of Accounts - Fiscal Year - Filter By [[ data['form']['filter']!='filter_no' and get_filter(data) ]] - Display Account - Target Moves - - - [[ get_account(data) or removeParentNode('para') ]] - [[ get_fiscalyear(data) or '' ]] - [[ data['form']['filter']=='filter_no' and get_filter(data) or removeParentNode('para') ]] - [[ data['form']['filter']=='filter_date' or removeParentNode('blockTable') ]] - - Start Date - End Date - - - [[ formatLang(get_start_date(data),date=True) ]] - [[ formatLang(get_end_date(data),date=True) ]] - - - [[ data['form']['filter']=='filter_period' or removeParentNode('blockTable') ]] - - Start Period - End Period - - - [[ get_start_period(data) or removeParentNode('para') ]] - [[ get_end_period(data) or removeParentNode('para') ]] - - - - [[ (data['form']['display_account']=='all' and 'All') or (data['form']['display_account']=='movement' and 'With movements') or 'With balance is not equal to 0']] - [[ get_target_move(data) ]] - - - - - - - - - Code - - - Expenses - - - Balance - - - Code - - - Income - - - Balance - - - - - - - [[ repeatIn(get_lines(),'a' ) ]] [[ a['code'] ]][[ a['level']<4 and ( setTag('para','para',{'style':'terp_default_Bold_9'})) or removeParentNode('font') ]] - - - - - [[ '. '*(a['level']-1) ]][[ a['level']<4 and ( setTag('para','para',{'style':'terp_default_Bold_9'})) or removeParentNode('font') ]][[ a['name'] ]] - - - - [[ a['level']<4 and ( setTag('para','para',{'style':'terp_default_Right_9_Bold'})) or removeParentNode('font') ]][[ formatLang(abs(a['balance']), currency_obj=company.currency_id) ]] - - - - [[ a['code1'] ]][[ a['level1']<4 and ( setTag('para','para',{'style':'terp_default_Bold_9'})) or removeParentNode('font') ]] - - - - - [[ '. '*(a['level1']-1) ]][[ a['level1']<4 and ( setTag('para','para',{'style':'terp_default_Bold_9'})) or removeParentNode('font') ]][[ a['name1'] ]] - - - - [[ a['level']<4 and ( setTag('para','para',{'style':'terp_default_Right_9_Bold'})) or removeParentNode('font') ]][[(a['code1'] and a['name1']) and formatLang(abs(a['balance1']), currency_obj=company.currency_id) or removeParentNode('font') ]] - - - - - - - - - - [[ final_result()['type'] == 'Net Profit' and final_result()['type'] or '' ]] - - - [[ final_result()['balance'] and final_result()['type'] == 'Net Profit' and formatLang(abs(final_result()['balance']), currency_obj=company.currency_id) ]] - - - - - - [[ final_result()['type'] == 'Net Loss' and final_result()['type'] or '' ]] - - - [[ final_result()['balance'] and final_result()['type'] == 'Net Loss' and formatLang(abs(final_result()['balance']), currency_obj=company.currency_id) ]] - - - - - - - - Total: - - - [[ formatLang(abs(sum_dr()), currency_obj=company.currency_id) ]] - - - Total: - - - [[ formatLang(abs(sum_cr()), currency_obj=company.currency_id) ]] - - - - - - diff --git a/addons/account/report/account_profit_loss.py b/addons/account/report/account_profit_loss.py deleted file mode 100644 index 27182cdbd21..00000000000 --- a/addons/account/report/account_profit_loss.py +++ /dev/null @@ -1,198 +0,0 @@ -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2009 Tiny SPRL (). -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - -import time -import pooler -from report import report_sxw -from common_report_header import common_report_header -from tools.translate import _ - -class report_pl_account_horizontal(report_sxw.rml_parse, common_report_header): - - def __init__(self, cr, uid, name, context=None): - super(report_pl_account_horizontal, self).__init__(cr, uid, name, context=context) - self.result_sum_dr = 0.0 - self.result_sum_cr = 0.0 - self.res_pl = {} - self.result = {} - self.result_temp = [] - self.localcontext.update( { - 'time': time, - 'get_lines': self.get_lines, - 'get_lines_another': self.get_lines_another, - 'get_currency': self._get_currency, - 'get_data': self.get_data, - 'sum_dr': self.sum_dr, - 'sum_cr': self.sum_cr, - 'final_result': self.final_result, - 'get_fiscalyear': self._get_fiscalyear, - 'get_account': self._get_account, - 'get_start_period': self.get_start_period, - 'get_end_period': self.get_end_period, - 'get_sortby': self._get_sortby, - 'get_filter': self._get_filter, - 'get_journal': self._get_journal, - 'get_start_date':self._get_start_date, - 'get_end_date':self._get_end_date, - 'get_company':self._get_company, - 'get_target_move': self._get_target_move, - }) - self.context = context - - def set_context(self, objects, data, ids, report_type=None): - new_ids = ids - if (data['model'] == 'ir.ui.menu'): - new_ids = 'chart_account_id' in data['form'] and [data['form']['chart_account_id']] or [] - objects = self.pool.get('account.account').browse(self.cr, self.uid, new_ids) - return super(report_pl_account_horizontal, self).set_context(objects, data, new_ids, report_type=report_type) - - - def final_result(self): - return self.res_pl - - def sum_dr(self): - if self.res_pl['type'] == _('Net Profit'): - self.result_sum_dr += self.res_pl['balance'] - return self.result_sum_dr - - def sum_cr(self): - if self.res_pl['type'] == _('Net Loss'): - self.result_sum_cr += self.res_pl['balance'] - return self.result_sum_cr - - def get_data(self, data): - cr, uid = self.cr, self.uid - db_pool = pooler.get_pool(self.cr.dbname) - - account_pool = db_pool.get('account.account') - currency_pool = db_pool.get('res.currency') - - types = [ - 'expense', - 'income' - ] - - ctx = self.context.copy() - ctx['fiscalyear'] = data['form'].get('fiscalyear_id', False) - - if data['form']['filter'] == 'filter_period': - ctx['period_from'] = data['form'].get('period_from', False) - ctx['period_to'] = data['form'].get('period_to', False) - elif data['form']['filter'] == 'filter_date': - ctx['date_from'] = data['form'].get('date_from', False) - ctx['date_to'] = data['form'].get('date_to', False) - - cal_list = {} - account_id = data['form'].get('chart_account_id', False) - company_currency = account_pool.browse(self.cr, self.uid, account_id).company_id.currency_id - account_ids = account_pool._get_children_and_consol(cr, uid, account_id, context=ctx) - accounts = account_pool.browse(cr, uid, account_ids, context=ctx) - - for typ in types: - accounts_temp = [] - for account in accounts: - if (account.user_type.report_type) and (account.user_type.report_type == typ): - currency = account.currency_id and account.currency_id or account.company_id.currency_id - if typ == 'expense' and account.type <> 'view' and (account.debit <> account.credit): - self.result_sum_dr += account.debit - account.credit - if typ == 'income' and account.type <> 'view' and (account.debit <> account.credit): - self.result_sum_cr += account.credit - account.debit - if data['form']['display_account'] == 'movement': - if not currency_pool.is_zero(self.cr, self.uid, currency, account.credit) or not currency_pool.is_zero(self.cr, self.uid, currency, account.debit) or not currency_pool.is_zero(self.cr, self.uid, currency, account.balance): - accounts_temp.append(account) - elif data['form']['display_account'] == 'not_zero': - if not currency_pool.is_zero(self.cr, self.uid, currency, account.balance): - accounts_temp.append(account) - else: - accounts_temp.append(account) - if currency_pool.is_zero(self.cr, self.uid, company_currency, (self.result_sum_dr-self.result_sum_cr)): - self.res_pl['type'] = None - self.res_pl['balance'] = 0.0 - elif self.result_sum_dr > self.result_sum_cr: - self.res_pl['type'] = _('Net Loss') - self.res_pl['balance'] = (self.result_sum_dr - self.result_sum_cr) - else: - self.res_pl['type'] = _('Net Profit') - self.res_pl['balance'] = (self.result_sum_cr - self.result_sum_dr) - self.result[typ] = accounts_temp - cal_list[typ] = self.result[typ] - if cal_list: - temp = {} - for i in range(0,max(len(cal_list['expense']),len(cal_list['income']))): - if i < len(cal_list['expense']) and i < len(cal_list['income']): - temp={ - 'code': cal_list['expense'][i].code, - 'name': cal_list['expense'][i].name, - 'level': cal_list['expense'][i].level, - 'balance': cal_list['expense'][i].balance != 0 and \ - cal_list['expense'][i].balance * cal_list['expense'][i].user_type.sign or \ - cal_list['expense'][i].balance, - 'code1': cal_list['income'][i].code, - 'name1': cal_list['income'][i].name, - 'level1': cal_list['income'][i].level, - 'balance1': cal_list['income'][i].balance != 0 and \ - cal_list['income'][i].balance * cal_list['income'][i].user_type.sign or \ - cal_list['income'][i].balance, - } - self.result_temp.append(temp) - else: - if i < len(cal_list['income']): - temp={ - 'code': '', - 'name': '', - 'level': False, - 'balance':False, - 'code1': cal_list['income'][i].code, - 'name1': cal_list['income'][i].name, - 'level1': cal_list['income'][i].level, - 'balance1': cal_list['income'][i].balance != 0 and \ - cal_list['income'][i].balance * cal_list['income'][i].user_type.sign \ - or cal_list['income'][i].balance, - } - self.result_temp.append(temp) - if i < len(cal_list['expense']): - temp={ - 'code': cal_list['expense'][i].code, - 'name': cal_list['expense'][i].name, - 'level': cal_list['expense'][i].level, - 'balance': cal_list['expense'][i].balance != 0 and \ - cal_list['expense'][i].balance * cal_list['expense'][i].user_type.sign \ - or cal_list['expense'][i].balance, - 'code1': '', - 'name1': '', - 'level1': False, - 'balance1':False, - } - self.result_temp.append(temp) - return None - - def get_lines(self): - return self.result_temp - - def get_lines_another(self, group): - return self.result.get(group, []) - -report_sxw.report_sxw('report.pl.account.horizontal', 'account.account', - 'addons/account/report/account_profit_horizontal.rml',parser=report_pl_account_horizontal, header='internal landscape') - -report_sxw.report_sxw('report.pl.account', 'account.account', - 'addons/account/report/account_profit_loss.rml',parser=report_pl_account_horizontal, header='internal') - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/report/account_profit_loss.rml b/addons/account/report/account_profit_loss.rml deleted file mode 100644 index 28fe167aef5..00000000000 --- a/addons/account/report/account_profit_loss.rml +++ /dev/null @@ -1,314 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Profit And Loss - - - - - [[ get_data(data) or removeParentNode('para')]] - - - - - - Chart of Accounts - Fiscal Year - Filter By [[ data['form']['filter']!='filter_no' and get_filter(data) ]] - Display Account - Target Moves - - - [[ get_account(data) or removeParentNode('para') ]] - [[ get_fiscalyear(data) or '' ]] - [[ data['form']['filter']=='filter_no' and get_filter(data) or removeParentNode('para') ]] - [[ data['form']['filter']=='filter_date' or removeParentNode('blockTable') ]] - - Start Date - End Date - - - [[ formatLang(get_start_date(data),date=True) ]] - [[ formatLang(get_end_date(data),date=True) ]] - - - [[ data['form']['filter']=='filter_period' or removeParentNode('blockTable') ]] - - Start Period - End Period - - - [[ get_start_period(data) or removeParentNode('para') ]] - [[ get_end_period(data) or removeParentNode('para') ]] - - - - [[ (data['form']['display_account']=='all' and 'All') or (data['form']['display_account']=='movement' and 'With movements') or 'With balance is not equal to 0']] - [[ get_target_move(data) ]] - - - - - - Expenses - - - - Code - - - Account - - - Balance - - - - [[ repeatIn(get_lines_another('expense'),'a' ) ]] - [[ setTag('tr','tr',{'style': 'Table'+str(min(3,a.level))}) ]] - [[ (a.type =='view' and a.level >= 3) and setTag('para','para',{'style': 'terp_level_3_code_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(3,a.level))+'_code'}) ]][[ a.code ]] - [[ (a.type =='view' and a.level >= 3) and setTag('para','para',{'style': 'terp_level_'+str(min(3,a.level))+'_name_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(4,a.level))+'_name'}) ]][[ a.name ]] - [[ (a.level <>2) or removeParentNode('td') ]][[ (a.type =='view' and a.level >= 3) and setTag('para','para',{'style': 'terp_level_3_balance_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(3,a.level))+'_balance'}) ]][[ formatLang(a.balance * a.user_type.sign, currency_obj=company.currency_id) ]] - [[ a.level == 2 or removeParentNode('td') ]][[ formatLang(a.balance * a.user_type.sign, currency_obj=company.currency_id) ]] - - - - - - - - - [[ final_result()['type'] == 'Net Profit' and final_result()['type'] or removeParentNode('blockTable') ]] - - - [[ final_result()['balance'] and final_result()['type'] == 'Net Profit' and formatLang(final_result()['balance'], currency_obj=company.currency_id) ]] - - - - - - - Total: - - - [[ formatLang(sum_dr(), currency_obj=company.currency_id) ]] - - - - - - - - Incomes - - - - Code - - - Account - - - Balance - - - - [[ repeatIn(get_lines_another('income'),'a' ) ]] - [[ setTag('tr','tr',{'style': 'Table'+str(min(3,a.level))}) ]] - [[ (a.type =='view' and a.level >= 3) and setTag('para','para',{'style': 'terp_level_3_code_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(3,a.level))+'_code'}) ]][[ a.code ]] - [[ (a.type =='view' and a.level >= 3) and setTag('para','para',{'style': 'terp_level_'+str(min(3,a.level))+'_name_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(4,a.level))+'_name'}) ]][[ a.name ]] - [[ (a.level <>2) or removeParentNode('td') ]][[ (a.type =='view' and a.level >= 3) and setTag('para','para',{'style': 'terp_level_3_balance_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(3,a.level))+'_balance'}) ]][[ formatLang(a.balance * a.user_type.sign, currency_obj=company.currency_id) ]] - [[ a.level == 2 or removeParentNode('td') ]][[ formatLang(a.balance * a.user_type.sign, currency_obj=company.currency_id) ]] - - - - - - - - - [[ final_result()['type'] == 'Net Loss' and final_result()['type'] or removeParentNode('blockTable') ]] - - - [[ final_result()['balance'] and final_result()['type'] == 'Net Loss' and formatLang(final_result()['balance'], currency_obj=company.currency_id) ]] - - - - - - - Total: - - - [[ formatLang(sum_cr(), currency_obj=company.currency_id) ]] - - - - - - - - - - - diff --git a/addons/account/test/account_report.yml b/addons/account/test/account_report.yml index 40ba7ea7127..c2797f274e7 100644 --- a/addons/account/test/account_report.yml +++ b/addons/account/test/account_report.yml @@ -37,24 +37,15 @@ data_dict = {'chart_account_id':ref('account.chart0')} from tools import test_reports test_reports.try_report_action(cr, uid, 'action_account_aged_balance_view',wiz_data=data_dict, context=ctx, our_module='account') -- - Print the Account Balance Sheet in Horizontal mode -- - !python {model: account.account}: | - ctx={} - ctx.update({'model': 'account.account','active_ids':[ref('account.chart0')]}) - data_dict = {'chart_account_id':ref('account.chart0'),'display_type': True} - from tools import test_reports - test_reports.try_report_action(cr, uid, 'action_account_bs_report',wiz_data=data_dict, context=ctx, our_module='account') - Print the Account Balance Sheet in Normal mode - !python {model: account.account}: | ctx={} ctx.update({'model': 'account.account','active_ids':[ref('account.chart0')]}) - data_dict = {'chart_account_id':ref('account.chart0'),'display_type': False} + data_dict = {'chart_account_id':ref('account.chart0'),'display_type': False, 'account_report_id': ref('account_financial_report_balancesheet0')} from tools import test_reports - test_reports.try_report_action(cr, uid, 'action_account_bs_report',wiz_data=data_dict, context=ctx, our_module='account') + test_reports.try_report_action(cr, uid, 'action_account_report',wiz_data=data_dict, context=ctx, our_module='account') - Print the Account Balance Report in Normal mode through the wizard - From Account Chart - @@ -147,18 +138,9 @@ !python {model: account.account}: | ctx={} ctx.update({'model': 'account.account','active_ids':[ref('account.chart0')]}) - data_dict = {'chart_account_id':ref('account.chart0'),'display_type': False,'target_move': 'all'} + data_dict = {'chart_account_id':ref('account.chart0'),'display_type': False,'target_move': 'all', 'account_report_id': ref('account_financial_report_balancesheet0')} from tools import test_reports - test_reports.try_report_action(cr, uid, 'action_account_pl_report',wiz_data=data_dict, context=ctx, our_module='account') -- - Print the Profit-Loss Report in Horizontal Mode -- - !python {model: account.account}: | - ctx={} - ctx.update({'model': 'account.account','active_ids':[ref('account.chart0')]}) - data_dict = {'chart_account_id':ref('account.chart0'),'display_type': True,'target_move': 'all'} - from tools import test_reports - test_reports.try_report_action(cr, uid, 'action_account_pl_report',wiz_data=data_dict, context=ctx, our_module='account') + test_reports.try_report_action(cr, uid, 'action_account_report',wiz_data=data_dict, context=ctx, our_module='account') - Print the Analytic Balance Report through the wizard - diff --git a/addons/account/wizard/__init__.py b/addons/account/wizard/__init__.py index d82eff62142..a78cf12050b 100644 --- a/addons/account/wizard/__init__.py +++ b/addons/account/wizard/__init__.py @@ -64,8 +64,6 @@ import account_report_account_balance import account_change_currency -import account_report_balance_sheet -import account_report_profit_loss # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/account_change_currency.py b/addons/account/wizard/account_change_currency.py index eb4319a56b6..fc460eceb11 100644 --- a/addons/account/wizard/account_change_currency.py +++ b/addons/account/wizard/account_change_currency.py @@ -56,18 +56,18 @@ class account_change_currency(osv.osv_memory): if invoice.company_id.currency_id.id == invoice.currency_id.id: new_price = line.price_unit * rate if new_price <= 0: - raise osv.except_osv(_('Error'), _('New currency is not confirured properly !')) + raise osv.except_osv(_('Error'), _('New currency is not configured properly !')) if invoice.company_id.currency_id.id != invoice.currency_id.id and invoice.company_id.currency_id.id == new_currency: old_rate = invoice.currency_id.rate if old_rate <= 0: - raise osv.except_osv(_('Error'), _('Currnt currency is not confirured properly !')) + raise osv.except_osv(_('Error'), _('Current currency is not configured properly !')) new_price = line.price_unit / old_rate if invoice.company_id.currency_id.id != invoice.currency_id.id and invoice.company_id.currency_id.id != new_currency: old_rate = invoice.currency_id.rate if old_rate <= 0: - raise osv.except_osv(_('Error'), _('Current currency is not confirured properly !')) + raise osv.except_osv(_('Error'), _('Current currency is not configured properly !')) new_price = (line.price_unit / old_rate ) * rate obj_inv_line.write(cr, uid, [line.id], {'price_unit': new_price}) obj_inv.write(cr, uid, [invoice.id], {'currency_id': new_currency}, context=context) diff --git a/addons/account/wizard/account_financial_report.py b/addons/account/wizard/account_financial_report.py index de9cae3a00c..92c623a9524 100644 --- a/addons/account/wizard/account_financial_report.py +++ b/addons/account/wizard/account_financial_report.py @@ -38,9 +38,19 @@ class accounting_report(osv.osv_memory): 'date_to_cmp': fields.date("End Date"), } + def _get_account_report(self, cr, uid, context=None): + menu_obj = self.pool.get('ir.ui.menu') + report_obj = self.pool.get('account.financial.report') + report_ids = [] + if context.get('active_id'): + menu = menu_obj.browse(cr, uid, context.get('active_id')).name + report_ids = report_obj.search(cr, uid, [('name','ilike',menu)]) + return report_ids and report_ids[0] or False + _defaults = { 'filter_cmp': 'filter_no', 'target_move': 'posted', + 'account_report_id': _get_account_report, } def _build_comparison_context(self, cr, uid, ids, data, context=None): diff --git a/addons/account/wizard/account_financial_report_view.xml b/addons/account/wizard/account_financial_report_view.xml index 1472da4ba87..4be6fb5e95c 100644 --- a/addons/account/wizard/account_financial_report_view.xml +++ b/addons/account/wizard/account_financial_report_view.xml @@ -40,6 +40,24 @@ new + + + + + + ). -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - -from osv import osv, fields -from tools.translate import _ - -class account_bs_report(osv.osv_memory): - """ - This wizard will provide the account balance sheet report by periods, between any two dates. - """ - _name = 'account.bs.report' - _inherit = "account.common.account.report" - _description = 'Account Balance Sheet Report' - - def _get_def_reserve_account(self, cr, uid, context=None): - chart_id = self._get_account(cr, uid, context=context) - res = self.onchange_chart_id(cr, uid, [], chart_id, context=context) - if not res: - return False - return res['value']['reserve_account_id'] - - _columns = { - 'display_type': fields.boolean("Landscape Mode"), - 'reserve_account_id': fields.many2one('account.account', 'Reserve & Profit/Loss Account', - help='This account is used for transferring Profit/Loss (If It is Profit: Amount will be added, Loss : Amount will be deducted.), as calculated in Profit & Loss Report', - domain = [('type','=','other')]), - 'journal_ids': fields.many2many('account.journal', 'account_bs_report_journal_rel', 'account_id', 'journal_id', 'Journals', required=True), - } - - _defaults={ - 'display_type': False, - 'journal_ids': [], - 'reserve_account_id': _get_def_reserve_account, - } - - def onchange_chart_id(self, cr, uid, ids, chart_id, context=None): - if not chart_id: - return {} - account = self.pool.get('account.account').browse(cr, uid, chart_id , context=context) - if not account.company_id.property_reserve_and_surplus_account: - return {'value': {'reserve_account_id': False}} - return {'value': {'reserve_account_id': account.company_id.property_reserve_and_surplus_account.id}} - - - def _print_report(self, cr, uid, ids, data, context=None): - if context is None: - context = {} - data['form'].update(self.read(cr, uid, ids, ['display_type','reserve_account_id'])[0]) - if not data['form']['reserve_account_id']: - raise osv.except_osv(_('Warning'),_('Please define the Reserve and Profit/Loss account for current user company !')) - data = self.pre_print_report(cr, uid, ids, data, context=context) - if data['form']['display_type']: - return { - 'type': 'ir.actions.report.xml', - 'report_name': 'account.balancesheet.horizontal', - 'datas': data, - } - else: - return { - 'type': 'ir.actions.report.xml', - 'report_name': 'account.balancesheet', - 'datas': data, - } - -account_bs_report() - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/account_report_balance_sheet_view.xml b/addons/account/wizard/account_report_balance_sheet_view.xml deleted file mode 100644 index faac52388a1..00000000000 --- a/addons/account/wizard/account_report_balance_sheet_view.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - Account Balance Sheet - account.bs.report - form - - - - - - - - - - - - - - - - - - - - - - - - Balance Sheet - account.bs.report - ir.actions.act_window - form - form - - new - - - - - - diff --git a/addons/account/wizard/account_report_profit_loss.py b/addons/account/wizard/account_report_profit_loss.py deleted file mode 100644 index f4c2897bfe0..00000000000 --- a/addons/account/wizard/account_report_profit_loss.py +++ /dev/null @@ -1,62 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2010 Tiny SPRL (). -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - -from osv import osv, fields - -class account_pl_report(osv.osv_memory): - """ - This wizard will provide the account profit and loss report by periods, between any two dates. - """ - _inherit = "account.common.account.report" - _name = "account.pl.report" - _description = "Account Profit And Loss Report" - - _columns = { - 'display_type': fields.boolean("Landscape Mode"), - 'journal_ids': fields.many2many('account.journal', 'account_pl_report_journal_rel', 'account_id', 'journal_id', 'Journals', required=True), - } - - _defaults = { - 'display_type': False, - 'journal_ids': [], - } - - def _print_report(self, cr, uid, ids, data, context=None): - if context is None: - context = {} - data = self.pre_print_report(cr, uid, ids, data, context=context) - data['form'].update(self.read(cr, uid, ids, ['display_type'])[0]) - if data['form']['display_type']: - return { - 'type': 'ir.actions.report.xml', - 'report_name': 'pl.account.horizontal', - 'datas': data, - } - else: - return { - 'type': 'ir.actions.report.xml', - 'report_name': 'pl.account', - 'datas': data, - } - -account_pl_report() - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/account_report_profit_loss_view.xml b/addons/account/wizard/account_report_profit_loss_view.xml deleted file mode 100644 index 75b6766ff87..00000000000 --- a/addons/account/wizard/account_report_profit_loss_view.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - Profit and Loss - account.pl.report - form - - - - - - - - - - - - - - - - - - - Account Profit And Loss - account.pl.report - ir.actions.act_window - form - form - - new - - - - - - - - diff --git a/addons/account_analytic_analysis/account_analytic_analysis_menu.xml b/addons/account_analytic_analysis/account_analytic_analysis_menu.xml index 1f6444c7351..e8647bd1aac 100644 --- a/addons/account_analytic_analysis/account_analytic_analysis_menu.xml +++ b/addons/account_analytic_analysis/account_analytic_analysis_menu.xml @@ -32,13 +32,11 @@ help="Analytic Accounts with a past deadline in one month." /> - - - + + - @@ -64,7 +62,7 @@ account.analytic.account form tree,form,graph - {'search_default_has_partner':1, 'search_default_my_accounts':1, 'search_default_draft':1, 'search_default_pending':1, 'search_default_open':1, 'search_default_renew':1} + {'search_default_has_partner':1, 'search_default_user_id':uid, 'search_default_draft':1, 'search_default_pending':1, 'search_default_open':1, 'search_default_renew':1} [('type','=','normal')] You will find here the contracts to be renewed because the deadline is passed or the working hours are higher than the allocated hours. OpenERP automatically sets these analytic accounts to the pending state, in order to raise a warning during the timesheets recording. Salesmen should review all pending accounts and reopen or close the according to the negotiation with the customer. @@ -76,7 +74,7 @@ account.analytic.account form tree,form,graph - {'search_default_has_partner':1, 'search_default_my_accounts':1, 'search_default_draft':1, 'search_default_pending':1, 'search_default_open':1} + {'search_default_has_partner':1, 'search_default_user_id':uid, 'search_default_draft':1, 'search_default_pending':1, 'search_default_open':1} [('type','=','normal')] diff --git a/addons/account_analytic_analysis/account_analytic_analysis_view.xml b/addons/account_analytic_analysis/account_analytic_analysis_view.xml index 9bf66c18344..73c98e650f8 100644 --- a/addons/account_analytic_analysis/account_analytic_analysis_view.xml +++ b/addons/account_analytic_analysis/account_analytic_analysis_view.xml @@ -16,14 +16,14 @@ - - + +