[ADD] Account: account_vat and account_print_journal wizard converted to osv memory
authorpsi (Open ERP) <psi@tinyerp.co.in>
Wed, 7 Apr 2010 06:41:53 +0000 (12:11 +0530)
committerpsi (Open ERP) <psi@tinyerp.co.in>
Wed, 7 Apr 2010 06:41:53 +0000 (12:11 +0530)
bzr revid: psi@tinyerp.co.in-20100407064153-y2gna2j3zb2ctlvb

12 files changed:
addons/account/__terp__.py
addons/account/account_report.xml
addons/account/account_wizard.xml
addons/account/report/account_journal.py
addons/account/report/tax_report.py
addons/account/wizard/__init__.py
addons/account/wizard/account_print_journal.py [new file with mode: 0644]
addons/account/wizard/account_print_journal_view.xml [new file with mode: 0644]
addons/account/wizard/account_vat.py [new file with mode: 0755]
addons/account/wizard/account_vat_view.xml [new file with mode: 0644]
addons/account/wizard/wizard_print_journal.py [deleted file]
addons/account/wizard/wizard_vat.py [deleted file]

index bd39518..b08fec5 100644 (file)
@@ -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',
index 5c99ebd..9d449f1 100644 (file)
 
         <report id="account_move_line_list" model="account.tax.code" name="account.tax.code.entries" rml="account/report/account_tax_code.rml" string="All Entries"/>
 
-        <report auto="False" id="account_vat_declaration" menu="False" model="account.tax.code" name="account.vat.declaration" rml="account/report/tax_report.rml" string="Taxes Report"/>
+        <report
+               auto="False"
+               id="account_vat_declaration"
+               menu="False"
+               model="account.tax.code"
+               name="account.vat.declaration"
+               rml="account/report/tax_report.rml"
+               string="Taxes Report"/>
 
         <menuitem
             id="menu_tax_report"
             name="Taxes"
             parent="account.menu_finance_generic_reporting" sequence="3"/>
 
-        <wizard
+<!--        <wizard
             id="wizard_vat_declaration"
             menu="False"
             model="account.tax.code"
             name="account.vat.declaration"
-            string="Print Taxes Report"/>
-        <menuitem
+            string="Print Taxes Report"/> -->
+
+<!--        <menuitem
             icon="STOCK_PRINT"
             action="wizard_vat_declaration"
             id="menu_wizard_vat_declaration"
             parent="menu_tax_report"
-            type="wizard"/>
+            type="wizard"/> -->
 
 
         <record id="action_tax_code_tree" model="ir.actions.act_window">
@@ -66,6 +74,7 @@
                        rml="account/report/compare_account_balance.rml"
                        auto="False"
                        menu="False"/>
+
                <report id="account_account_balance_landscape"
                        string="Account balance"
                        model="account.account"
index 5ee4643..0a72815 100644 (file)
                <wizard id="wizard_general_ledger" menu="False" model="account.account" name="account.general.ledger.report" string="General Ledger"/>
         <menuitem icon="STOCK_PRINT" action="wizard_general_ledger" id="menu_general_ledger" parent="account.menu_generic_report" type="wizard"/>
 
-        <wizard id="wizard_print_journal" menu="False" model="account.journal.period" name="account.print.journal.report" string="Print Journal" />
-               <menuitem icon="STOCK_PRINT" action="wizard_print_journal" id="menu_print_journal" parent="account.menu_generic_report" type="wizard" />
+<!--        <wizard id="wizard_print_journal" menu="False" model="account.journal.period" name="account.print.journal.report" string="Print Journal" />
+               <menuitem icon="STOCK_PRINT" action="wizard_print_journal" id="menu_print_journal" parent="account.menu_generic_report" type="wizard" />-->
 
         <wizard id="wizard_central_journal" menu="False" model="account.journal.period" name="account.central.journal.report" string="Print Central Journal" />
                <menuitem icon="STOCK_PRINT" action="wizard_central_journal" id="menu_central_journal" parent="account.menu_generic_report" type="wizard" />
index 830f815..5b8418b 100644 (file)
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 ##############################################################################
-#    
+#
 #    OpenERP, Open Source Management Solution
 #    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
 #
 #    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 <http://www.gnu.org/licenses/>.     
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
 
-
 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:
 
index 3910622..daa010a 100644 (file)
 ##############################################################################
 
 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<len(res):
-                       res[i]['account'] = self.pool.get('account.account').browse(self.cr, self.uid, res[i]['account_id'])
+                       res[i]['account'] = obj_account.browse(self.cr, self.uid, res[i]['account_id'], context=context)
                        i+=1
                return res
 
-       def _get_codes(self,based_on, company_id, parent=False, level=0,period_list=[]):
-               tc = self.pool.get('account.tax.code')
-               ids = tc.search(self.cr, self.uid, [('parent_id','=',parent),('company_id','=',company_id)])
+       def _get_codes(self, based_on, company_id, parent=False, level=0, period_list=[], context={}):
+               obj_tc = self.pool.get('account.tax.code')
+               ids = obj_tc.search(self.cr, self.uid, [('parent_id','=',parent),('company_id','=',company_id)], context=context)
 
                res = []
-               for code in tc.browse(self.cr, self.uid, ids, {'based_on': based_on}):
-                       res.append(('.'*2*level,code))
+               for code in obj_tc.browse(self.cr, self.uid, ids, {'based_on': based_on}):
+                       res.append(('.'*2*level, code))
 
-                       res += self._get_codes(based_on, company_id, code.id, level+1)
+                       res += self._get_codes(based_on, company_id, code.id, level+1, context=context)
                return res
 
-       def _add_codes(self,based_on, account_list=[],period_list=[]):
+       def _add_codes(self, based_on, account_list=[], period_list=[], context={}):
                res = []
+               obj_tc = self.pool.get('account.tax.code')
                for account in account_list:
-                       tc = self.pool.get('account.tax.code')
-                       ids = tc.search(self.cr, self.uid, [('id','=',account[1].id)])
+                       ids = obj_tc.search(self.cr, self.uid, [('id','=', account[1].id)], context=context)
                        sum_tax_add = 0
-                       for period_ind in period_list[0][2]:
-                               for code in tc.browse(self.cr, self.uid, ids, {'period_id':period_ind,'based_on': based_on}):
+                       for period_ind in period_list:
+                               for code in obj_tc.browse(self.cr, self.uid, ids, {'period_id':period_ind,'based_on': based_on}):
                                        sum_tax_add = sum_tax_add + code.sum_period
 
                        code.sum_period = sum_tax_add
 
-                       res.append((account[0],code))
+                       res.append((account[0], code))
                return res
 
 
-       def _get_company(self, form):
-               return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).name
+       def _get_company(self, form, context={}):
+               obj_company = self.pool.get('res.company')
+               return obj_company.browse(self.cr, self.uid, form['company_id'], context=context).name
 
-       def _get_currency(self, form):
-               return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).currency_id.name
+       def _get_currency(self, form, context={}):
+               obj_company = self.pool.get('res.company')
+               return obj_company.browse(self.cr, self.uid, form['company_id'], context=context).currency_id.name
 
-       def sort_result(self,accounts):
+       def sort_result(self, accounts, context={}):
                # On boucle sur notre rapport
                result_accounts = []
                ind=0
@@ -191,7 +193,7 @@ class tax_report(rml_parse.rml_parse):
                                bcl_rup_ind = ind - 1
 
                                while (bcl_current_level >= 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:
index ffd08da..37aa167 100644 (file)
@@ -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 (file)
index 0000000..25d06ef
--- /dev/null
@@ -0,0 +1,66 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+#    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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+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 (file)
index 0000000..078db42
--- /dev/null
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+
+               <record id="view_account_print_journal" model="ir.ui.view">
+            <field name="name">Account Print Journal</field>
+            <field name="model">account.print.journal</field>
+            <field name="type">form</field>
+            <field name="arch" type="xml">
+                       <form string="Print Journal">
+                           <group col="4" colspan="6">
+                                   <field name="journal_id"/>
+                                   <field name="period_id"/>
+                                   <newline/>
+                                   <field name="sort_selection"/>
+                               </group>
+                               <separator colspan="4"/>
+                           <group col="2" colspan="4">
+                               <button special="cancel"  string="Cancel" icon='gtk-cancel'/>
+                                               <button name="check_data" string="Print" colspan="1" type="object" icon="gtk-ok"/>
+                               </group>
+                       </form>
+            </field>
+        </record>
+
+        <record id="action_account_print_journal" model="ir.actions.act_window">
+            <field name="name">Account Print Journal</field>
+            <field name="type">ir.actions.act_window</field>
+            <field name="res_model">account.print.journal</field>
+            <field name="view_type">form</field>
+            <field name="view_mode">form</field>
+            <field name="target">new</field>
+        </record>
+
+               <menuitem
+               name="Print Journal"
+               parent="account.menu_generic_report"
+               action="action_account_print_journal"
+               id="menu_account_print_journal"
+               icon="STOCK_PRINT"/>
+
+       </data>
+</openerp>
\ No newline at end of file
diff --git a/addons/account/wizard/account_vat.py b/addons/account/wizard/account_vat.py
new file mode 100755 (executable)
index 0000000..6ff6d59
--- /dev/null
@@ -0,0 +1,65 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+#    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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from osv import osv, fields
+
+class account_vat_declaration(osv.osv_memory):
+       _name = 'account.vat.declaration'
+       _description = 'Account Vat Declaration'
+
+       _columns = {
+        'based_on': fields.selection([('invoices','Invoices'),
+                                                                        ('payments','Payments'),],
+                                                                         'Based On', required=True),
+        'company_id': fields.many2one('res.company', 'Company', required=True),
+               'periods': fields.many2many('account.period', 'vat_period_rel', 'vat_id', 'period_id', 'Periods', help="All periods if empty"),
+               }
+
+       def _get_company(self, cr, uid, ids, context={}):
+               user_obj = self.pool.get('res.users')
+               company_obj = self.pool.get('res.company')
+               user = user_obj.browse(cr, uid, uid, context=context)
+               if user.company_id:
+                       return user.company_id.id
+               else:
+                       return company_obj.search(cr, uid, [('parent_id', '=', False)])[0]
+
+       _defaults = {
+               'based_on': lambda *a: 'invoices',
+               'company_id': _get_company
+           }
+
+       def create_vat(self, cr, uid, ids, context={}):
+               if context is None:
+                       context = {}
+               datas = {'ids': context.get('active_ids', [])}
+               datas['model'] = 'account.tax.code'
+               datas['form'] = self.read(cr, uid, ids)[0]
+               print "datasssss", datas, datas['form']
+               return {
+                       'type': 'ir.actions.report.xml',
+                       'report_name': 'account.vat.declaration',
+                       'datas': datas,
+                       }
+
+account_vat_declaration()
+
+#vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account/wizard/account_vat_view.xml b/addons/account/wizard/account_vat_view.xml
new file mode 100644 (file)
index 0000000..edd6eaf
--- /dev/null
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+
+        <menuitem
+            id="menu_tax_report"
+            name="Taxes"
+            parent="account.menu_finance_generic_reporting" sequence="3"/>
+
+               <record id="view_account_vat_declaration" model="ir.ui.view">
+            <field name="name">Account Vat Declaration</field>
+            <field name="model">account.vat.declaration</field>
+            <field name="type">form</field>
+            <field name="arch" type="xml">
+                       <form string="Select Period">
+                                   <field name="company_id"/>
+                                       <newline/>
+                                   <field name="based_on"/>
+                                   <newline/>
+                                   <field name="periods"/>
+                           <group col="2" colspan="4">
+                               <button icon='gtk-cancel' special="cancel"  string="Cancel" />
+                                               <button name="create_vat" string="Print VAT Decl." colspan="1" type="object" icon="gtk-ok"/>
+                               </group>
+                       </form>
+            </field>
+        </record>
+
+        <record id="action_account_vat_declaration" model="ir.actions.act_window">
+            <field name="name">Account Vat Declaration</field>
+            <field name="type">ir.actions.act_window</field>
+            <field name="res_model">account.vat.declaration</field>
+            <field name="view_type">form</field>
+            <field name="view_mode">form</field>
+            <field name="target">new</field>
+        </record>
+
+               <menuitem
+               name="Print Taxes Report"
+               parent="menu_tax_report"
+               action="action_account_vat_declaration"
+               id="menu_account_vat_declaration"
+               icon="STOCK_PRINT"/>
+
+       </data>
+</openerp>
diff --git a/addons/account/wizard/wizard_print_journal.py b/addons/account/wizard/wizard_print_journal.py
deleted file mode 100644 (file)
index 8cd9560..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#    
-#    OpenERP, Open Source Management Solution
-#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
-#
-#    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 <http://www.gnu.org/licenses/>.     
-#
-##############################################################################
-
-import wizard
-import pooler
-from tools.translate import _
-
-form = '''<?xml version="1.0"?>
-<form string="Print Journal">
-    <field name="journal_id"/>
-    <field name="period_id"/>
-    <field name="sort_selection"/>
-</form>'''
-
-fields = {
-  'journal_id': {'string': 'Journal', 'type': 'many2many', 'relation': 'account.journal', 'required': True},
-  'period_id': {'string': 'Period', 'type': 'many2many', 'relation': 'account.period', 'required': True},
-  'sort_selection':{
-        'string':"Entries Sorted By",
-        'type':'selection',
-        'selection':[('date','By date'),('ref','Reference Number')],
-        'required':True,
-        'default': lambda *a: 'date',
-    },
-
-}
-
-def _check_data(self, cr, uid, data, *args):
-    period_id = data['form']['period_id'][0][2]
-    journal_id=data['form']['journal_id'][0][2]
-
-    if type(period_id)==type([]):
-        
-        ids_final = []
-
-        for journal in journal_id:
-            for period in period_id:
-                ids_journal_period = pooler.get_pool(cr.dbname).get('account.journal.period').search(cr,uid, [('journal_id','=',journal),('period_id','=',period)])
-
-                if ids_journal_period:
-                    ids_final.append(ids_journal_period)
-
-            if not ids_final:
-                raise wizard.except_wizard(_('No Data Available'), _('No records found for your selection!'))
-    return data['form']
-
-class wizard_print_journal(wizard.interface):
-    states = {
-        'init': {
-            'actions': [],
-            'result': {'type': 'form', 'arch': form, 'fields': fields, 'state': (('end', 'Cancel', 'gtk-cancel'), ('print', 'Print', 'gtk-ok'))},
-        },
-        'print': {
-            'actions': [_check_data],
-            'result': {'type':'print', 'report':'account.journal.period.print.wiz', 'state':'end'},
-        },
-    }
-wizard_print_journal('account.print.journal.report')
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/account/wizard/wizard_vat.py b/addons/account/wizard/wizard_vat.py
deleted file mode 100755 (executable)
index 6c14402..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#    
-#    OpenERP, Open Source Management Solution
-#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
-#
-#    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 <http://www.gnu.org/licenses/>.     
-#
-##############################################################################
-
-import time
-import wizard
-import pooler
-
-dates_form = '''<?xml version="1.0"?>
-<form string="Select period">
-       <field name="company_id"/>
-       <newline/>
-       <field name="based_on"/>
-       <field name="periods" colspan="4"/>
-
-       
-</form>'''
-
-dates_fields = {
-       'company_id': {'string': 'Company', 'type': 'many2one',
-               'relation': 'res.company', 'required': True},
-       'based_on':{'string':'Base on', 'type':'selection', 'selection':[
-                       ('invoices','Invoices'),
-                       ('payments','Payments'),
-                       ], 'required':True, 'default': lambda *a: 'invoices'},
-       'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty'},
-
-}
-
-
-class wizard_report(wizard.interface):
-
-       def _get_defaults(self, cr, uid, data, context):
-               pool = pooler.get_pool(cr.dbname)
-               period_obj = pool.get('account.period')
-
-               user = pool.get('res.users').browse(cr, uid, uid, context=context)
-               if user.company_id:
-                       company_id = user.company_id.id
-               else:
-                       company_id = pool.get('res.company').search(cr, uid,
-                                       [('parent_id', '=', False)])[0]
-               data['form']['company_id'] = company_id
-
-               return data['form']
-
-       states = {
-               'init': {
-                       'actions': [_get_defaults],
-                       'result': {
-                               'type': 'form',
-                               'arch': dates_form,
-                               'fields': dates_fields,
-                               'state': [
-                                       ('end', 'Cancel', 'gtk-cancel'),
-                                       ('report', 'Print VAT Decl.', 'gtk-ok')
-                               ]
-                       }
-               },
-               'report': {
-                       'actions': [],
-                       'result': {
-                               'type': 'print',
-                               'report': 'account.vat.declaration',
-                               'state':'end'
-                       }
-               }
-       }
-
-wizard_report('account.vat.declaration')
-
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: