From e6137ed4ae58b7d365af9ec33f0dab9c4b37a8ac Mon Sep 17 00:00:00 2001 From: "psi (Open ERP)" Date: Wed, 7 Apr 2010 12:11:53 +0530 Subject: [PATCH] [ADD] Account: account_vat and account_print_journal wizard converted to osv memory bzr revid: psi@tinyerp.co.in-20100407064153-y2gna2j3zb2ctlvb --- addons/account/__terp__.py | 3 + addons/account/account_report.xml | 19 ++-- addons/account/account_wizard.xml | 4 +- addons/account/report/account_journal.py | 23 ++--- addons/account/report/tax_report.py | 80 +++++++++-------- addons/account/wizard/__init__.py | 5 +- .../account/wizard/account_print_journal.py | 66 ++++++++++++++ .../wizard/account_print_journal_view.xml | 43 +++++++++ addons/account/wizard/account_vat.py | 65 ++++++++++++++ addons/account/wizard/account_vat_view.xml | 46 ++++++++++ addons/account/wizard/wizard_print_journal.py | 79 ---------------- addons/account/wizard/wizard_vat.py | 90 ------------------- 12 files changed, 296 insertions(+), 227 deletions(-) create mode 100644 addons/account/wizard/account_print_journal.py create mode 100644 addons/account/wizard/account_print_journal_view.xml create mode 100755 addons/account/wizard/account_vat.py create mode 100644 addons/account/wizard/account_vat_view.xml delete mode 100644 addons/account/wizard/wizard_print_journal.py delete mode 100755 addons/account/wizard/wizard_vat.py diff --git a/addons/account/__terp__.py b/addons/account/__terp__.py index bd39518d5c1..b08fec5835b 100644 --- a/addons/account/__terp__.py +++ b/addons/account/__terp__.py @@ -56,6 +56,9 @@ module named account_voucherss 'account_wizard.xml', 'wizard/account_open_closed_fiscalyear_view.xml', 'wizard/account_move_line_unreconcile_select_view.xml', + 'wizard/account_vat_view.xml', + 'wizard/account_print_journal_view.xml', + 'wizard/account_subscription_generate_view.xml', 'project/wizard/project_account_analytic_line_view.xml', 'account_view.xml', diff --git a/addons/account/account_report.xml b/addons/account/account_report.xml index 5c99ebdde13..9d449f116f4 100644 --- a/addons/account/account_report.xml +++ b/addons/account/account_report.xml @@ -24,25 +24,33 @@ - + - - --> + + @@ -66,6 +74,7 @@ rml="account/report/compare_account_balance.rml" auto="False" menu="False"/> + - - + diff --git a/addons/account/report/account_journal.py b/addons/account/report/account_journal.py index 830f8152120..5b8418be430 100644 --- a/addons/account/report/account_journal.py +++ b/addons/account/report/account_journal.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,19 +15,19 @@ # 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 . +# along with this program. If not, see . # ############################################################################## - import time + from report import report_sxw # # Use period and Journal for selection or resources # class journal_print(report_sxw.rml_parse): - def __init__(self, cr, uid, name, context): + def __init__(self, cr, uid, name, context={}): super(journal_print, self).__init__(cr, uid, name, context=context) self.localcontext.update( { 'time': time, @@ -37,11 +37,13 @@ class journal_print(report_sxw.rml_parse): }) def lines(self, period_id, journal_id, sort_selection='date', *args): - if type(period_id)==type([]): + obj_jperiod = self.pool.get('account.journal.period') + obj_mline = self.pool.get('account.move.line') + if type(period_id) == type([]): ids_final = [] for journal in journal_id: for period in period_id: - ids_journal_period = self.pool.get('account.journal.period').search(self.cr,self.uid, [('journal_id','=',journal),('period_id','=',period)]) + ids_journal_period = obj_jperiod.search(self.cr, self.uid, [('journal_id','=',journal), ('period_id','=',period)]) if ids_journal_period: self.cr.execute('update account_journal_period set state=%s where journal_id=%s and period_id=%s and state=%s', ('printed',journal,period,'draft')) self.cr.commit() @@ -50,14 +52,14 @@ class journal_print(report_sxw.rml_parse): ids_final.append(ids) line_ids = [] for line_id in ids_final: - a = self.pool.get('account.move.line').browse(self.cr, self.uid, line_id ) + a = obj_mline.browse(self.cr, self.uid, line_id) line_ids.append(a) return line_ids self.cr.execute('update account_journal_period set state=%s where journal_id=%s and period_id=%s and state=%s', ('printed',journal_id,period_id,'draft')) self.cr.commit() self.cr.execute('select id from account_move_line where period_id=%s and journal_id=%s and state<>\'draft\' order by date,id', (period_id, journal_id)) ids = map(lambda x: x[0], self.cr.fetchall()) - return self.pool.get('account.move.line').browse(self.cr, self.uid, ids ) + return obj_mline.browse(self.cr, self.uid, ids) def _sum_debit(self, period_id, journal_id): self.cr.execute('select sum(debit) from account_move_line where period_id=%s and journal_id=%s and state<>\'draft\'', (period_id, journal_id)) @@ -66,8 +68,9 @@ class journal_print(report_sxw.rml_parse): def _sum_credit(self, period_id, journal_id): self.cr.execute('select sum(credit) from account_move_line where period_id=%s and journal_id=%s and state<>\'draft\'', (period_id, journal_id)) return self.cr.fetchone()[0] or 0.0 -report_sxw.report_sxw('report.account.journal.period.print', 'account.journal.period', 'addons/account/report/account_journal.rml', parser=journal_print,header=False) -report_sxw.report_sxw('report.account.journal.period.print.wiz', 'account.journal.period', 'addons/account/report/wizard_account_journal.rml', parser=journal_print,header=False) + +report_sxw.report_sxw('report.account.journal.period.print', 'account.journal.period', 'addons/account/report/account_journal.rml', parser=journal_print, header=False) +report_sxw.report_sxw('report.account.journal.period.print.wiz', 'account.journal.period', 'addons/account/report/wizard_account_journal.rml', parser=journal_print, header=False) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/report/tax_report.py b/addons/account/report/tax_report.py index 3910622ad68..daa010a0453 100644 --- a/addons/account/report/tax_report.py +++ b/addons/account/report/tax_report.py @@ -20,16 +20,15 @@ ############################################################################## import time -import pooler -import rml_parse import copy + +import rml_parse from report import report_sxw -import pdb -import re class tax_report(rml_parse.rml_parse): _name = 'report.account.vat.declaration' - def __init__(self, cr, uid, name, context): + def __init__(self, cr, uid, name, context={}): + print "tax______init", name, context super(tax_report, self).__init__(cr, uid, name, context=context) self.localcontext.update({ 'time': time, @@ -42,19 +41,19 @@ class tax_report(rml_parse.rml_parse): }) - def _get_lines(self, based_on,period_list,company_id=False, parent=False, level=0): - res = self._get_codes(based_on,company_id,parent,level,period_list) + def _get_lines(self, based_on, period_list, company_id=False, parent=False, level=0, context={}): + res = self._get_codes(based_on, company_id, parent, level, period_list, context=context) - if period_list[0][2] : - res = self._add_codes(based_on,res,period_list) + if period_list: + res = self._add_codes(based_on, res, period_list, context=context) else : 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[0][2].append(p[0]) - res = self._add_codes(based_on,res,period_list) + period_list.append(p[0]) + res = self._add_codes(based_on, res, period_list, context=context) i = 0 top_result = [] @@ -71,7 +70,7 @@ class tax_report(rml_parse.rml_parse): } top_result.append(res_dict) - res_general = self._get_general(res[i][1].id,period_list,company_id,based_on) + 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 @@ -84,11 +83,12 @@ class tax_report(rml_parse.rml_parse): return top_result #return array_result - def _get_period(self, period_id): - return self.pool.get('account.period').browse(self.cr, self.uid, period_id).name + def _get_period(self, period_id, context={}): + return self.pool.get('account.period').browse(self.cr, self.uid, period_id, context=context).name - def _get_general(self, tax_code_id,period_list ,company_id, based_on): + def _get_general(self, tax_code_id,period_list ,company_id, based_on, context={}): res=[] + obj_account = self.pool.get('account.account') if based_on == 'payments': self.cr.execute('SELECT SUM(line.tax_amount) AS tax_amount, \ SUM(line.debit) AS debit, \ @@ -110,8 +110,8 @@ class tax_report(rml_parse.rml_parse): AND line.period_id =ANY(%s) \ AND ((invoice.state = %s) \ OR (invoice.id IS NULL)) \ - GROUP BY account.id,account.name,account.code', ('draft',tax_code_id, - company_id, period_list[0][2],'paid',)) + GROUP BY account.id,account.name,account.code', ('draft', tax_code_id, + company_id, period_list, 'paid',)) else : self.cr.execute('SELECT SUM(line.tax_amount) AS tax_amount, \ @@ -129,52 +129,54 @@ class tax_report(rml_parse.rml_parse): AND account.company_id = %s \ AND line.period_id =ANY(%s)\ AND account.active \ - GROUP BY account.id,account.name,account.code', ('draft',tax_code_id, - company_id,period_list[0][2],)) + GROUP BY account.id,account.name,account.code', ('draft', tax_code_id, + company_id, period_list,)) res = self.cr.dictfetchall() #AND line.period_id IN ('+ period_sql_list +') \ i = 0 while i= int(accounts[bcl_rup_ind]['level']) and bcl_rup_ind >= 0 ): - tot_elem = copy.copy(accounts[bcl_rup_ind]) + tot_elem = copy.copy(accounts[bcl_rup_ind], context=context) res_tot = { 'code' : accounts[bcl_rup_ind]['code'], 'name' : '', 'debit' : 0, @@ -218,6 +220,6 @@ class tax_report(rml_parse.rml_parse): report_sxw.report_sxw('report.account.vat.declaration', 'account.tax.code', - 'addons/account/report/tax_report.rml', parser=tax_report, header=False) + 'addons/account/report/tax_report.rml', parser=tax_report, header=True) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/__init__.py b/addons/account/wizard/__init__.py index ffd08dae608..37aa1672823 100644 --- a/addons/account/wizard/__init__.py +++ b/addons/account/wizard/__init__.py @@ -38,8 +38,9 @@ import wizard_partner_balance_report import account_period_close import wizard_fiscalyear_close import account_fiscalyear_close_state +import account_vat import account_open_closed_fiscalyear -import wizard_vat + import wizard_compare_account_balance_report import wizard_invoice_state import wizard_account_duplicate @@ -52,7 +53,7 @@ import wizard_use_model import wizard_state_open import wizard_statement_from_invoice -import wizard_print_journal +import account_print_journal import wizard_central_journal import wizard_general_journal import wizard_change_currency diff --git a/addons/account/wizard/account_print_journal.py b/addons/account/wizard/account_print_journal.py new file mode 100644 index 00000000000..25d06ef40be --- /dev/null +++ b/addons/account/wizard/account_print_journal.py @@ -0,0 +1,66 @@ +# -*- 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_print_journal(osv.osv_memory): + _name = 'account.print.journal' + _description = 'Account Print Journal' + + _columns = { + 'journal_id': fields.many2many('account.journal', 'account_journal_rel', 'account_id', 'journal_id', 'Journals', required=True), + 'period_id': fields.many2many('account.period', 'account_period_rel', 'account_id', 'period_id', 'Periods', required=True), + 'sort_selection': fields.selection([('date','By date'), + ('ref','Reference Number'),], + 'Entries Sorted By', required=True), + } + + _defaults = { + 'sort_selection': lambda *a: 'date', + } + + def check_data(self, cr, uid, ids, context={}): + obj_jperiod = self.pool.get('account.journal.period') + datas = {} + datas['ids'] = [] + datas['model'] = 'account.journal.period' + datas['form'] = self.read(cr, uid, ids)[0] + period_id = datas['form']['period_id'] + journal_id = datas['form']['journal_id'] + + if type(period_id)==type([]): + ids_final = [] + for journal in journal_id: + for period in period_id: + ids_journal_period = obj_jperiod.search(cr,uid, [('journal_id','=',journal),('period_id','=',period)], context=context) + if ids_journal_period: + ids_final.append(ids_journal_period) + if not ids_final: + raise osv.except_osv(_('No Data Available'), _('No records found for your selection!')) + return { + 'type': 'ir.actions.report.xml', + 'report_name': 'account.journal.period.print', + 'datas': datas, + } + +account_print_journal() + +#vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/account_print_journal_view.xml b/addons/account/wizard/account_print_journal_view.xml new file mode 100644 index 00000000000..078db421b19 --- /dev/null +++ b/addons/account/wizard/account_print_journal_view.xml @@ -0,0 +1,43 @@ + + + + + + Account Print Journal + account.print.journal + form + +
+ + + + + + + + +