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
+
+
+
+
+
+
+ Account Print Journal
+ ir.actions.act_window
+ account.print.journal
+ form
+ form
+ new
+
+
+
+
+
+
\ 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
index 00000000000..6ff6d59f41c
--- /dev/null
+++ b/addons/account/wizard/account_vat.py
@@ -0,0 +1,65 @@
+# -*- 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_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
index 00000000000..edd6eaf7874
--- /dev/null
+++ b/addons/account/wizard/account_vat_view.xml
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+ Account Vat Declaration
+ account.vat.declaration
+ form
+
+
+
+
+
+
+ Account Vat Declaration
+ ir.actions.act_window
+ account.vat.declaration
+ form
+ form
+ new
+
+
+
+
+
+
diff --git a/addons/account/wizard/wizard_print_journal.py b/addons/account/wizard/wizard_print_journal.py
deleted file mode 100644
index 8cd95608256..00000000000
--- a/addons/account/wizard/wizard_print_journal.py
+++ /dev/null
@@ -1,79 +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 wizard
-import pooler
-from tools.translate import _
-
-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
index 6c14402c701..00000000000
--- a/addons/account/wizard/wizard_vat.py
+++ /dev/null
@@ -1,90 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
-
-import time
-import wizard
-import pooler
-
-dates_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: