diff --git a/addons/account/project/report/account_journal.py b/addons/account/project/report/account_journal.py deleted file mode 100644 index 50f98fd0ee0..00000000000 --- a/addons/account/project/report/account_journal.py +++ /dev/null @@ -1,49 +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 -from openerp.report import report_sxw - -# -# Use period and Journal for selection or resources -# -class journal_print(report_sxw.rml_parse): - def lines(self, journal_id, *args): - self.cr.execute('select id from account_analytic_line where journal_id=%s order by date,id', (journal_id,)) - ids = map(lambda x: x[0], self.cr.fetchall()) - res = self.pool.get('account.analytic.line').browse(self.cr, self.uid, ids) - return res - def _sum_lines(self, journal_id): - self.cr.execute('select sum(amount) from account_analytic_line where journal_id=%s', (journal_id,)) - return self.cr.fetchone()[0] or 0.0 - def __init__(self, cr, uid, name, context): - super(journal_print, self).__init__(cr, uid, name, context=context) - self.localcontext = { - 'time': time, - 'lines': self.lines, - 'sum_lines': self._sum_lines, - } -report_sxw.report_sxw('report.account.analytic.journal.print', 'account.analytic.journal', 'addons/account/project/report/analytic_journal.rml',parser=journal_print) - - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/addons/account/project/report/analytic_balance.py b/addons/account/project/report/analytic_balance.py index 2aa9f2c549e..7c333b84c45 100644 --- a/addons/account/project/report/analytic_balance.py +++ b/addons/account/project/report/analytic_balance.py @@ -20,7 +20,7 @@ ############################################################################## import time - +from openerp.osv import osv from openerp.report import report_sxw @@ -56,7 +56,6 @@ class account_analytic_balance(report_sxw.rml_parse): self.get_children(data['child_ids']) return True - def _get_objects(self, empty_acc): if self.read_data: return self.read_data @@ -143,18 +142,16 @@ class account_analytic_balance(report_sxw.rml_parse): WHERE account_id IN %s AND date>=%s AND date<=%s",query_params) return self.cr.fetchone()[0] or 0.0 - - def _sum_balance(self, accounts, date1, date2): debit = self._sum_all(accounts, date1, date2, 'debit') or 0.0 credit = self._sum_all(accounts, date1, date2, 'credit') or 0.0 return (debit-credit) -report_sxw.report_sxw('report.account.analytic.account.balance', - 'account.analytic.account', 'addons/account/project/report/analytic_balance.rml', - parser=account_analytic_balance, header="internal") - +class report_analyticbalance(osv.AbstractModel): + _name = 'report.account.report_analyticbalance' + _inherit = 'report.abstract_report' + _template = 'account.report_analyticbalance' + _wrapped_report_class = account_analytic_balance # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/addons/account/project/report/analytic_journal.py b/addons/account/project/report/analytic_journal.py index 1ca1ffb3ca4..c59efb057d7 100644 --- a/addons/account/project/report/analytic_journal.py +++ b/addons/account/project/report/analytic_journal.py @@ -20,9 +20,10 @@ ############################################################################## import time - +from openerp.osv import osv from openerp.report import report_sxw + # # Use period and Journal for selection or resources # @@ -57,8 +58,11 @@ class account_analytic_journal(report_sxw.rml_parse): res = self.cr.dictfetchone() return res['sum'] or 0 -report_sxw.report_sxw('report.account.analytic.journal', 'account.analytic.journal', 'addons/account/project/report/analytic_journal.rml',parser=account_analytic_journal,header="internal") +class report_analyticjournal(osv.AbstractModel): + _name = 'report.account.report_analyticjournal' + _inherit = 'report.abstract_report' + _template = 'account.report_analyticjournal' + _wrapped_report_class = account_analytic_journal # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/addons/account/project/report/cost_ledger.py b/addons/account/project/report/cost_ledger.py index e594ab92a63..5eef375eaab 100644 --- a/addons/account/project/report/cost_ledger.py +++ b/addons/account/project/report/cost_ledger.py @@ -20,9 +20,10 @@ ############################################################################## import time - +from openerp.osv import osv from openerp.report import report_sxw + class account_analytic_cost_ledger(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): super(account_analytic_cost_ledger, self).__init__(cr, uid, name, context=context) @@ -100,8 +101,11 @@ class account_analytic_cost_ledger(report_sxw.rml_parse): credit = self._sum_credit(accounts, date1, date2) return (debit-credit) -report_sxw.report_sxw('report.account.analytic.account.cost_ledger', 'account.analytic.account', 'addons/account/project/report/cost_ledger.rml',parser=account_analytic_cost_ledger, header="internal") +class report_analyticcostledger(osv.AbstractModel): + _name = 'report.account.report_analyticcostledger' + _inherit = 'report.abstract_report' + _template = 'account.report_analyticcostledger' + _wrapped_report_class = account_analytic_cost_ledger # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/addons/account/project/report/inverted_analytic_balance.py b/addons/account/project/report/inverted_analytic_balance.py index bd86bcfe257..23129144555 100644 --- a/addons/account/project/report/inverted_analytic_balance.py +++ b/addons/account/project/report/inverted_analytic_balance.py @@ -20,7 +20,7 @@ ############################################################################## import time - +from openerp.osv import osv from openerp.report import report_sxw class account_inverted_analytic_balance(report_sxw.rml_parse): @@ -120,8 +120,11 @@ class account_inverted_analytic_balance(report_sxw.rml_parse): WHERE account_id IN %s AND date>=%s AND date<=%s", (tuple(ids),date1, date2,)) return self.cr.fetchone()[0] or 0.0 -report_sxw.report_sxw('report.account.analytic.account.inverted.balance', 'account.analytic.account', 'addons/account/project/report/inverted_analytic_balance.rml',parser=account_inverted_analytic_balance, header="internal") +class report_invertedanalyticbalance(osv.AbstractModel): + _name = 'report.account.report_invertedanalyticbalance' + _inherit = 'report.abstract_report' + _template = 'account.report_invertedanalyticbalance' + _wrapped_report_class = account_inverted_analytic_balance # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/addons/account/project/report/quantity_cost_ledger.py b/addons/account/project/report/quantity_cost_ledger.py index b22558b900f..d3ed1cdc3a8 100644 --- a/addons/account/project/report/quantity_cost_ledger.py +++ b/addons/account/project/report/quantity_cost_ledger.py @@ -19,9 +19,10 @@ # ############################################################################## import time - +from openerp.osv import osv from openerp.report import report_sxw + class account_analytic_quantity_cost_ledger(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): super(account_analytic_quantity_cost_ledger, self).__init__(cr, uid, name, context=context) @@ -116,9 +117,11 @@ class account_analytic_quantity_cost_ledger(report_sxw.rml_parse): AND journal_id IN %s",(tuple(ids), date1, date2, tuple(journal_ids))) return self.cr.fetchone()[0] or 0.0 -report_sxw.report_sxw('report.account.analytic.account.quantity_cost_ledger', - 'account.analytic.account', - 'addons/account/project/report/quantity_cost_ledger.rml', - parser=account_analytic_quantity_cost_ledger, header="internal") + +class report_analyticcostledgerquantity(osv.AbstractModel): + _name = 'report.account.report_analyticcostledgerquantity' + _inherit = 'report.abstract_report' + _template = 'account.report_analyticcostledgerquantity' + _wrapped_report_class = account_analytic_quantity_cost_ledger # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/project/views/report_analyticbalance.xml b/addons/account/project/views/report_analyticbalance.xml index 96f692eda3d..09cd56fc83f 100644 --- a/addons/account/project/views/report_analyticbalance.xml +++ b/addons/account/project/views/report_analyticbalance.xml @@ -22,28 +22,28 @@ Total - + - + - + - + - + - - - - + + + + - + diff --git a/addons/account/project/views/report_analyticcostledger.xml b/addons/account/project/views/report_analyticcostledger.xml index fd99c637411..cda37d4158f 100644 --- a/addons/account/project/views/report_analyticcostledger.xml +++ b/addons/account/project/views/report_analyticcostledger.xml @@ -10,11 +10,11 @@
Period From: -

+

Period To: -

+

Printing Date: @@ -38,10 +38,10 @@ Total: - - + + - + @@ -50,12 +50,12 @@ - - - + + + - + @@ -66,7 +66,7 @@ - + diff --git a/addons/account/project/views/report_analyticcostledgerquantity.xml b/addons/account/project/views/report_analyticcostledgerquantity.xml index 1098a7627f3..de49d4972e5 100644 --- a/addons/account/project/views/report_analyticcostledgerquantity.xml +++ b/addons/account/project/views/report_analyticcostledgerquantity.xml @@ -10,11 +10,11 @@
Period From: -

+

Period To: -

+

Printing Date: @@ -39,7 +39,7 @@ - + @@ -54,11 +54,11 @@

- + - + @@ -66,7 +66,7 @@ - + diff --git a/addons/account/project/views/report_analyticjournal.xml b/addons/account/project/views/report_analyticjournal.xml index ce2f216e419..1b3a4fda97c 100644 --- a/addons/account/project/views/report_analyticjournal.xml +++ b/addons/account/project/views/report_analyticjournal.xml @@ -11,11 +11,11 @@
Period From: -

+

Period To: -

+

Currency: @@ -35,12 +35,12 @@ - - - + + - + @@ -56,7 +56,7 @@ - + @@ -71,13 +71,13 @@ - +

- - + diff --git a/addons/account/project/views/report_invertedanalyticbalance.xml b/addons/account/project/views/report_invertedanalyticbalance.xml index 7ed8f4f84f3..e545ec8525b 100644 --- a/addons/account/project/views/report_invertedanalyticbalance.xml +++ b/addons/account/project/views/report_invertedanalyticbalance.xml @@ -22,14 +22,14 @@ Total - - + + - + - + - + @@ -58,7 +58,7 @@ - + diff --git a/addons/account/project/wizard/account_analytic_cost_ledger_for_journal_report.py b/addons/account/project/wizard/account_analytic_cost_ledger_for_journal_report.py index b3c2d1bec12..125dfda46fb 100644 --- a/addons/account/project/wizard/account_analytic_cost_ledger_for_journal_report.py +++ b/addons/account/project/wizard/account_analytic_cost_ledger_for_journal_report.py @@ -49,7 +49,6 @@ class account_analytic_cost_ledger_journal_report(osv.osv_memory): } datas['form']['active_ids'] = context.get('active_ids', False) - return self.pool['report'].get_action(cr, uid, ids, 'account.report_analyticcostledgerquantity', data=datas, context=context) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/project/wizard/account_analytic_inverted_balance_report.py b/addons/account/project/wizard/account_analytic_inverted_balance_report.py index 3b03ad2da56..ad79c0b33f6 100644 --- a/addons/account/project/wizard/account_analytic_inverted_balance_report.py +++ b/addons/account/project/wizard/account_analytic_inverted_balance_report.py @@ -46,9 +46,7 @@ class account_analytic_inverted_balance(osv.osv_memory): 'model': 'account.analytic.account', 'form': data } - datas['form']['active_ids'] = context.get('active_ids', False) - return self.pool['report'].get_action(cr, uid, ids, 'account.report_invertedanalyticbalance', data=datas, context=context) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/report/account_aged_partner_balance.py b/addons/account/report/account_aged_partner_balance.py index 3b000e40592..3fd83c19207 100644 --- a/addons/account/report/account_aged_partner_balance.py +++ b/addons/account/report/account_aged_partner_balance.py @@ -20,9 +20,11 @@ ############################################################################## import time +from openerp.osv import osv from openerp.report import report_sxw from common_report_header import common_report_header + class aged_trial_report(report_sxw.rml_parse, common_report_header): def __init__(self, cr, uid, name, context): @@ -375,8 +377,11 @@ class aged_trial_report(report_sxw.rml_parse, common_report_header): return self._translate('Receivable and Payable Accounts') return '' -report_sxw.report_sxw('report.account.aged_trial_balance', 'res.partner', - 'addons/account/report/account_aged_partner_balance.rml',parser=aged_trial_report, header="internal landscape") +class report_agedpartnerbalance(osv.AbstractModel): + _name = 'report.account.report_agedpartnerbalance' + _inherit = 'report.abstract_report' + _template = 'account.report_agedpartnerbalance' + _wrapped_report_class = aged_trial_report # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/report/account_balance.py b/addons/account/report/account_balance.py index 2a445984b27..af2c37fc610 100644 --- a/addons/account/report/account_balance.py +++ b/addons/account/report/account_balance.py @@ -21,9 +21,11 @@ import time +from openerp.osv import osv from openerp.report import report_sxw from common_report_header import common_report_header + class account_balance(report_sxw.rml_parse, common_report_header): _name = 'report.account.account.balance' @@ -58,11 +60,6 @@ class account_balance(report_sxw.rml_parse, common_report_header): objects = self.pool.get('account.account').browse(self.cr, self.uid, new_ids) return super(account_balance, self).set_context(objects, data, new_ids, report_type=report_type) - #def _add_header(self, node, header=1): - # if header == 0: - # self.rml_header = "" - # return True - def _get_account(self, data): if data['model']=='account.account': return self.pool.get('account.account').browse(self.cr, self.uid, data['form']['id']).company_id.name @@ -131,6 +128,11 @@ class account_balance(report_sxw.rml_parse, common_report_header): _process_child(accounts,form['display_account'],parent) return self.result_acc -report_sxw.report_sxw('report.account.account.balance', 'account.account', 'addons/account/report/account_balance.rml', parser=account_balance, header="internal") + +class report_trialbalance(osv.AbstractModel): + _name = 'report.account.report_trialbalance' + _inherit = 'report.abstract_report' + _template = 'account.report_trialbalance' + _wrapped_report_class = account_balance # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/report/account_central_journal.py b/addons/account/report/account_central_journal.py index 8dae208a7a5..28892d0730e 100644 --- a/addons/account/report/account_central_journal.py +++ b/addons/account/report/account_central_journal.py @@ -20,11 +20,14 @@ ############################################################################## import time +from openerp.osv import osv from openerp.report import report_sxw from common_report_header import common_report_header # # Use period and Journal for selection or resources # + + class journal_print(report_sxw.rml_parse, common_report_header): def __init__(self, cr, uid, name, context=None): @@ -103,6 +106,11 @@ class journal_print(report_sxw.rml_parse, common_report_header): return True return data['form']['amount_currency'] -report_sxw.report_sxw('report.account.central.journal', 'account.journal.period', 'addons/account/report/account_central_journal.rml', parser=journal_print, header='external') + +class report_agedpartnerbalance(osv.AbstractModel): + _name = 'report.account.report_centraljournal' + _inherit = 'report.abstract_report' + _template = 'account.report_centraljournal' + _wrapped_report_class = journal_print # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/report/account_financial_report.py b/addons/account/report/account_financial_report.py index 2b1f5af4d68..064f02c5fbf 100644 --- a/addons/account/report/account_financial_report.py +++ b/addons/account/report/account_financial_report.py @@ -23,6 +23,8 @@ import time from openerp.report import report_sxw from common_report_header import common_report_header from openerp.tools.translate import _ +from openerp.osv import osv + class report_account_common(report_sxw.rml_parse, common_report_header): @@ -105,8 +107,11 @@ class report_account_common(report_sxw.rml_parse, common_report_header): lines.append(vals) return lines -report_sxw.report_sxw('report.account.financial.report', 'account.financial.report', - 'addons/account/report/account_financial_report.rml', parser=report_account_common, header='internal') +class report_financial(osv.AbstractModel): + _name = 'report.account.report_financial' + _inherit = 'report.abstract_report' + _template = 'account.report_financial' + _wrapped_report_class = report_account_common # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/report/account_general_journal.py b/addons/account/report/account_general_journal.py index 4f63411478c..ada615e31fa 100644 --- a/addons/account/report/account_general_journal.py +++ b/addons/account/report/account_general_journal.py @@ -20,8 +20,10 @@ ############################################################################## import time -from common_report_header import common_report_header +from openerp.osv import osv from openerp.report import report_sxw +from common_report_header import common_report_header + class journal_print(report_sxw.rml_parse, common_report_header): @@ -156,6 +158,11 @@ class journal_print(report_sxw.rml_parse, common_report_header): (tuple(move_state), period_id, tuple(journals))) return self.cr.fetchone()[0] or 0.0 -report_sxw.report_sxw('report.account.general.journal', 'account.journal.period', 'addons/account/report/general_journal.rml', parser=journal_print, header='internal') + +class report_generaljournal(osv.AbstractModel): + _name = 'report.account.report_generaljournal' + _inherit = 'report.abstract_report' + _template = 'account.report_generaljournal' + _wrapped_report_class = journal_print # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/report/account_general_ledger.py b/addons/account/report/account_general_ledger.py index 4f712ad58cc..ffccbec300d 100644 --- a/addons/account/report/account_general_ledger.py +++ b/addons/account/report/account_general_ledger.py @@ -28,9 +28,11 @@ ############################################################################## import time +from openerp.osv import osv from openerp.report import report_sxw from common_report_header import common_report_header + class general_ledger(report_sxw.rml_parse, common_report_header): _name = 'report.account.general.ledger' @@ -304,7 +306,11 @@ class general_ledger(report_sxw.rml_parse, common_report_header): return self._translate('Journal & Partner') return self._translate('Date') -report_sxw.report_sxw('report.account.general.ledger', 'account.account', 'addons/account/report/account_general_ledger.rml', parser=general_ledger, header='internal') -report_sxw.report_sxw('report.account.general.ledger_landscape', 'account.account', 'addons/account/report/account_general_ledger_landscape.rml', parser=general_ledger, header='internal landscape') + +class report_generalledger(osv.AbstractModel): + _name = 'report.account.report_generalledger' + _inherit = 'report.abstract_report' + _template = 'account.report_generalledger' + _wrapped_report_class = general_ledger # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/report/account_journal.py b/addons/account/report/account_journal.py index 97e19be4b0c..13dfd538f4a 100644 --- a/addons/account/report/account_journal.py +++ b/addons/account/report/account_journal.py @@ -20,8 +20,10 @@ ############################################################################## import time -from common_report_header import common_report_header +from openerp.osv import osv from openerp.report import report_sxw +from common_report_header import common_report_header + class journal_print(report_sxw.rml_parse, common_report_header): @@ -196,7 +198,18 @@ class journal_print(report_sxw.rml_parse, common_report_header): return self._translate('Reference Number') return self._translate('Date') -report_sxw.report_sxw('report.account.journal.period.print', 'account.journal.period', 'addons/account/report/account_journal.rml', parser=journal_print, header='external') -report_sxw.report_sxw('report.account.journal.period.print.sale.purchase', 'account.journal.period', 'addons/account/report/account_journal_sale_purchase.rml', parser=journal_print, header='external') + +class report_journal(osv.AbstractModel): + _name = 'report.account.report_journal' + _inherit = 'report.abstract_report' + _template = 'account.report_journal' + _wrapped_report_class = journal_print + + +class report_salepurchasejournal(osv.AbstractModel): + _name = 'report.account.report_salepurchasejournal' + _inherit = 'report.abstract_report' + _template = 'account.report_salepurchasejournal' + _wrapped_report_class = journal_print # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/report/account_partner_balance.py b/addons/account/report/account_partner_balance.py index 53edbbe9685..ecd287551e5 100644 --- a/addons/account/report/account_partner_balance.py +++ b/addons/account/report/account_partner_balance.py @@ -20,11 +20,12 @@ ############################################################################## import time - +from openerp.osv import osv from openerp.tools.translate import _ from openerp.report import report_sxw from common_report_header import common_report_header + class partner_balance(report_sxw.rml_parse, common_report_header): def __init__(self, cr, uid, name, context=None): @@ -301,6 +302,11 @@ class partner_balance(report_sxw.rml_parse, common_report_header): return _('Receivable and Payable Accounts') return '' -report_sxw.report_sxw('report.account.partner.balance', 'res.partner', 'account/report/account_partner_balance.rml',parser=partner_balance, header="internal") + +class report_partnerbalance(osv.AbstractModel): + _name = 'report.account.report_partnerbalance' + _inherit = 'report.abstract_report' + _template = 'account.report_partnerbalance' + _wrapped_report_class = partner_balance # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/report/account_partner_ledger.py b/addons/account/report/account_partner_ledger.py index d21323e02fc..f02ac96b6fc 100644 --- a/addons/account/report/account_partner_ledger.py +++ b/addons/account/report/account_partner_ledger.py @@ -20,10 +20,11 @@ ############################################################################## import time -import re +from openerp.osv import osv +from openerp.tools.translate import _ from openerp.report import report_sxw from common_report_header import common_report_header -from openerp.tools.translate import _ + class third_party_ledger(report_sxw.rml_parse, common_report_header): @@ -297,12 +298,18 @@ class third_party_ledger(report_sxw.rml_parse, common_report_header): return True return False -report_sxw.report_sxw('report.account.third_party_ledger', 'res.partner', - 'addons/account/report/account_partner_ledger.rml',parser=third_party_ledger, - header='internal') -report_sxw.report_sxw('report.account.third_party_ledger_other', 'res.partner', - 'addons/account/report/account_partner_ledger_other.rml',parser=third_party_ledger, - header='internal') +class report_partnerledger(osv.AbstractModel): + _name = 'report.account.report_partnerledger' + _inherit = 'report.abstract_report' + _template = 'account.report_partnerledger' + _wrapped_report_class = third_party_ledger + + +class report_partnerledgerother(osv.AbstractModel): + _name = 'report.account.report_partnerledgerother' + _inherit = 'report.abstract_report' + _template = 'account.report_partnerledgerother' + _wrapped_report_class = third_party_ledger # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/report/account_print_overdue.py b/addons/account/report/account_print_overdue.py index e135f41309d..26192d39949 100644 --- a/addons/account/report/account_print_overdue.py +++ b/addons/account/report/account_print_overdue.py @@ -22,15 +22,36 @@ import time from openerp.report import report_sxw +from openerp.osv import osv + class Overdue(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): super(Overdue, self).__init__(cr, uid, name, context=context) - self.localcontext.update( { + ids = context.get('active_ids') + partner_obj = self.pool['res.partner'] + docs = partner_obj.browse(cr, uid, ids, context) + + due = {} + paid = {} + mat = {} + + for partner in docs: + due[partner.id] = reduce(lambda x, y: x + ((y['account_id']['type'] == 'receivable' and y['debit'] or 0) or (y['account_id']['type'] == 'payable' and y['credit'] * -1 or 0)), self._lines_get(partner), 0) + paid[partner.id] = reduce(lambda x, y: x + ((y['account_id']['type'] == 'receivable' and y['credit'] or 0) or (y['account_id']['type'] == 'payable' and y['debit'] * -1 or 0)), self._lines_get(partner), 0) + mat[partner.id] = reduce(lambda x, y: x + (y['debit'] - y['credit']), filter(lambda x: x['date_maturity'] < time.strftime('%Y-%m-%d'), self._lines_get(partner)), 0) + + addresses = self.pool['res.partner']._address_display(cr, uid, ids, None, None) + self.localcontext.update({ + 'docs': docs, 'time': time, 'getLines': self._lines_get, 'tel_get': self._tel_get, 'message': self._message, + 'due': due, + 'paid': paid, + 'mat': mat, + 'addresses': addresses }) self.context = context @@ -41,7 +62,7 @@ class Overdue(report_sxw.rml_parse): addresses = res_partner.address_get(self.cr, self.uid, [partner.id], ['invoice']) adr_id = addresses and addresses['invoice'] or False if adr_id: - adr=res_partner_address.read(self.cr, self.uid, [adr_id])[0] + adr=res_partner.read(self.cr, self.uid, [adr_id])[0] return adr['phone'] else: return partner.phone or False @@ -62,5 +83,10 @@ class Overdue(report_sxw.rml_parse): return message.split('\n') -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: +class report_overdue(osv.AbstractModel): + _name = 'report.account.report_overdue' + _inherit = 'report.abstract_report' + _template = 'account.report_overdue' + _wrapped_report_class = Overdue +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/report/report_vat.py b/addons/account/report/report_vat.py index 3a0950ac62f..be2b6244f7d 100644 --- a/addons/account/report/report_vat.py +++ b/addons/account/report/report_vat.py @@ -19,24 +19,16 @@ # ############################################################################## +import time from openerp.osv import osv -from openerp.addons.web import http -from openerp.addons.web.http import request +from openerp.report import report_sxw from common_report_header import common_report_header -try: - import cStringIO as StringIO -except ImportError: - import StringIO -import xlwt -class tax_report(osv.AbstractModel, common_report_header): - _name = 'report.account.report_vat' - - def render_html(self, cr, uid, ids, data=None, context=None): - report_obj = request.registry['report'] - self.cr, self.uid, self.context = cr, uid, context +class tax_report(report_sxw.rml_parse, common_report_header): + def set_context(self, objects, data, ids, report_type=None): + new_ids = ids res = {} self.period_ids = [] period_obj = self.pool.get('account.period') @@ -46,30 +38,42 @@ class tax_report(osv.AbstractModel, common_report_header): if data['form'].get('period_from', False) and data['form'].get('period_to', False): self.period_ids = period_obj.build_ctx_periods(self.cr, self.uid, data['form']['period_from'], data['form']['period_to']) + periods_l = period_obj.read(self.cr, self.uid, self.period_ids, ['name']) + for period in periods_l: + if res['periods'] == '': + res['periods'] = period['name'] + else: + res['periods'] += ", "+ period['name'] + return super(tax_report, self).set_context(objects, data, new_ids, report_type=report_type) - docargs = { - 'fiscalyear': self._get_fiscalyear(data), - 'account': self._get_account(data), - 'based_on': self._get_basedon(data), - 'period_from': self.get_start_period(data), - 'period_to': self.get_end_period(data), - 'taxlines': self._get_lines(self._get_basedon(data), company_id=data['form']['company_id'], cr=cr, uid=uid), - } - return report_obj.render(self.cr, self.uid, [], 'account.report_vat', docargs, context=context) + def __init__(self, cr, uid, name, context=None): + super(tax_report, self).__init__(cr, uid, name, context=context) + self.localcontext.update({ + 'time': time, + 'get_codes': self._get_codes, + 'get_general': self._get_general, + 'get_currency': self._get_currency, + 'get_lines': self._get_lines, + '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_basedon': self._get_basedon, + }) def _get_basedon(self, form): return form['form']['based_on'] - def _get_lines(self, based_on, company_id=False, parent=False, level=0, context=None, cr=None, uid=None): + def _get_lines(self, based_on, company_id=False, parent=False, level=0, context=None): period_list = self.period_ids - res = self._get_codes(based_on, company_id, parent, level, period_list, cr=cr, uid=uid, context=context) + res = self._get_codes(based_on, company_id, parent, level, period_list, context=context) if period_list: res = self._add_codes(based_on, res, period_list, context=context) else: - cr.execute ("select id from account_fiscalyear") - fy = cr.fetchall() - cr.execute ("select id from account_period where fiscalyear_id = %s",(fy[0][0],)) - periods = cr.fetchall() + self.cr.execute ("select id from account_fiscalyear") + fy = self.cr.fetchall() + self.cr.execute ("select id from account_period where fiscalyear_id = %s",(fy[0][0],)) + periods = self.cr.fetchall() for p in periods: period_list.append(p[0]) res = self._add_codes(based_on, res, period_list, context=context) @@ -89,7 +93,7 @@ class tax_report(osv.AbstractModel, common_report_header): } top_result.append(res_dict) - res_general = self._get_general(res[i][1].id, period_list, company_id, based_on, cr=cr, uid=uid, context=context) + res_general = self._get_general(res[i][1].id, period_list, company_id, based_on, context=context) ind_general = 0 while ind_general < len(res_general): res_general[ind_general]['type'] = 2 @@ -100,14 +104,14 @@ class tax_report(osv.AbstractModel, common_report_header): i+=1 return top_result - def _get_general(self, tax_code_id, period_list, company_id, based_on, cr=None, uid=None, context=None): + def _get_general(self, tax_code_id, period_list, company_id, based_on, context=None): if not self.display_detail: return [] res = [] obj_account = self.pool.get('account.account') periods_ids = tuple(period_list) if based_on == 'payments': - cr.execute('SELECT SUM(line.tax_amount) AS tax_amount, \ + self.cr.execute('SELECT SUM(line.tax_amount) AS tax_amount, \ SUM(line.debit) AS debit, \ SUM(line.credit) AS credit, \ COUNT(*) AS count, \ @@ -131,7 +135,7 @@ class tax_report(osv.AbstractModel, common_report_header): company_id, periods_ids, 'paid',)) else: - cr.execute('SELECT SUM(line.tax_amount) AS tax_amount, \ + self.cr.execute('SELECT SUM(line.tax_amount) AS tax_amount, \ SUM(line.debit) AS debit, \ SUM(line.credit) AS credit, \ COUNT(*) AS count, \ @@ -148,21 +152,23 @@ class tax_report(osv.AbstractModel, common_report_header): AND account.active \ GROUP BY account.id,account.name,account.code', ('draft', tax_code_id, company_id, periods_ids,)) - res = cr.dictfetchall() + res = self.cr.dictfetchall() i = 0 while i= int(accounts[bcl_rup_ind]['level']) and bcl_rup_ind >= 0 ): - res_tot = { - 'code': accounts[bcl_rup_ind]['code'], + res_tot = { 'code': accounts[bcl_rup_ind]['code'], 'name': '', 'debit': 0, 'credit': 0, @@ -225,40 +234,10 @@ class tax_report(osv.AbstractModel, common_report_header): return result_accounts -class tax_report_xls(http.Controller): - - @http.route(['/report/account.report_vat_xls'], type='http', auth='user', website=True, multilang=True) - def report_account_tax_xls(self, **data): - - # Very ugly lines, only for the proof of concept of 'controller' report - taxreport_obj = request.registry['report.account.report_vat'] - from openerp.addons.report.controllers.main import ReportController - eval_params = ReportController()._eval_params - - cr, uid = request.cr, request.uid - data = eval_params(data) - data = {'form': data} - - taxreport_obj.render_html(cr, uid, [], data=data) - lines = taxreport_obj._get_lines(taxreport_obj._get_basedon(data), company_id=data['form']['company_id'], cr=cr, uid=uid) - - if lines: - xls = StringIO.StringIO() - xls_workbook = xlwt.Workbook() - vat_sheet = xls_workbook.add_sheet('report_vat') - - for x in range(0, len(lines)): - for y in range(0, len(lines[0])): - vat_sheet.write(x, y, lines[x].values()[y]) - - xls_workbook.save(xls) - xls.seek(0) - content = xls.read() - - response = request.make_response(content, headers=[ - ('Content-Type', 'application/vnd.ms-excel'), - ('Content-Disposition', 'attachment; filename=report_vat.xls;') - ]) - return response +class report_vat(osv.AbstractModel): + _name = 'report.account.report_vat' + _inherit = 'report.abstract_report' + _template = 'account.report_vat' + _wrapped_report_class = tax_report # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/test/account_report.yml b/addons/account/test/account_report.yml index 7a2d09486e4..9173c37b61e 100644 --- a/addons/account/test/account_report.yml +++ b/addons/account/test/account_report.yml @@ -16,10 +16,9 @@ import os import openerp.report from openerp import tools - data, format = openerp.report.render_report(cr, uid, [ref('account.account_invoice_customer0')], 'account.invoice', {}, {}) + data, format = openerp.report.render_report(cr, uid, [ref('account.account_invoice_customer0')], 'account.report_invoice', {}, {}) if tools.config['test_report_directory']: file(os.path.join(tools.config['test_report_directory'], 'account-invoice.'+format), 'wb+').write(data) - - In order to test the PDF reports defined on a partner, we will print the Overdue Report - @@ -27,7 +26,7 @@ import os import openerp.report from openerp import tools - data, format = openerp.report.render_report(cr, uid, [ref('base.res_partner_1'),ref('base.res_partner_2'),ref('base.res_partner_12')], 'account.overdue', {}, {}) + data, format = openerp.report.render_report(cr, uid, [ref('base.res_partner_1'),ref('base.res_partner_2'),ref('base.res_partner_12')], 'account.report_overdue', {}, {}) if tools.config['test_report_directory']: file(os.path.join(tools.config['test_report_directory'], 'account-report_overdue.'+format), 'wb+').write(data) - @@ -86,8 +85,8 @@ Print the General Ledger Report in Landscape Mode - !python {model: account.account}: | - ctx={} - data_dict = {'chart_account_id':ref('account.chart0'),'landscape':True} + ctx={'landscape': True} + data_dict = {'chart_account_id':ref('account.chart0')} from openerp.tools import test_reports test_reports.try_report_action(cr, uid, 'action_account_general_ledger_menu',wiz_data=data_dict, context=ctx, our_module='account') - diff --git a/addons/account/views/report_agedpartnerbalance.xml b/addons/account/views/report_agedpartnerbalance.xml index 9ab05afa772..019f32a35de 100644 --- a/addons/account/views/report_agedpartnerbalance.xml +++ b/addons/account/views/report_agedpartnerbalance.xml @@ -52,11 +52,11 @@ Due Not due - - - - - + + + + + + Total diff --git a/addons/account/views/report_overdue.xml b/addons/account/views/report_overdue.xml index 080de9a5615..0c2d763f84e 100644 --- a/addons/account/views/report_overdue.xml +++ b/addons/account/views/report_overdue.xml @@ -8,6 +8,7 @@
+
diff --git a/addons/account/views/report_vat.xml b/addons/account/views/report_vat.xml index 03664045ef4..f88d45e5c44 100644 --- a/addons/account/views/report_vat.xml +++ b/addons/account/views/report_vat.xml @@ -39,7 +39,7 @@ - + diff --git a/addons/account/wizard/account_financial_report.py b/addons/account/wizard/account_financial_report.py index df1fa94ae90..6c1b57fa428 100644 --- a/addons/account/wizard/account_financial_report.py +++ b/addons/account/wizard/account_financial_report.py @@ -84,8 +84,6 @@ class accounting_report(osv.osv_memory): if isinstance(data['form'][field], tuple): data['form'][field] = data['form'][field][0] comparison_context = self._build_comparison_context(cr, uid, ids, data, context=context) - res['data'] = {} - res['data']['form'] = data['form'] res['data']['form']['comparison_context'] = comparison_context return res diff --git a/addons/account/wizard/account_report_partner_ledger.py b/addons/account/wizard/account_report_partner_ledger.py index 75f79512603..eb743e32e4f 100644 --- a/addons/account/wizard/account_report_partner_ledger.py +++ b/addons/account/wizard/account_report_partner_ledger.py @@ -57,6 +57,8 @@ class account_partner_ledger(osv.osv_memory): context = {} data = self.pre_print_report(cr, uid, ids, data, context=context) data['form'].update(self.read(cr, uid, ids, ['initial_balance', 'filter', 'page_split', 'amount_currency'])[0]) + if data['form'].get('page_split') is True: + return self.pool['report'].get_action(cr, uid, ids, 'account.report_partnerledgerother', data=data, context=context) return self.pool['report'].get_action(cr, uid, ids, 'account.report_partnerledger', data=data, context=context) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_analytic_plans/__openerp__.py b/addons/account_analytic_plans/__openerp__.py index 7c580bd14f2..7ca7c00e6c0 100644 --- a/addons/account_analytic_plans/__openerp__.py +++ b/addons/account_analytic_plans/__openerp__.py @@ -76,7 +76,7 @@ The analytic plan validates the minimum and maximum percentage at the time of cr 'views/report_crossoveredanalyticplans.xml', ], 'demo': [], - 'test': [], + 'test': ['test/acount_analytic_plans_report.yml'], 'installable': True, 'auto_install': False, } diff --git a/addons/account_analytic_plans/report/crossovered_analytic.py b/addons/account_analytic_plans/report/crossovered_analytic.py index b1a8f965d6b..ef7589fda8e 100644 --- a/addons/account_analytic_plans/report/crossovered_analytic.py +++ b/addons/account_analytic_plans/report/crossovered_analytic.py @@ -20,9 +20,10 @@ ############################################################################## import time - +from openerp.osv import osv from openerp.report import report_sxw + class crossovered_analytic(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): super(crossovered_analytic, self).__init__(cr, uid, name, context = context) @@ -173,7 +174,11 @@ class crossovered_analytic(report_sxw.rml_parse): final.append(item) return final -report_sxw.report_sxw('report.account.analytic.account.crossovered.analytic', 'account.analytic.account', 'addons/account_analytic_plans/report/crossovered_analytic.rml',parser = crossovered_analytic, header='internal') + +class report_crossoveredanalyticplans(osv.AbstractModel): + _name = 'report.account_analytic_plans.report_crossoveredanalyticplans' + _inherit = 'report.abstract_report' + _template = 'account_analytic_plans.report_crossoveredanalyticplans' + _wrapped_report_class = crossovered_analytic # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/addons/account_analytic_plans/test/acount_analytic_plans_report.yml b/addons/account_analytic_plans/test/acount_analytic_plans_report.yml index 6aa67a3052a..cae58583793 100644 --- a/addons/account_analytic_plans/test/acount_analytic_plans_report.yml +++ b/addons/account_analytic_plans/test/acount_analytic_plans_report.yml @@ -6,6 +6,6 @@ import openerp.report from openerp import tools data_dict = {'model': 'account.analytic.account', 'form': {'date1':time.strftime("%Y-01-01"),'date2':time.strftime('%Y-%m-%d'),'journal_ids':[6,0,(ref('account.cose_journal_sale'))],'ref':ref('account.analytic_root'),'empty_line':True,'id':ref('account.analytic_root'),'context':{}}} - data, format = openerp.report.render_report(cr, uid, [ref('account.analytic_root')], 'account.analytic.account.crossovered.analytic', data_dict, {}) + data, format = openerp.report.render_report(cr, uid, [ref('account.analytic_root')], 'account_analytic_plans.report_crossoveredanalyticplans', data_dict, {}) if tools.config['test_report_directory']: file(os.path.join(tools.config['test_report_directory'], 'account_analytic_plans-crossovered_analyitic.'+format), 'wb+').write(data) diff --git a/addons/account_analytic_plans/views/report_crossoveredanalyticplans.xml b/addons/account_analytic_plans/views/report_crossoveredanalyticplans.xml index bce3cccd5c7..b4470ea2913 100644 --- a/addons/account_analytic_plans/views/report_crossoveredanalyticplans.xml +++ b/addons/account_analytic_plans/views/report_crossoveredanalyticplans.xml @@ -11,11 +11,11 @@
From Date: -

+

To Date: -

+

Company: diff --git a/addons/account_bank_statement_extensions/report/bank_statement_balance_report.py b/addons/account_bank_statement_extensions/report/bank_statement_balance_report.py index 59b8efb23e1..f0b63bf148c 100644 --- a/addons/account_bank_statement_extensions/report/bank_statement_balance_report.py +++ b/addons/account_bank_statement_extensions/report/bank_statement_balance_report.py @@ -21,15 +21,14 @@ ############################################################################## import time - +from openerp.osv import osv from openerp.report import report_sxw + class bank_statement_balance_report(report_sxw.rml_parse): def set_context(self, objects, data, ids, report_type=None): cr = self.cr - uid = self.uid - context = self.context cr.execute('SELECT s.name as s_name, s.date AS s_date, j.code as j_code, s.balance_end_real as s_balance ' \ 'FROM account_bank_statement s ' \ @@ -46,7 +45,6 @@ class bank_statement_balance_report(report_sxw.rml_parse): }) super(bank_statement_balance_report, self).set_context(objects, data, ids, report_type=report_type) - def __init__(self, cr, uid, name, context): if context is None: context = {} @@ -56,12 +54,11 @@ class bank_statement_balance_report(report_sxw.rml_parse): }) self.context = context -report_sxw.report_sxw( - 'report.bank.statement.balance.report', - 'account.bank.statement', - 'addons/account_bank_statement_extensions/report/bank_statement_balance_report.rml', - parser=bank_statement_balance_report, - header='internal' -) + +class report_bankstatementbalance(osv.AbstractModel): + _name = 'report.account_bank_statement_extensions.report_bankstatementbalance' + _inherit = 'report.abstract_report' + _template = 'account_bank_statement_extensions.report_bankstatementbalance' + _wrapped_report_class = bank_statement_balance_report # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_budget/report/analytic_account_budget_report.py b/addons/account_budget/report/analytic_account_budget_report.py index 6701fc06a2b..4e3feaf06b7 100644 --- a/addons/account_budget/report/analytic_account_budget_report.py +++ b/addons/account_budget/report/analytic_account_budget_report.py @@ -20,10 +20,10 @@ ############################################################################## import time -import datetime - +from openerp.osv import osv from openerp.report import report_sxw + class analytic_account_budget_report(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): super(analytic_account_budget_report, self).__init__(cr, uid, name, context=context) @@ -166,6 +166,11 @@ class analytic_account_budget_report(report_sxw.rml_parse): result.append(res) return result -report_sxw.report_sxw('report.account.analytic.account.budget', 'account.analytic.account', 'addons/account_budget/report/analytic_account_budget_report.rml',parser=analytic_account_budget_report,header='internal') + +class report_analyticaccountbudget(osv.AbstractModel): + _name = 'report.account_budget.report_analyticaccountbudget' + _inherit = 'report.abstract_report' + _template = 'account_budget.report_analyticaccountbudget' + _wrapped_report_class = analytic_account_budget_report # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_budget/report/budget_report.py b/addons/account_budget/report/budget_report.py index f00eb8a3713..f8f812639b0 100644 --- a/addons/account_budget/report/budget_report.py +++ b/addons/account_budget/report/budget_report.py @@ -20,6 +20,7 @@ ############################################################################## import time +from openerp.osv import osv from openerp.report import report_sxw tot = {} @@ -187,6 +188,11 @@ class budget_report(report_sxw.rml_parse): result.append(res) return result -report_sxw.report_sxw('report.account.budget', 'account.budget.post', 'addons/account_budget/report/budget_report.rml', parser=budget_report, header='internal') + +class report_budget(osv.AbstractModel): + _name = 'report.account_budget.report_budget' + _inherit = 'report.abstract_report' + _template = 'account_budget.report_budget' + _wrapped_report_class = budget_report # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_budget/report/crossovered_budget_report.py b/addons/account_budget/report/crossovered_budget_report.py index 70cbdecb713..8a001aafb39 100644 --- a/addons/account_budget/report/crossovered_budget_report.py +++ b/addons/account_budget/report/crossovered_budget_report.py @@ -20,11 +20,9 @@ ############################################################################## import time -import datetime - +from openerp.osv import osv from openerp.report import report_sxw -import operator -from openerp import osv + class budget_report(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): @@ -191,7 +189,11 @@ class budget_report(report_sxw.rml_parse): result.append(res) return result -report_sxw.report_sxw('report.crossovered.budget.report', 'crossovered.budget', 'addons/account_budget/report/crossovered_budget_report.rml',parser=budget_report,header='internal') + +class report_crossoveredbudget(osv.AbstractModel): + _name = 'report.account_budget.report_crossoveredbudget' + _inherit = 'report.abstract_report' + _template = 'account_budget.report_crossoveredbudget' + _wrapped_report_class = budget_report # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/addons/account_budget/test/account_budget_report.yml b/addons/account_budget/test/account_budget_report.yml index 80ab9b36b34..a36c2d87d04 100644 --- a/addons/account_budget/test/account_budget_report.yml +++ b/addons/account_budget/test/account_budget_report.yml @@ -2,35 +2,22 @@ Print the Analytic Budget Report through wizard - !python {model: account.analytic.account}: | - import os, time - from openerp import netsvc, tools - ctx={} - ctx.update({'model': 'account.analytic.account','active_ids': [ref('account.analytic_root')]}) - data_dict = {} + ctx = {'model': 'account.analytic.account','active_ids': [ref('account.analytic_root')]} from openerp.tools import test_reports - test_reports.try_report_action(cr, uid, 'action_account_budget_analytic',wiz_data=data_dict, context=ctx, our_module='account_budget') + test_reports.try_report_action(cr, uid, 'action_account_budget_analytic',wiz_data={}, context=ctx, our_module='account_budget') - Print the Budget Report through wizard - !python {model: account.budget.post}: | - import os, time - from openerp import netsvc, tools - ctx={} - ctx.update({'model': 'account.budget.post','active_ids': [ref('account_budget.account_budget_post_sales0')]}) - data_dict = {} + ctx = {'model': 'account.budget.post','active_ids': [ref('account_budget.account_budget_post_sales0')]} from openerp.tools import test_reports - test_reports.try_report_action(cr, uid, 'action_account_budget_report',wiz_data=data_dict, context=ctx, our_module='account_budget') + test_reports.try_report_action(cr, uid, 'action_account_budget_report',wiz_data={}, context=ctx, our_module='account_budget') - Print the CrossOvered Budget Report mode through wizard - !python {model: crossovered.budget}: | - import os, time - from openerp import netsvc, tools - ctx={} - ctx.update({'model': 'account.budget.post','active_ids': [ref('account_budget.crossovered_budget_budgetoptimistic0')]}) - data_dict = {} + ctx = {'model': 'account.budget.post','active_ids': [ref('account_budget.crossovered_budget_budgetoptimistic0')]} from openerp.tools import test_reports - test_reports.try_report_action(cr, uid, 'action_account_budget_crossvered_report',wiz_data=data_dict, context=ctx, our_module='account_budget') - + test_reports.try_report_action(cr, uid, 'action_account_budget_crossvered_report',wiz_data={}, context=ctx, our_module='account_budget') diff --git a/addons/account_check_writing/report/check_print.py b/addons/account_check_writing/report/check_print.py index add79fcc35a..be5feb4662b 100644 --- a/addons/account_check_writing/report/check_print.py +++ b/addons/account_check_writing/report/check_print.py @@ -20,8 +20,9 @@ ############################################################################## import time +from openerp.osv import osv from openerp.report import report_sxw -from openerp.tools import amount_to_text_en + class report_print_check(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): @@ -33,13 +34,14 @@ class report_print_check(report_sxw.rml_parse): 'get_lines': self.get_lines, 'fill_stars' : self.fill_stars, }) + def fill_stars(self, amount): if len(amount) < 100: stars = 100 - len(amount) return ' '.join([amount,'*'*stars]) else: return amount - + def get_lines(self, voucher_lines): result = [] self.number_lines = len(voucher_lines) @@ -63,24 +65,11 @@ class report_print_check(report_sxw.rml_parse): result.append(res) return result -report_sxw.report_sxw( - 'report.account.print.check.top', - 'account.voucher', - 'addons/account_check_writing/report/check_print_top.rml', - parser=report_print_check,header=False -) -report_sxw.report_sxw( - 'report.account.print.check.middle', - 'account.voucher', - 'addons/account_check_writing/report/check_print_middle.rml', - parser=report_print_check,header=False -) +class report_check(osv.AbstractModel): + _name = 'report.account_check_writing.report_check' + _inherit = 'report.abstract_report' + _template = 'account_check_writing.report_check' + _wrapped_report_class = report_print_check -report_sxw.report_sxw( - 'report.account.print.check.bottom', - 'account.voucher', - 'addons/account_check_writing/report/check_print_bottom.rml', - parser=report_print_check,header=False -) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_followup/account_followup.py b/addons/account_followup/account_followup.py index 5f912b61b37..eae361913ad 100644 --- a/addons/account_followup/account_followup.py +++ b/addons/account_followup/account_followup.py @@ -21,7 +21,6 @@ from openerp.osv import fields, osv from lxml import etree -import openerp.tools as tools from openerp.tools.translate import _ class followup(osv.osv): @@ -243,7 +242,8 @@ class res_partner(osv.osv): if partner.unreconciled_aml_ids: company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id current_date = fields.date.context_today(self, cr, uid, context=context) - final_res = self.pool['report.account_followup.report_followup']._lines_get_with_partner(partner, company.id, cr=cr, uid=uid) + rml_parse = account_followup_print.report_rappel(cr, uid, "followup_rml_parser") + final_res = rml_parse._lines_get_with_partner(partner, company.id) for currency_dict in final_res: currency = currency_dict.get('line', [{'currency_id': company.currency_id}])[0]['currency_id'] @@ -272,8 +272,7 @@ class res_partner(osv.osv): total = reduce(lambda x, y: x+y['balance'], currency_dict['line'], 0.00) - report_obj = self.pool.get('report') - total = report_obj.formatLang(total, dp='Account', currency_obj=currency, cr=cr, uid=uid) + total = rml_parse.formatLang(total, dp='Account', currency_obj=currency) followup_table += '''
''' + _("Amount due") + ''' : %s
''' % (total) diff --git a/addons/account_followup/report/account_followup_print.py b/addons/account_followup/report/account_followup_print.py index eecba81acb9..4e856853915 100644 --- a/addons/account_followup/report/account_followup_print.py +++ b/addons/account_followup/report/account_followup_print.py @@ -21,9 +21,10 @@ import time from collections import defaultdict - +from openerp.osv import osv from openerp.report import report_sxw + class report_rappel(report_sxw.rml_parse): _name = "account_followup.report.rappel" @@ -108,8 +109,11 @@ class report_rappel(report_sxw.rml_parse): } return text -report_sxw.report_sxw('report.account_followup.followup.print', - 'account_followup.stat.by.partner', 'addons/account_followup/report/account_followup_print.rml', - parser=report_rappel) + +class report_followup(osv.AbstractModel): + _name = 'report.account_followup.report_followup' + _inherit = 'report.abstract_report' + _template = 'account_followup.report_followup' + _wrapped_report_class = report_rappel # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_followup/wizard/account_followup_print.py b/addons/account_followup/wizard/account_followup_print.py index 00ecab7b860..7b7cb8fc77e 100644 --- a/addons/account_followup/wizard/account_followup_print.py +++ b/addons/account_followup/wizard/account_followup_print.py @@ -218,18 +218,18 @@ class account_followup_print(osv.osv_memory): #Update partners self.do_update_followup_level(cr, uid, to_update, partner_list, date, context=context) #process the partners (send mails...) - restot = self.process_partners(cr, uid, partner_list, data, context=context) + restot_context = context.copy() + restot = self.process_partners(cr, uid, partner_list, data, context=restot_context) + context.update(restot_context) #clear the manual actions if nothing is due anymore nbactionscleared = self.clear_manual_actions(cr, uid, partner_list, context=context) if nbactionscleared > 0: restot['resulttext'] = restot['resulttext'] + "
  • " + _("%s partners have no credits and as such the action is cleared") %(str(nbactionscleared)) + "
  • " - res = restot['action'] - #return the next action mod_obj = self.pool.get('ir.model.data') model_data_ids = mod_obj.search(cr, uid, [('model','=','ir.ui.view'),('name','=','view_account_followup_sending_results')], context=context) resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id'] - context.update({'description': restot['resulttext'], 'needprinting': restot['needprinting'], 'report_data': res}) + context.update({'description': restot['resulttext'], 'needprinting': restot['needprinting'], 'report_data': restot['action']}) return { 'name': _('Send Letters and Emails: Actions Summary'), 'view_type': 'form', diff --git a/addons/account_payment/report/payment_order.py b/addons/account_payment/report/payment_order.py index a851a54ecbb..292d0e11bf4 100644 --- a/addons/account_payment/report/payment_order.py +++ b/addons/account_payment/report/payment_order.py @@ -20,9 +20,10 @@ ############################################################################## import time - +from openerp.osv import osv from openerp.report import report_sxw + class payment_order(report_sxw.rml_parse): def __init__(self, cr, uid, name, context=None): @@ -70,6 +71,11 @@ class payment_order(report_sxw.rml_parse): return value_name[0][1] return False -report_sxw.report_sxw('report.payment.order', 'payment.order', 'addons/account_payment/report/payment_order.rml', parser=payment_order, header="external") + +class report_paymentorder(osv.AbstractModel): + _name = 'report.account_payment.report_paymentorder' + _inherit = 'report.abstract_report' + _template = 'account_payment.report_paymentorder' + _wrapped_report_class = payment_order # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_payment/test/account_payment_report.yml b/addons/account_payment/test/account_payment_report.yml index 3def62de429..922d2502203 100644 --- a/addons/account_payment/test/account_payment_report.yml +++ b/addons/account_payment/test/account_payment_report.yml @@ -5,6 +5,6 @@ import os import openerp.report from openerp import tools - data, format = openerp.report.render_report(cr, uid, [ref('payment_order_1')], 'payment.order', {}, {}) + data, format = openerp.report.render_report(cr, uid, [ref('payment_order_1')], 'account_payment.report_paymentorder', {}, {}) if tools.config['test_report_directory']: file(os.path.join(tools.config['test_report_directory'], 'account_payment-payment_order_report.'+format), 'wb+').write(data) diff --git a/addons/account_test/report/account_test_report.py b/addons/account_test/report/account_test_report.py index 0cfbc040d82..bb21e3807a8 100644 --- a/addons/account_test/report/account_test_report.py +++ b/addons/account_test/report/account_test_report.py @@ -23,8 +23,10 @@ import datetime import time -from openerp.report import report_sxw +from openerp.osv import osv from openerp.tools.translate import _ +from openerp.report import report_sxw + # # Use period and Journal for selection or resources @@ -84,6 +86,11 @@ class report_assert_account(report_sxw.rml_parse): return result -report_sxw.report_sxw('report.account.test.assert.print', 'accounting.assert.test', 'addons/account_test/report/account_test.rml', parser=report_assert_account, header=False) + +class report_accounttest(osv.AbstractModel): + _name = 'report.account_test.report_accounttest' + _inherit = 'report.abstract_report' + _template = 'account_test.report_accounttest' + _wrapped_report_class = report_assert_account # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_voucher/__openerp__.py b/addons/account_voucher/__openerp__.py index 6a3b0ee81cd..dc8102d6647 100644 --- a/addons/account_voucher/__openerp__.py +++ b/addons/account_voucher/__openerp__.py @@ -58,7 +58,6 @@ This module manages: 'report/account_voucher_sales_receipt_view.xml', 'security/account_voucher_security.xml', 'account_voucher_data.xml', - 'account_voucher_report.xml', ], 'test' : [ 'test/account_voucher_users.yml', @@ -73,7 +72,6 @@ This module manages: 'test/case3_eur_eur.yml', 'test/case4_cad_chf.yml', 'test/case_eur_usd.yml', - 'account_voucher_report.yml', ], 'auto_install': False, 'application': True, diff --git a/addons/account_voucher/account_voucher_report.xml b/addons/account_voucher/account_voucher_report.xml deleted file mode 100644 index 239492d1a27..00000000000 --- a/addons/account_voucher/account_voucher_report.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - diff --git a/addons/account_voucher/report/__init__.py b/addons/account_voucher/report/__init__.py index 862843352a8..53ac7e915be 100644 --- a/addons/account_voucher/report/__init__.py +++ b/addons/account_voucher/report/__init__.py @@ -19,8 +19,6 @@ # ############################################################################## -import account_voucher -import account_voucher_print import account_voucher_sales_receipt # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_voucher/report/account_voucher.py b/addons/account_voucher/report/account_voucher.py deleted file mode 100644 index c23c7f4d384..00000000000 --- a/addons/account_voucher/report/account_voucher.py +++ /dev/null @@ -1,75 +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 -from openerp.report import report_sxw -from openerp.tools import amount_to_text_en - -class report_voucher(report_sxw.rml_parse): - def __init__(self, cr, uid, name, context): - super(report_voucher, self).__init__(cr, uid, name, context) - self.localcontext.update({ - 'time': time, - 'convert':self.convert, - 'get_title': self.get_title, - 'debit':self.debit, - 'credit':self.credit, - 'get_ref': self._get_ref - }) - - def convert(self, amount, cur): - amt_en = amount_to_text_en.amount_to_text(amount, 'en', cur) - return amt_en - - def get_title(self, type): - title = '' - if type: - title = type[0].swapcase() + type[1:] + " Voucher" - return title - - def debit(self, move_ids): - debit = 0.0 - for move in move_ids: - debit += move.debit - return debit - - def credit(self, move_ids): - credit = 0.0 - for move in move_ids: - credit += move.credit - return credit - - def _get_ref(self, voucher_id, move_ids): - voucher_line_obj = self.pool.get('account.voucher.line') - voucher_line = voucher_line_obj.search(self.cr, self.uid, [('partner_id', '=', move_ids.partner_id.id), ('voucher_id', '=', voucher_id)]) - if voucher_line: - voucher = voucher_line_obj.browse(self.cr, self.uid, voucher_line)[0] - return voucher.name - else: - return -report_sxw.report_sxw( - 'report.voucher.cash_receipt.drcr', - 'account.voucher', - 'addons/account_voucher/report/account_voucher.rml', - parser=report_voucher,header="external" -) - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_voucher/report/account_voucher_print.py b/addons/account_voucher/report/account_voucher_print.py deleted file mode 100644 index 1bc411947f6..00000000000 --- a/addons/account_voucher/report/account_voucher_print.py +++ /dev/null @@ -1,96 +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 -from openerp.report import report_sxw -from openerp.tools import amount_to_text_en - -class report_voucher_print(report_sxw.rml_parse): - def __init__(self, cr, uid, name, context): - super(report_voucher_print, self).__init__(cr, uid, name, context) - self.localcontext.update({ - 'time': time, - 'get_title': self.get_title, - 'get_lines':self.get_lines, - 'get_on_account':self.get_on_account, - 'convert':self.convert - }) - - def convert(self, amount, cur): - amt_en = amount_to_text_en.amount_to_text(amount, 'en', cur) - return amt_en - - def get_lines(self, voucher): - result = [] - if voucher.type in ('payment','receipt'): - type = voucher.line_ids and voucher.line_ids[0].type or False - for move in voucher.move_ids: - res = {} - amount = move.credit - if type == 'dr': - amount = move.debit - if amount > 0.0: - res['pname'] = move.partner_id.name - res['ref'] = 'Agst Ref'+" "+str(move.name) - res['aname'] = move.account_id.name - res['amount'] = amount - result.append(res) - else: - type = voucher.line_ids and voucher.line_ids[0].type or False - for move in voucher.move_ids: - res = {} - amount = move.credit - if type == 'dr': - amount = move.debit - if amount > 0.0: - res['pname'] = move.partner_id.name - res['ref'] = move.name - res['aname'] = move.account_id.name - res['amount'] = amount - result.append(res) - return result - - def get_title(self, type): - title = '' - if type: - title = type[0].swapcase() + type[1:] + " Voucher" - return title - - def get_on_account(self, voucher): - name = "" - if voucher.type == 'receipt': - name = "Received cash from "+str(voucher.partner_id.name) - elif voucher.type == 'payment': - name = "Payment from "+str(voucher.partner_id.name) - elif voucher.type == 'sale': - name = "Sale to "+str(voucher.partner_id.name) - elif voucher.type == 'purchase': - name = "Purchase from "+str(voucher.partner_id.name) - return name - -report_sxw.report_sxw( - 'report.voucher.print', - 'account.voucher', - 'addons/account_voucher/report/account_voucher_print.rml', - parser=report_voucher_print,header="external" -) - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_voucher/test/account_voucher_report.yml b/addons/account_voucher/test/account_voucher_report.yml deleted file mode 100644 index 96e96e4bdfd..00000000000 --- a/addons/account_voucher/test/account_voucher_report.yml +++ /dev/null @@ -1,27 +0,0 @@ -- - Demo for Account Voucher -- - !record {model: account.voucher, id: account_voucher_voucheraxelor0again, view: view_sale_receipt_form}: - type: sale - account_id: account.cash - company_id: base.main_company - journal_id: account.bank_journal - name: Voucher Axelor - narration: PC Assemble SC234 - amount: 1000.0 - line_ids: - - account_id: account.cash - amount: 1000.0 - name: Voucher Axelor - period_id: account.period_6 - -- - In order to test the PDF reports defined on a account_voucher, we will print account voucher Report -- - !python {model: account.voucher}: | - import os - import openerp.report - from openerp import tools - data, format = openerp.report.render_report(cr, uid, [ref("account_voucher_voucheraxelor0again")], 'voucher.cash_receipt.drcr', {}, {}) - if tools.config['test_report_directory']: - file(os.path.join(tools.config['test_report_directory'], 'account_voucher-report.'+format), 'wb+').write(data) diff --git a/addons/lunch/report/order.py b/addons/lunch/report/order.py index 0bb99f01017..85b216ac632 100644 --- a/addons/lunch/report/order.py +++ b/addons/lunch/report/order.py @@ -20,11 +20,11 @@ ############################################################################## import time -from openerp.addons.web import http -from openerp.addons.web.http import request +from openerp.report import report_sxw +from openerp.osv import osv -class order(http.Controller): +class order(report_sxw.rml_parse): def get_lines(self, user,objects): lines=[] @@ -60,24 +60,23 @@ class order(http.Controller): notes.append(obj.note) return notes - @http.route(['/report/lunch.report_lunchorder/'], type='http', auth='user', website=True, multilang=True) - def report_lunch(self, docids): - self.cr, self.uid, self.context = request.cr, request.uid, request.context - - ids = [int(i) for i in docids.split(',')] - report_obj = request.registry['lunch.order.line'] - docs = report_obj.browse(self.cr, self.uid, ids, context=self.context) - + def __init__(self, cr, uid, name, context): + super(order, self).__init__(cr, uid, name, context) self.net_total=0.0 - docargs = { - 'docs': docs, + self.localcontext.update({ 'time': time, 'get_lines': self.get_lines, 'get_users': self.get_users, 'get_total': self.get_total, 'get_nettotal': self.get_nettotal, 'get_note': self.get_note, - } - return request.registry['report'].render(self.cr, self.uid, [], 'lunch.report_lunchorder', docargs) + }) + + +class report_lunchorder(osv.AbstractModel): + _name = 'report.lunch.report_lunchorder' + _inherit = 'report.abstract_report' + _template = 'lunch.report_lunchorder' + _wrapped_report_class = order # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/mrp/report/bom_structure.py b/addons/mrp/report/bom_structure.py index 98949ed75dc..1b286feac46 100644 --- a/addons/mrp/report/bom_structure.py +++ b/addons/mrp/report/bom_structure.py @@ -19,22 +19,18 @@ # ############################################################################## +import time from openerp.osv import osv +from openerp.report import report_sxw -class bom_structure(osv.AbstractModel): - _name = 'report.mrp.report_mrpbomstructure' - - def render_html(self, cr, uid, ids, data=None, context=None): - mrpbom_obj = self.pool['mrp.bom'] - report_obj = self.pool['report'] - docs = mrpbom_obj.browse(cr, uid, ids, context=context) - - docargs = { - 'docs': docs, - 'get_children': self.get_children, - } - return report_obj.render(cr, uid, [], 'mrp.report_mrpbomstructure', docargs, context=context) +class bom_structure(report_sxw.rml_parse): + def __init__(self, cr, uid, name, context): + super(bom_structure, self).__init__(cr, uid, name, context=context) + self.localcontext.update({ + 'time': time, + 'get_children':self.get_children, + }) def get_children(self, object, level=0): result = [] @@ -62,4 +58,11 @@ class bom_structure(osv.AbstractModel): return children + +class report_lunchorder(osv.AbstractModel): + _name = 'report.mrp.report_mrpbomstructure' + _inherit = 'report.abstract_report' + _template = 'mpr.report_mrpbomstructure' + _wrapped_report_class = bom_structure + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/report_intrastat/test/report_intrastat_report.yml b/addons/report_intrastat/test/report_intrastat_report.yml index 687f605b901..5c70ba67ef2 100644 --- a/addons/report_intrastat/test/report_intrastat_report.yml +++ b/addons/report_intrastat/test/report_intrastat_report.yml @@ -16,6 +16,6 @@ import os import openerp.report from openerp import tools - data, format = openerp.report.render_report(cr, uid, [ref('test_invoice_1')], 'account.invoice.intrastat', {}, {}) + data, format = openerp.report.render_report(cr, uid, [ref('test_invoice_1')], 'report_intrastat.report_intrastatinvoice', {}, {}) if tools.config['test_report_directory']: file(os.path.join(tools.config['test_report_directory'], 'report_intrastat-intrastat_report.'+format), 'wb+').write(data)