diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py index 343512dc271..95ecdc8c35a 100644 --- a/addons/account/__openerp__.py +++ b/addons/account/__openerp__.py @@ -123,7 +123,9 @@ for a particular financial year and for preparation of vouchers there is a modul 'edi/invoice_action_data.xml', 'account_bank_view.xml', 'res_config_view.xml', - 'account_pre_install.yml' + 'account_pre_install.yml', + + 'views/report_vat.xml', ], 'js': [ 'static/src/js/account_move_reconciliation.js', diff --git a/addons/account/account_report.xml b/addons/account/account_report.xml index 6e121c9f5a5..4f9ad1b5c56 100644 --- a/addons/account/account_report.xml +++ b/addons/account/account_report.xml @@ -27,13 +27,13 @@ + id="action_report_vat" + model="account.tax.code" + report_type="qweb-pdf" + string="Account tax" + name="account.report_vat" + file="account.report_vat" + /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Tax Statement - - - - Chart of Tax - Fiscal Year - Periods - Based On - - - [[ get_account(data) or removeParentNode('para') ]] - [[ get_fiscalyear(data) or '' ]] - - - - Start Period - End Period - - - [[ get_start_period(data) or '' ]] - [[ get_end_period(data) or '' ]] - - - - [[ get_basedon(data) or '' ]] - - - - - - Tax Name - Debit - Credit - Tax Amount - - - [[ repeatIn(get_lines(data['form']['based_on'], data['form']['company_id']), 'o') ]][[ (o['level']) ]] [[ (len(o['level'])<5 and setTag('para','para',{'fontName':'Helvetica-Bold'})) or removeParentNode('font') ]][[ o['code'] ]] [[ o['name'] ]] - [[ len(o['level'])<5 and setTag('para','para',{'fontName':"Helvetica-Bold"}) or removeParentNode('font')]][[ o['type']=='view' and removeParentNode('font') ]][[ formatLang(o['debit']) ]][[ o['type']<>'view' and removeParentNode('font') ]][[ formatLang(o['debit']) ]] - [[ len(o['level'])<5 and setTag('para','para',{'fontName':"Helvetica-Bold"}) or removeParentNode('font')]][[ o['type']=='view' and removeParentNode('font') ]][[ formatLang(o['credit']) ]][[ o['type']<>'view' and removeParentNode('font') ]][[ formatLang(o['credit'])]] - [[ len(o['level'])<5 and setTag('para','para',{'fontName':"Helvetica-Bold"}) or removeParentNode('font')]][[ o['type']=='view' and removeParentNode('font') ]][[ formatLang(o['tax_amount'], currency_obj=company.currency_id) ]][[ o['type']<>'view' and removeParentNode('font') ]][[ formatLang(o['tax_amount'], currency_obj=company.currency_id) ]] - - - - diff --git a/addons/account/report/account_tax_report.py b/addons/account/report/report_vat.py similarity index 85% rename from addons/account/report/account_tax_report.py rename to addons/account/report/report_vat.py index b3cbcb441bf..79eeccac66c 100644 --- a/addons/account/report/account_tax_report.py +++ b/addons/account/report/report_vat.py @@ -19,16 +19,20 @@ # ############################################################################## -import time - +from openerp.addons.web import http +from openerp.addons.web.http import request from common_report_header import common_report_header -from openerp.report import report_sxw -class tax_report(report_sxw.rml_parse, common_report_header): - _name = 'report.account.vat.declaration' - def set_context(self, objects, data, ids, report_type=None): - new_ids = ids +class tax_report(http.Controller, common_report_header): + + @http.route(['/report/account.report_vat'], type='http', auth='user', website=True, multilang=True) + def report_account_tax(self, **data): + report_obj = request.registry['report'] + self.cr, self.uid, self.pool = request.cr, request.uid, request.registry + + data = report_obj.eval_params(data) + res = {} self.period_ids = [] period_obj = self.pool.get('account.period') @@ -38,28 +42,17 @@ class tax_report(report_sxw.rml_parse, 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) - 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, - }) + 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']), + } + return request.registry['report'].render(self.cr, self.uid, [], 'account.report_vat', docargs) + def _get_basedon(self, form): return form['form']['based_on'] @@ -194,7 +187,6 @@ class tax_report(report_sxw.rml_parse, common_report_header): return self.pool.get('res.company').browse(self.cr, self.uid, form['company_id'], context=context).currency_id.name def sort_result(self, accounts, context=None): - # On boucle sur notre rapport result_accounts = [] ind=0 old_level=0 @@ -233,7 +225,4 @@ class tax_report(report_sxw.rml_parse, common_report_header): return result_accounts -report_sxw.report_sxw('report.account.vat.declaration', 'account.tax.code', - 'addons/account/report/account_tax_report.rml', parser=tax_report, header="internal") - # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/views/report_vat.xml b/addons/account/views/report_vat.xml new file mode 100644 index 00000000000..3dd1d0c668e --- /dev/null +++ b/addons/account/views/report_vat.xml @@ -0,0 +1,68 @@ + + + + + + diff --git a/addons/account/wizard/account_vat.py b/addons/account/wizard/account_vat.py index 37bf4b029a6..6fbfcc9ddf5 100644 --- a/addons/account/wizard/account_vat.py +++ b/addons/account/wizard/account_vat.py @@ -46,18 +46,20 @@ class account_vat_declaration(osv.osv_memory): def create_vat(self, cr, uid, ids, context=None): if context is None: context = {} + datas = {'ids': context.get('active_ids', [])} datas['model'] = 'account.tax.code' datas['form'] = self.read(cr, uid, ids, context=context)[0] + for field in datas['form'].keys(): if isinstance(datas['form'][field], tuple): datas['form'][field] = datas['form'][field][0] - datas['form']['company_id'] = self.pool.get('account.tax.code').browse(cr, uid, [datas['form']['chart_tax_id']], context=context)[0].company_id.id - return { - 'type': 'ir.actions.report.xml', - 'report_name': 'account.vat.declaration', - 'datas': datas, - } + taxcode_obj = self.pool.get('account.tax.code') + taxcode_id = datas['form']['chart_tax_id'] + taxcode = taxcode_obj.browse(cr, uid, [taxcode_id], context=context)[0] + datas['form']['company_id'] = taxcode.company_id.id + + return self.pool['report'].get_action(cr, uid, ids, 'account.report_vat', datas=datas, context=context) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: