diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py index 1ff58367b47..abd3d1f459d 100644 --- a/addons/account/__openerp__.py +++ b/addons/account/__openerp__.py @@ -46,14 +46,18 @@ module named account_voucherss 'security/account_security.xml', 'security/ir.model.access.csv', 'account_menuitem.xml', + 'account_wizard.xml', + 'wizard/account_statement_from_invoice_view.xml', + 'wizard/account_move_bank_reconcile_view.xml', + 'wizard/account_use_model_view.xml', + 'account_view.xml', + 'account_report.xml', 'wizard/account_invoice_refund_view.xml', 'wizard/account_period_close_view.xml', 'wizard/account_fiscalyear_close_state.xml', 'wizard/account_chart_view.xml', - 'wizard/account_move_bank_reconcile_view.xml', - 'wizard/account_move_line_reconcile_select_view.xml', 'wizard/account_move_journal_view.xml', - 'account_wizard.xml', + 'wizard/account_move_line_reconcile_select_view.xml', 'wizard/account_open_closed_fiscalyear_view.xml', 'wizard/account_move_line_unreconcile_select_view.xml', 'wizard/account_vat_view.xml', @@ -66,17 +70,19 @@ module named account_voucherss 'wizard/account_journal_select_view.xml', 'wizard/account_change_currency_view.xml', 'wizard/account_validate_move_view.xml', - 'wizard/account_statement_from_invoice_view.xml', 'wizard/account_pay_invoice_view.xml', 'wizard/account_unreconcile_view.xml', + 'wizard/account_general_ledger_report_view.xml', 'wizard/account_invoice_state_view.xml', - 'wizard/account_use_model_view.xml', 'wizard/account_partner_balance_report_view.xml', + 'wizard/account_balance_report_view.xml', + 'wizard/account_move_line_select_view.xml', + 'wizard/account_aged_trial_balance_view.xml', + 'wizard/account_compare_account_balance_report_view.xml', + 'wizard/account_third_party_ledger.xml', 'project/wizard/project_account_analytic_line_view.xml', - 'account_view.xml', 'account_end_fy.xml', 'account_invoice_view.xml', - 'account_report.xml', 'partner_view.xml', 'data/account_invoice.xml', 'data/account_data2.xml', @@ -93,17 +99,16 @@ module named account_voucherss 'account_installer.xml', 'report/account_invoice_report_view.xml', 'report/account_report_view.xml', + 'report/account_analytic_report_view.xml', ], 'demo_xml': [ + #'demo/price_accuracy00.yml', 'account_demo.xml', 'project/project_demo.xml', 'project/analytic_account_demo.xml', 'demo/account_minimal.xml', 'account_unit_test.xml', ], - 'test': [ - 'test/price_accuracy00.yml', - ], 'installable': True, 'active': False, 'certificate': '0080331923549', diff --git a/addons/account/account.py b/addons/account/account.py index 12868487c49..b7dcb6a3b8d 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -291,7 +291,7 @@ class account_account(osv.osv): "special effects in Open ERP: view can not have entries, consolidation are accounts that "\ "can have children accounts for multi-company consolidations, payable/receivable are for "\ "partners accounts (for debit/credit computations), closed for depreciated accounts."), - 'user_type': fields.many2one('account.account.type', 'Account Type', required=True, + 'user_type': fields.many2one('account.account.type', 'Account Type', required=True, help="These types are defined according to your country. The type contains more information "\ "about the account and its specificities."), 'parent_id': fields.many2one('account.account', 'Parent', ondelete='cascade'), @@ -437,18 +437,18 @@ class account_account(osv.osv): elif method == 'unlink': raise osv.except_osv(_('Error !'), _('You cannot remove an account which has account entries!. ')) return True - + def write(self, cr, uid, ids, vals, context=None): if not context: context = {} if 'active' in vals and not vals['active']: self._check_moves(cr, uid, ids, "write", context) return super(account_account, self).write(cr, uid, ids, vals, context=context) - + def unlink(self, cr, uid, ids, context={}): self._check_moves(cr, uid, ids, "unlink", context) return super(account_account, self).unlink(cr, uid, ids, context) - + account_account() class account_journal_view(osv.osv): @@ -791,7 +791,7 @@ class account_move(osv.osv): for id in ids: result.setdefault(id, 0.0) return result - + def _search_amount(self, cr, uid, obj, name, args, context): ids = [] cr.execute('select move_id,sum(debit) from account_move_line group by move_id') @@ -801,10 +801,10 @@ class account_move(osv.osv): if item[1] == '>=': res = [('id', 'in', [k for k,v in result.iteritems() if v >= item[2]])] else: - res = [('id', 'in', [k for k,v in result.iteritems() if v <= item[2]])] + res = [('id', 'in', [k for k,v in result.iteritems() if v <= item[2]])] ids += res - if not ids: + if not ids: return [('id', '>', '0')] return ids @@ -1056,7 +1056,13 @@ class account_move(osv.osv): if line.account_id.currency_id.id != line.currency_id.id and (line.account_id.currency_id.id != line.account_id.company_id.currency_id.id or line.currency_id): raise osv.except_osv(_('Error'), _("""Couldn't create move with currency different from the secondary currency of the account "%s - %s". Clear the secondary currency field of the account definition if you want to accept all currencies.""" % (line.account_id.code, line.account_id.name))) - if abs(amount) < 0.0001: + # Check that the move balances, the tolerance for debit/credit must + # be smaller than the smallest value according to price accuracy + # (hence the +1 below) + # Example: + # difference == 0.01 is OK iff price_accuracy <= 1! + # difference == 0.0001 is OK iff price_accuracy <= 3! + if abs(amount) < 10 ** -(int(config['price_accuracy'])): if not len(line_draft_ids): continue self.pool.get('account.move.line').write(cr, uid, line_draft_ids, { @@ -1126,7 +1132,7 @@ class account_move_reconcile(osv.osv): 'name': lambda self,cr,uid,ctx={}: self.pool.get('ir.sequence').get(cr, uid, 'account.reconcile') or '/', } def reconcile_partial_check(self, cr, uid, ids, type='auto', context={}): - total = 0.0 + total = 0.0 for rec in self.browse(cr, uid, ids, context): for line in rec.line_partial_ids: total += (line.debit or 0.0) - (line.credit or 0.0) @@ -1880,7 +1886,7 @@ account_account_template() class account_add_tmpl_wizard(osv.osv_memory): """Add one more account from the template. - + With the 'nocreate' option, some accounts may not be created. Use this to add them later.""" _name = 'account.addtmpl.wizard' @@ -1906,7 +1912,7 @@ class account_add_tmpl_wizard(osv.osv_memory): _defaults = { 'cparent_id': _get_def_cparent, } - + def action_create(self,cr,uid,ids,context=None): acc_obj=self.pool.get('account.account') tmpl_obj=self.pool.get('account.account.template') @@ -1933,7 +1939,7 @@ class account_add_tmpl_wizard(osv.osv_memory): # print "Creating:", vals new_account = acc_obj.create(cr,uid,vals) return {'type':'state', 'state': 'end' } - + def action_cancel(self,cr,uid,ids,context=None): return { 'type': 'state', 'state': 'end' } diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index a386901a083..9ace27294fa 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -1382,14 +1382,14 @@ [('account_id','child_of', [active_id]),('state','<>','draft')] {'account_id':active_id} - - - - - Account Entries - - - + + + + + + + + diff --git a/addons/account/account_wizard.xml b/addons/account/account_wizard.xml index e5825f6b2da..cdd14780256 100644 --- a/addons/account/account_wizard.xml +++ b/addons/account/account_wizard.xml @@ -1,12 +1,12 @@ - + + + + + + @@ -71,19 +71,21 @@ --> - - - + - + + + + + - - @@ -105,11 +107,11 @@ - - + + - - + + + + + + @@ -44,60 +50,85 @@ - - + + + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + @@ -110,6 +141,7 @@ account.invoice.report form tree,graph + {'search_default_month':1,'search_default_User':1,'group_by_no_leaf':1,'group_by':[]} diff --git a/addons/account/report/aged_trial_balance.py b/addons/account/report/aged_trial_balance.py index c13ea96ea50..26e24031c3a 100644 --- a/addons/account/report/aged_trial_balance.py +++ b/addons/account/report/aged_trial_balance.py @@ -18,8 +18,8 @@ # along with this program. If not, see . # ############################################################################## - import time + import pooler import rml_parse from report import report_sxw @@ -45,7 +45,6 @@ class aged_trial_report(rml_parse.rml_parse): def _get_lines(self, form): - if (form['result_selection'] == 'customer' ): self.ACCOUNT_TYPE = ['receivable'] elif (form['result_selection'] == 'supplier'): diff --git a/addons/account/report/compare_account_balance.py b/addons/account/report/compare_account_balance.py index 52205055298..28054377834 100755 --- a/addons/account/report/compare_account_balance.py +++ b/addons/account/report/compare_account_balance.py @@ -368,15 +368,15 @@ class account_balance(report_sxw.rml_parse): self.total_for_perc=self.linesForTotal(form,ids={},doneAccount={},level=1) self.done_total=0 - for t1 in range(0,len(form['fiscalyear'][0][2])): + for t1 in range(0,len(form['fiscalyear'])): locale.setlocale(locale.LC_ALL, '') self.result_total["sum_credit" + str(t1)]=locale.format("%.2f", self.result_total["sum_credit" + str(t1)], grouping=True) self.result_total["sum_debit" + str(t1)]=locale.format("%.2f", self.result_total["sum_debit" + str(t1)], grouping=True) # self.flag=1 # self.result_total = {} - for temp in range(0,len(form['fiscalyear'][0][2])): - fy=self.pool.get('account.fiscalyear').name_get(self.cr,self.uid,form['fiscalyear'][0][2][temp]) + for temp in range(0,len(form['fiscalyear'])): + fy=self.pool.get('account.fiscalyear').name_get(self.cr,self.uid,form['fiscalyear'][temp]) years["year"+str(temp)]=fy[0][1][12:16] return [years] @@ -395,11 +395,11 @@ class account_balance(report_sxw.rml_parse): ctx = self.context.copy() result_total_parent=[] - for id in form['fiscalyear'][0][2]: + for id in form['fiscalyear']: tmp=[] ctx['fiscalyear'] = id - ctx['periods'] = form['periods'][0][2] + ctx['periods'] = form['periods'] ctx['period_manner'] = form['period_manner'] ctx['state'] = form['context'].get('state','all') tmp = self.pool.get('account.account').browse(self.cr, self.uid, ids, ctx.copy()) @@ -453,10 +453,10 @@ class account_balance(report_sxw.rml_parse): result = [] ctx = self.context.copy() tmp1=[] - for id in form['fiscalyear'][0][2]: + for id in form['fiscalyear']: ctx['fiscalyear'] = id - ctx['periods'] = form['periods'][0][2] + ctx['periods'] = form['periods'] ctx['period_manner']=form['period_manner'] ctx['state'] = form['context'].get('state','all') tmp1 = self.pool.get('account.account').browse(self.cr, self.uid, ids,ctx.copy()) @@ -571,7 +571,7 @@ class account_balance(report_sxw.rml_parse): if entry[0].child_id: - for q in range(0,len(form['fiscalyear'][0][2])): + for q in range(0,len(form['fiscalyear'])): self.baldiv["baldiv"+str(level)+str(q)]=entry[q].balance ids2 = [(x.code,x.id) for x in entry[0].child_id] @@ -579,7 +579,7 @@ class account_balance(report_sxw.rml_parse): dir=[] dir += self.lines(form, [x[1] for x in ids2], done, level+1) if dir==[]: - for w in range(0,len(form['fiscalyear'][0][2])): + for w in range(0,len(form['fiscalyear'])): if entry[w].credit <> 0.0 or entry[w].debit <> 0.0 or entry[w].balance<>0.00: dont_pop=1 break @@ -597,9 +597,9 @@ class account_balance(report_sxw.rml_parse): def get_years(self,form): result =[] res={} - for temp in range(0,len(form['fiscalyear'][0][2])): + for temp in range(0,len(form['fiscalyear'])): res={} - fy=self.pool.get('account.fiscalyear').name_get(self.cr,self.uid,form['fiscalyear'][0][2][temp]) + fy=self.pool.get('account.fiscalyear').name_get(self.cr,self.uid,form['fiscalyear'][temp]) res['year']=fy[0][1] res['last_str']=temp diff --git a/addons/account/report/general_ledger.py b/addons/account/report/general_ledger.py index b06aa1198fc..00031a77ed8 100644 --- a/addons/account/report/general_ledger.py +++ b/addons/account/report/general_ledger.py @@ -41,7 +41,7 @@ class general_ledger(rml_parse.rml_parse): ## new_ids = [] if (data['model'] == 'account.account'): - new_ids = ids + new_ids = 'active_ids' in data['form']['context'] and data['form']['context']['active_ids'] or [] else: new_ids.append(data['form']['Account_list']) @@ -117,7 +117,7 @@ class general_ledger(rml_parse.rml_parse): borne_max = res[0]['stop_date'] if form['state'] == 'byperiod': ## This function will return the most aged date - periods = form['periods'][0][2] + periods = form['periods'] if not periods: self.cr.execute(""" Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = %s""",(form['fiscalyear'],)) @@ -131,13 +131,16 @@ class general_ledger(rml_parse.rml_parse): borne_min = form['date_from'] borne_max = form['date_to'] elif form['state'] == 'all': - periods = form['periods'][0][2] + periods = form['periods'] if not periods: - self.cr.execute(""" - Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = %s""",(form['fiscalyear'],)) + if form['fiscalyear'] == False: + fiscalyears = self.pool.get('account.fiscalyear').search(self.cr, self.uid, [('state', '=', 'draft')]) + else: + fiscalyears = [form['fiscalyear']] + self.cr.execute("select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id =ANY(%s)" ,(fiscalyears,)) else: - self.cr.execute(""" - Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id =ANY(%s)""",(periods,)) + self.cr.execute(""" + Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id =ANY(%s)""",(periods,)) res = self.cr.dictfetchall() period_min = res[0]['start_date'] period_max = res[0]['stop_date'] @@ -180,7 +183,7 @@ class general_ledger(rml_parse.rml_parse): ctx['state'] = form['context'].get('state','all') if form.has_key('fiscalyear'): ctx['fiscalyear'] = form['fiscalyear'] - ctx['periods'] = form['periods'][0][2] + ctx['periods'] = form['periods'] else: ctx['date_from'] = form['date_from'] ctx['date_to'] = form['date_to'] diff --git a/addons/account/report/general_ledger_landscape.py b/addons/account/report/general_ledger_landscape.py index c888994622b..472f0675519 100644 --- a/addons/account/report/general_ledger_landscape.py +++ b/addons/account/report/general_ledger_landscape.py @@ -42,12 +42,10 @@ class general_ledger_landscape(rml_parse.rml_parse): ## new_ids = [] if (data['model'] == 'account.account'): - new_ids = ids + new_ids = 'active_ids' in data['form']['context'] and data['form']['context']['active_ids'] or [] else: new_ids.append(data['form']['Account_list']) - objects = self.pool.get('account.account').browse(self.cr, self.uid, new_ids) - super(general_ledger_landscape, self).set_context(objects, data, new_ids,report_type) def __init__(self, cr, uid, name, context): @@ -118,7 +116,7 @@ class general_ledger_landscape(rml_parse.rml_parse): borne_max = res[0]['stop_date'] if form['state'] == 'byperiod': ## This function will return the most aged date - periods = form['periods'][0][2] + periods = form['periods'] if not periods: self.cr.execute(""" Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = %s""" ,(form['fiscalyear'],)) @@ -133,11 +131,13 @@ class general_ledger_landscape(rml_parse.rml_parse): borne_min = form['date_from'] borne_max = form['date_to'] elif form['state'] == 'all': - periods = form['periods'][0][2] + periods = form['periods'] if not periods: - self.cr.execute(""" - Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = = %s""" ,(form['fiscalyear'],)) - + if form['fiscalyear'] == False: + fiscalyears = self.pool.get('account.fiscalyear').search(self.cr, self.uid, [('state', '=', 'draft')]) + else: + fiscalyears = [form['fiscalyear']] + self.cr.execute("select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id =ANY(%s)" ,(fiscalyears,)) else: self.cr.execute(""" Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id =ANY(%s)""",(periods,)) @@ -182,7 +182,7 @@ class general_ledger_landscape(rml_parse.rml_parse): ctx['state'] = form['context'].get('state','all') if form.has_key('fiscalyear'): ctx['fiscalyear'] = form['fiscalyear'] - ctx['periods'] = form['periods'][0][2] + ctx['periods'] = form['periods'] else: ctx['date_from'] = form['date_from'] ctx['date_to'] = form['date_to'] diff --git a/addons/account/report/third_party_ledger.py b/addons/account/report/third_party_ledger.py index 0ae5bf8ce1a..1dca4dfb64a 100644 --- a/addons/account/report/third_party_ledger.py +++ b/addons/account/report/third_party_ledger.py @@ -59,10 +59,10 @@ class third_party_ledger(rml_parse.rml_parse): # def transform_period_into_date_array(self,data): ## Get All Period Date - if not data['form']['periods'][0][2] : + if not data['form']['periods']: periods_id = self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id','=',data['form']['fiscalyear'])]) else: - periods_id = data['form']['periods'][0][2] + periods_id = data['form']['periods'] date_array = [] for period_id in periods_id: period_obj = self.pool.get('account.period').browse(self.cr, self.uid, period_id) @@ -77,10 +77,10 @@ class third_party_ledger(rml_parse.rml_parse): def transform_both_into_date_array(self,data): - if not data['form']['periods'][0][2] : + if not data['form']['periods']: periods_id = self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id','=',data['form']['fiscalyear'])]) else: - periods_id = data['form']['periods'][0][2] + periods_id = data['form']['periods'] date_array = [] for period_id in periods_id: period_obj = self.pool.get('account.period').browse(self.cr, self.uid, period_id) diff --git a/addons/account/test/test_parent_structure.py b/addons/account/test/test_parent_structure.py new file mode 100644 index 00000000000..ba27d91c87c --- /dev/null +++ b/addons/account/test/test_parent_structure.py @@ -0,0 +1,54 @@ +# -*- 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 . +# +############################################################################## + +# +# TODO: move this in a YAML test with !python tag +# + +import xmlrpclib + +DB = 'training3' +USERID = 1 +USERPASS = 'admin' + + +sock = xmlrpclib.ServerProxy('http://%s:%s/xmlrpc/object' % ('localhost',8069)) + +ids = sock.execute(DB, USERID, USERPASS, 'account.account', 'search', [], {}) +account_lists = sock.execute(DB, USERID, USERPASS, 'account.account', 'read', ids, ['parent_id','parent_left','parent_right']) + +accounts = dict(map(lambda x: (x['id'],x), account_lists)) +for a in account_lists: + if a['parent_id']: + assert a['parent_left'] > accounts[a['parent_id'][0]]['parent_left'] + assert a['parent_right'] < accounts[a['parent_id'][0]]['parent_right'] + assert a['parent_left'] < a['parent_right'] + for a2 in account_lists: + assert not ((a2['parent_right']>a['parent_left']) and + (a2['parent_left']a['parent_left']) and (a2['parent_right'] parent_right of all childs - . if an account is a child it is included in parent_left-parent_right - . if an account is not a child it is not included in parent_left-parent_right +- + We retrieve all accounts and test they are in a tree data structure. - !python {model: account.account}: | ids = self.search(cr, uid, []) diff --git a/addons/account/wizard/__init__.py b/addons/account/wizard/__init__.py index db19cfe9961..91fb10e5205 100644 --- a/addons/account/wizard/__init__.py +++ b/addons/account/wizard/__init__.py @@ -30,21 +30,21 @@ import account_move_journal import account_journal_select import account_move_bank_reconcile import account_subscription_generate -import wizard_aged_trial_balance -import wizard_general_ledger_report -import wizard_third_party_ledger +import account_aged_trial_balance +import account_general_ledger_report +import account_third_party_ledger import account_partner_balance_report +import account_balance_report import account_period_close import account_fiscalyear_close import account_fiscalyear_close_state import account_vat import account_open_closed_fiscalyear -import wizard_compare_account_balance_report +import account_compare_account_balance_report import account_invoice_state -import wizard_account_duplicate import account_chart -import wizard_move_line_select +import account_move_line_select import account_validate_account_move import account_use_model diff --git a/addons/account/wizard/account_aged_trial_balance.py b/addons/account/wizard/account_aged_trial_balance.py new file mode 100755 index 00000000000..bdcb8af735a --- /dev/null +++ b/addons/account/wizard/account_aged_trial_balance.py @@ -0,0 +1,106 @@ +# -*- 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 datetime +from mx.DateTime import * + +from osv import osv, fields +from tools.translate import _ + +class account_aged_trial_balance(osv.osv_memory): + + _name = 'account.aged.trial.balance' + _description = 'Account Aged Trial balance Report' + + _columns = { + 'company_id': fields.many2one('res.company', 'Company', required=True), + 'period_length':fields.integer('Period length (days)', required=True), + 'date1': fields.date('Start of period', required=True), + 'result_selection': fields.selection([('customer','Receivable'), + ('supplier','Payable'), + ('all','Receivable and Payable')], + 'Filter on Partners', required=True), + 'direction_selection': fields.selection([('past','Past'), + ('future','Future')], + 'Analysis Direction', required=True), + } + + def _get_company(self, cr, uid, ids, context=None): + user_obj = self.pool.get('res.users') + company_obj = self.pool.get('res.company') + if context is None: + context = {} + 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 = { + 'company_id' : _get_company, + 'period_length' : 30, + 'date1' : time.strftime('%Y-%m-%d'), + 'result_selection' : 'all', + 'direction_selection' : 'past', + } + + def calc_dates(self, cr, uid, ids, context=None): + fiscalyear_obj = self.pool.get('account.fiscalyear') + data={} + res = {} + if context is None: + context = {} + data['ids'] = context.get('active_ids',[]) + data['model'] = 'res.partner' + data['form'] = self.read(cr, uid, ids, [])[0] + data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid) + period_length = data['form']['period_length'] + if period_length<=0: + raise osv.except_osv(_('UserError'), _('You must enter a period length that cannot be 0 or below !')) + start = datetime.date.fromtimestamp(time.mktime(time.strptime(data['form']['date1'],"%Y-%m-%d"))) + start = DateTime(int(start.year),int(start.month),int(start.day)) + if data['form']['direction_selection'] == 'past': + for i in range(5)[::-1]: + stop = start - RelativeDateTime(days=period_length) + res[str(i)] = { + 'name' : str((5-(i+1))*period_length) + '-' + str((5-i)*period_length), + 'stop': start.strftime('%Y-%m-%d'), + 'start' : stop.strftime('%Y-%m-%d'), + } + start = stop - RelativeDateTime(days=1) + else: + for i in range(5): + stop = start + RelativeDateTime(days=period_length) + res[str(5-(i+1))] = { + 'name' : str((i)*period_length)+'-'+str((i+1)*period_length), + 'start': start.strftime('%Y-%m-%d'), + 'stop' : stop.strftime('%Y-%m-%d'), + } + start = stop + RelativeDateTime(days=1) + data['form'].update(res) + return { + 'type': 'ir.actions.report.xml', + 'report_name': 'account.aged_trial_balance', + 'datas': data, + } + +account_aged_trial_balance() +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/account_aged_trial_balance_view.xml b/addons/account/wizard/account_aged_trial_balance_view.xml new file mode 100644 index 00000000000..258de38b714 --- /dev/null +++ b/addons/account/wizard/account_aged_trial_balance_view.xml @@ -0,0 +1,53 @@ + + + + + + + + Aged Partner Balance + account.aged.trial.balance + form + +
+ + + + + + + + + + + +