2 In order to test the PDF reports defined on an invoice, we will create a Invoice Record
4 !record {model: account.invoice, id: test_invoice_1}:
6 company_id: base.main_company
7 address_invoice_id: base.res_partner_address_tang
8 partner_id: base.res_partner_asus
11 account_id: account.a_recv
13 address_contact_id: base.res_partner_address_tang
15 In order to test the PDF reports defined on an invoice, we will print an Invoice Report
17 !python {model: account.invoice}: |
18 import netsvc, tools, os
19 (data, format) = netsvc.LocalService('report.account.invoice').create(cr, uid, [ref('account.account_invoice_customer0')], {}, {})
20 if tools.config['test_report_directory']:
21 file(os.path.join(tools.config['test_report_directory'], 'account-invoice.'+format), 'wb+').write(data)
24 In order to test the PDF reports defined on a partner, we will print the Overdue Report
26 !python {model: res.partner}: |
27 import netsvc, tools, os
28 (data, format) = netsvc.LocalService('report.account.overdue').create(cr, uid, [ref('base.res_partner_asus'),ref('base.res_partner_agrolait'),ref('base.res_partner_c2c')], {}, {})
29 if tools.config['test_report_directory']:
30 file(os.path.join(tools.config['test_report_directory'], 'account-report_overdue.'+format), 'wb+').write(data)
33 In order to test the PDF reports defined on Account Move, we will print the Voucher Report
35 !python {model: account.move}: |
36 import netsvc, tools, os
37 (data, format) = netsvc.LocalService('report.account.move.voucher').create(cr, uid, [ref('account.account_move_0')], {}, {})
38 if tools.config['test_report_directory']:
39 file(os.path.join(tools.config['test_report_directory'], 'account-voucher-report.'+format), 'wb+').write(data)
42 Print the Aged Partner Balance Report
44 !python {model: res.partner}: |
46 from datetime import datetime
47 from dateutil.relativedelta import relativedelta
48 start = datetime.fromtimestamp(time.mktime(time.strptime(time.strftime('%Y-%m-%d'), "%Y-%m-%d")))
49 start = datetime(int(start.year), int(start.month), int(start.day))
51 for i in range(5)[::-1]:
52 stop = start - relativedelta(days=30)
54 'name': (i!=0 and (str((5-(i+1)) * 30) + '-' + str((5-i) * 30)) or ('+'+str(4 * 30))),
55 'stop': start.strftime('%Y-%m-%d'),
56 'start': (i!=0 and stop.strftime('%Y-%m-%d') or False),
58 start = stop - relativedelta(days=1)
59 obj_move = self.pool.get('account.move.line')
61 fy_id = ref('account.data_fiscalyear')
62 period_list = self.pool.get('account.period').search(cr, uid, [('fiscalyear_id', 'in', [fy_id])], context=context)
63 journal_ids = [ref('account.sales_journal'),ref('account.refund_sales_journal'),ref('account.expenses_journal'),ref('account.refund_expenses_journal'),ref('account.bank_journal'),ref('account.check_journal'),ref('account.cash_journal')]
64 ctx['fiscalyear'] = fy_id
65 ctx['journal_ids'] = journal_ids
66 ctx['chart_account_id'] = ref('account.chart0')
68 query_line = obj_move._query_get(cr, uid, obj='l', context=ctx)
70 data_dict = {'model': 'ir.ui.menu', 'form': \
71 {'chart_account_id':ref('account.chart0'),
72 'initial_balance': 1, 'periods': period_list,
73 'journal_ids':journal_ids, 'page_split': 0,
74 'date_from': time.strftime('%Y-%m-%d'),
75 'period_length': 30, 'amount_currency': 0,
76 'query_line' : query_line, 'result_selection':
77 'customer','direction_selection':
78 'past','fiscalyear_id':fy_id } }
79 data_dict['form'].update(res)
80 from tools.test_reports import try_report
81 try_report(cr, uid, 'report.account.aged_trial_balance', [], data_dict, context={})
83 Print the Account Balance Sheet in Horizontal mode
85 !python {model: account.account}: |
86 import netsvc, tools, os, time
87 data_dict = {'model': 'ir.ui.menu', 'form': {'reserve_account_id':ref('account.rsa') ,'chart_account_id':ref('account.chart0'),'display_account':'bal_all','filter': 'filter_no','display_type': 1,'journal_ids':[],'fiscalyear': ref('account.data_fiscalyear') ,'target_move': 'all'}}
88 (data, format) = netsvc.LocalService('report.account.balancesheet.horizontal').create(cr, uid, [], data_dict, {'periods': []})
89 if tools.config['test_report_directory']:
90 file(os.path.join(tools.config['test_report_directory'], 'account-account_balance_sheet_horizontal.'+format), 'wb+').write(data)
93 Print the Account Balance Sheet in Normal mode
95 !python {model: account.account}: |
96 import netsvc, tools, os, time
97 data_dict = {'model': 'ir.ui.menu', 'form': {'reserve_account_id':ref('account.rsa') ,'chart_account_id':ref('account.chart0'),'display_account':'bal_all','filter': 'filter_no','display_type': 0,'journal_ids':[],'fiscalyear': ref('account.data_fiscalyear') ,'target_move': 'all'}}
98 (data, format) = netsvc.LocalService('report.account.balancesheet').create(cr, uid, [], data_dict, {'periods': []})
99 if tools.config['test_report_directory']:
100 file(os.path.join(tools.config['test_report_directory'], 'account-account_balance_sheet.'+format), 'wb+').write(data)
103 Print the Account Balance Report in Normal mode through the wizard - From Account Chart
105 !python {model: account.account}: |
106 import netsvc, tools, os, time
108 ctx.update({'model': 'account.account','active_ids':[ref('account.chart0')]})
109 data_dict = {'chart_account_id':ref('account.chart0'),'fiscalyear_id':ref('account.data_fiscalyear'),'target_move': 'all','display_account':'bal_all'}
110 from tools import test_reports
111 test_reports.try_report_action(cr, uid, 'action_account_balance_menu',wiz_data=data_dict, context=ctx, our_module='account')
113 Print the Central Journal Report - From Account
115 !python {model: account.journal.period}: |
116 import netsvc, tools, os, time
117 fy_id = ref('account.data_fiscalyear')
118 period_list = self.pool.get('account.period').search(cr, uid, [('fiscalyear_id', 'in', [fy_id])], context=context)
119 journal_ids = [ref('account.sales_journal'),ref('account.refund_sales_journal'),ref('account.expenses_journal'),ref('account.refund_expenses_journal'),ref('account.bank_journal'),ref('account.check_journal'),ref('account.cash_journal')]
120 journal_period_ids = self.pool.get('account.journal.period').search(cr, uid, [('journal_id', 'in', journal_ids), ('period_id', 'in', period_list)], context=context)
122 obj_move = self.pool.get('account.move.line')
124 ctx['fiscalyear'] = fy_id
125 ctx['journal_ids'] = journal_ids
126 ctx['chart_account_id'] = ref('account.chart0')
128 query_line = obj_move._query_get(cr, uid, obj='l', context=ctx)
129 data_dict = {'model': 'account.journal.period', 'id':journal_period_ids[0], 'form': {'chart_account_id':ref('account.chart0'),'display_account':'bal_all','filter': 'filter_no','amount_currency': 0,'compare_pattern': 'none','account_choice': 'moves','landscape':0,'period_manner': 'actual','fiscalyear_id': fy_id ,'query_line':query_line,'target_move': 'all','periods': period_list,'journal_ids':journal_ids,'id':ref('account.bal') }}
130 (data, format) = netsvc.LocalService('report.account.central.journal').create(cr, uid, journal_period_ids, data_dict, {})
131 if tools.config['test_report_directory']:
132 file(os.path.join(tools.config['test_report_directory'], 'account-central_journal.'+format), 'wb+').write(data)
134 data_dict.update({'model': 'ir.ui.menu'})
135 data_dict['form'].update({'active_ids':journal_period_ids})
137 (data, format) = netsvc.LocalService('report.account.central.journal').create(cr, uid, [], data_dict, {})
138 if tools.config['test_report_directory']:
139 file(os.path.join(tools.config['test_report_directory'], 'account-central_journal-menu.'+format), 'wb+').write(data)
141 Print the General Journal Report - From Journal
143 !python {model: account.journal.period}: |
144 import netsvc, tools, os, time
145 fy_id = ref('account.data_fiscalyear')
146 period_list = self.pool.get('account.period').search(cr, uid, [('fiscalyear_id', 'in', [fy_id])], context=context)
147 journal_ids = [ref('account.sales_journal'),ref('account.refund_sales_journal'),ref('account.expenses_journal'),ref('account.refund_expenses_journal'),ref('account.bank_journal'),ref('account.check_journal'),ref('account.cash_journal')]
148 journal_period_ids = self.pool.get('account.journal.period').search(cr, uid, [('journal_id', 'in', journal_ids), ('period_id', 'in', period_list)], context=context)
150 obj_move = self.pool.get('account.move.line')
152 ctx['fiscalyear'] = fy_id
153 ctx['journal_ids'] = journal_ids
154 ctx['chart_account_id'] = ref('account.chart0')
156 query_line = obj_move._query_get(cr, uid, obj='l', context=ctx)
157 data_dict = {'model': 'ir.ui.menu','id':journal_period_ids[0], 'form': {'chart_account_id':ref('account.chart0'),'display_account':'bal_all','filter': 'filter_no','amount_currency': 0,'compare_pattern': 'none','account_choice': 'moves','landscape':0,'period_manner': 'actual','fiscalyear_id': fy_id ,'query_line':query_line,'target_move': 'all','periods': period_list,'journal_ids':journal_ids, 'active_ids':journal_period_ids}}
158 (data, format) = netsvc.LocalService('report.account.general.journal').create(cr, uid, journal_period_ids, data_dict, {})
159 if tools.config['test_report_directory']:
160 file(os.path.join(tools.config['test_report_directory'], 'account-general_journal.'+format), 'wb+').write(data)
163 Print the General Ledger Report in Normal Mode
165 !python {model: account.account}: |
166 import netsvc, tools, os, time
167 fy_id = ref('account.data_fiscalyear')
168 period_list = self.pool.get('account.period').search(cr, uid, [('fiscalyear_id', 'in', [fy_id])], context=context)
169 journal_ids = [ref('account.sales_journal'),ref('account.refund_sales_journal'),ref('account.expenses_journal'),ref('account.refund_expenses_journal'),ref('account.bank_journal'),ref('account.check_journal'),ref('account.cash_journal')]
170 acc_ids = [ref('account.bal'),ref('account.gpf')]
172 obj_move = self.pool.get('account.move.line')
174 ctx['fiscalyear'] = fy_id
175 ctx['journal_ids'] = journal_ids
176 ctx['chart_account_id'] = ref('account.chart0')
178 query_line = obj_move._query_get(cr, uid, obj='l', context=ctx)
180 data_dict = {'model': 'account.account', 'form': {'initial_balance': 1,'initial_bal_query': query_line,'chart_account_id':ref('account.chart0'),'display_account':'bal_all','filter': 'filter_no','sortby': 'sort_date','amount_currency': 0,'landscape':0,'period_manner': 'actual','fiscalyear_id': fy_id ,'query_line':query_line,'target_move': 'all','periods': period_list,'journal_ids':journal_ids,'id':ref('account.bal') }}
181 (data, format) = netsvc.LocalService('report.account.general.ledger').create(cr, uid, acc_ids, data_dict, {})
182 if tools.config['test_report_directory']:
183 file(os.path.join(tools.config['test_report_directory'], 'account-general_ledger.'+format), 'wb+').write(data)
185 data_dict.update({'model': 'ir.ui.menu'})
186 data_dict['form'].update({'active_ids': acc_ids})
187 (data, format) = netsvc.LocalService('report.account.general.ledger').create(cr, uid, [], data_dict, {})
188 if tools.config['test_report_directory']:
189 file(os.path.join(tools.config['test_report_directory'], 'account-general_ledger-menu.'+format), 'wb+').write(data)
191 Print the General Ledger Report in Landscape Mode
193 !python {model: account.account}: |
194 import netsvc, tools, os, time
195 fy_id = ref('account.data_fiscalyear')
196 period_list = self.pool.get('account.period').search(cr, uid, [('fiscalyear_id', 'in', [fy_id])], context=context)
197 journal_ids = [ref('account.sales_journal'),ref('account.refund_sales_journal'),ref('account.expenses_journal'),ref('account.refund_expenses_journal'),ref('account.bank_journal'),ref('account.check_journal'),ref('account.cash_journal')]
198 acc_ids = [ref('account.bal'),ref('account.gpf')]
200 obj_move = self.pool.get('account.move.line')
202 ctx['fiscalyear'] = fy_id
203 ctx['journal_ids'] = journal_ids
204 ctx['chart_account_id'] = ref('account.chart0')
206 query_line = obj_move._query_get(cr, uid, obj='l', context=ctx)
208 data_dict = {'model': 'account.account', 'form': {'initial_balance': 1,'initial_bal_query':query_line,'chart_account_id':ref('account.chart0'),'display_account':'bal_all','filter': 'filter_no','sortby': 'sort_date','amount_currency': 0,'landscape':1,'period_manner': 'actual','fiscalyear_id': fy_id ,'query_line':query_line,'target_move': 'all','periods': period_list,'journal_ids':journal_ids,'id':ref('account.bal') }}
209 (data, format) = netsvc.LocalService('report.account.general.ledger_landscape').create(cr, uid, acc_ids, data_dict, {})
210 if tools.config['test_report_directory']:
211 file(os.path.join(tools.config['test_report_directory'], 'account-general_ledger-landscape.'+format), 'wb+').write(data)
213 data_dict.update({'model': 'ir.ui.menu'})
214 data_dict['form'].update({'active_ids': acc_ids})
215 (data, format) = netsvc.LocalService('report.account.general.ledger_landscape').create(cr, uid, [], data_dict, {})
216 if tools.config['test_report_directory']:
217 file(os.path.join(tools.config['test_report_directory'], 'account-general_ledger-landscape-menu.'+format), 'wb+').write(data)
220 Print Journal Report - From Model
222 !python {model: account.journal.period}: |
223 import netsvc, tools, os, time
224 fy_id = ref('account.data_fiscalyear')
225 period_list = self.pool.get('account.period').search(cr, uid, [('fiscalyear_id', 'in', [fy_id])], context=context)
226 journal_ids = [ref('account.sales_journal'),ref('account.refund_sales_journal'),ref('account.expenses_journal'),ref('account.refund_expenses_journal'),ref('account.bank_journal'),ref('account.check_journal'),ref('account.cash_journal')]
227 journal_period_ids = self.pool.get('account.journal.period').search(cr, uid, [('journal_id', 'in', journal_ids), ('period_id', 'in', period_list)], context=context)
229 obj_move = self.pool.get('account.move.line')
231 ctx['fiscalyear'] = fy_id
232 ctx['journal_ids'] = journal_ids
233 ctx['chart_account_id'] = ref('account.chart0')
235 query_line = obj_move._query_get(cr, uid, obj='l', context=ctx)
237 data_dict = {'model': 'account.journal.period', 'id':journal_period_ids[0], 'form': {'sort_selection': 'date','chart_account_id':ref('account.chart0'),'display_account':'bal_all','filter': 'filter_no','amount_currency': 0,'compare_pattern': 'none','account_choice': 'moves','landscape':0,'period_manner': 'actual','fiscalyear_id': fy_id ,'query_line':query_line,'target_move': 'all','periods': period_list,'journal_ids':journal_ids,'id':ref('account.bal') }}
238 (data, format) = netsvc.LocalService('report.account.journal.period.print').create(cr, uid, journal_period_ids, data_dict, {})
239 if tools.config['test_report_directory']:
240 file(os.path.join(tools.config['test_report_directory'], 'account-print_journal.'+format), 'wb+').write(data)
242 data_dict.update({'model': 'ir.ui.menu'})
243 data_dict['form'].update({'active_ids':journal_period_ids})
245 (data, format) = netsvc.LocalService('report.account.journal.period.print').create(cr, uid, [], data_dict, {})
246 if tools.config['test_report_directory']:
247 file(os.path.join(tools.config['test_report_directory'], 'account-print_journal-menu.'+format), 'wb+').write(data)
250 Print the Partner Balance Report
252 !python {model: res.partner}: |
253 import netsvc, tools, os, time
254 fy_id = ref('account.data_fiscalyear')
255 period_list = self.pool.get('account.period').search(cr, uid, [('fiscalyear_id', 'in', [fy_id])], context=context)
256 journal_ids = [ref('account.sales_journal'),ref('account.refund_sales_journal'),ref('account.expenses_journal'),ref('account.refund_expenses_journal'),ref('account.bank_journal'),ref('account.check_journal'),ref('account.cash_journal')]
257 journal_period_ids = self.pool.get('account.journal.period').search(cr, uid, [('journal_id', 'in', journal_ids), ('period_id', 'in', period_list)], context=context)
258 obj_move = self.pool.get('account.move.line')
260 ctx['fiscalyear'] = fy_id
261 ctx['journal_ids'] = journal_ids
262 ctx['chart_account_id'] = ref('account.chart0')
264 query_line = obj_move._query_get(cr, uid, obj='l', context=ctx)
266 data_dict = {'model': 'ir.ui.menu', 'form': {'result_selection': 'customer','chart_account_id':ref('account.chart0'),'display_account':'bal_all','filter': 'filter_no','display_type': 0,'journal_ids':journal_ids,'active_ids':journal_period_ids,'display_partner': 'all','fiscalyear': fy_id ,'target_move': 'all','query_line':query_line}}
267 (data, format) = netsvc.LocalService('report.account.partner.balance').create(cr, uid, journal_period_ids, data_dict, {})
268 if tools.config['test_report_directory']:
269 file(os.path.join(tools.config['test_report_directory'], 'account-partner_balance.'+format), 'wb+').write(data)
272 Print the Partner Ledger Report
274 !python {model: res.partner}: |
275 import netsvc, tools, os, time
276 fy_id = ref('account.data_fiscalyear')
277 period_list = self.pool.get('account.period').search(cr, uid, [('fiscalyear_id', 'in', [fy_id])], context=context)
278 journal_ids = [ref('account.sales_journal'),ref('account.refund_sales_journal'),ref('account.expenses_journal'),ref('account.refund_expenses_journal'),ref('account.bank_journal'),ref('account.check_journal'),ref('account.cash_journal')]
280 obj_move = self.pool.get('account.move.line')
282 ctx['fiscalyear'] = fy_id
283 ctx['journal_ids'] = journal_ids
284 ctx['chart_account_id'] = ref('account.chart0')
286 query_line = obj_move._query_get(cr, uid, obj='l', context=ctx)
288 data_dict = {'model': 'ir.ui.menu', 'form': {'initial_bal_query':query_line,'amount_currency': 0,'reconcil': True,'initial_balance':1,'page_split': True,'result_selection': 'customer','chart_account_id':ref('account.chart0'),'display_account':'bal_all','filter': 'filter_no','display_type': 0,'journal_ids':journal_ids,'display_partner': 'non-zero_balance','fiscalyear': fy_id ,'target_move': 'all','query_line':query_line}}
289 (data, format) = netsvc.LocalService('report.account.third_party_ledger').create(cr, uid, [], data_dict, {})
290 if tools.config['test_report_directory']:
291 file(os.path.join(tools.config['test_report_directory'], 'account-partner_ledger.'+format), 'wb+').write(data)
294 Print the Partner Ledger-Other Report
296 !python {model: res.partner}: |
297 import netsvc, tools, os, time
298 fy_id = ref('account.data_fiscalyear')
299 period_list = self.pool.get('account.period').search(cr, uid, [('fiscalyear_id', 'in', [fy_id])], context=context)
300 journal_ids = [ref('account.sales_journal'),ref('account.refund_sales_journal'),ref('account.expenses_journal'),ref('account.refund_expenses_journal'),ref('account.bank_journal'),ref('account.check_journal'),ref('account.cash_journal')]
302 obj_move = self.pool.get('account.move.line')
304 ctx['fiscalyear'] = fy_id
305 ctx['journal_ids'] = journal_ids
306 ctx['chart_account_id'] = ref('account.chart0')
308 query_line = obj_move._query_get(cr, uid, obj='l', context=ctx)
309 data_dict = {'model': 'ir.ui.menu', 'form': {'initial_bal_query':query_line,'amount_currency': 0,'reconcil': True,'initial_balance':1,'page_split': False,'result_selection': 'customer','chart_account_id':ref('account.chart0'),'display_account':'bal_all','filter': 'filter_no','display_type': 0,'journal_ids':journal_ids,'display_partner': 'non-zero_balance','fiscalyear': fy_id ,'target_move': 'all','query_line':query_line}}
310 (data, format) = netsvc.LocalService('report.account.third_party_ledger_other').create(cr, uid, [], data_dict, {})
311 if tools.config['test_report_directory']:
312 file(os.path.join(tools.config['test_report_directory'], 'account-partner_ledger-other.'+format), 'wb+').write(data)
315 Print the Profit-Loss Report in Normal Mode
317 !python {model: account.account}: |
318 import netsvc, tools, os, time
319 fy_id = ref('account.data_fiscalyear')
320 period_list = self.pool.get('account.period').search(cr, uid, [('fiscalyear_id', 'in', [fy_id])], context=context)
322 acc_ids = [ref('account.bal'),ref('account.gpf')]
323 data_dict = {'model': 'ir.ui.menu', 'form': {'display_type': False,'chart_account_id':ref('account.chart0'),'display_account':'bal_all','filter': 'filter_no','amount_currency': 0,'landscape':0,'period_manner': 'actual','fiscalyear_id': fy_id ,'query_line':'True ','target_move': 'all','periods': period_list,'journal_ids':journal_ids,'id':ref('account.bal'),'active_ids':acc_ids }}
324 (data, format) = netsvc.LocalService('report.pl.account').create(cr, uid, [], data_dict, {})
325 if tools.config['test_report_directory']:
326 file(os.path.join(tools.config['test_report_directory'], 'account-profit-loss.'+format), 'wb+').write(data)
329 Print the Profit-Loss Report in Horizontal Mode
331 !python {model: account.account}: |
332 import netsvc, tools, os, time
333 fy_id = ref('account.data_fiscalyear')
334 period_list = self.pool.get('account.period').search(cr, uid, [('fiscalyear_id', 'in', [fy_id])], context=context)
336 acc_ids = [ref('account.bal'),ref('account.gpf')]
337 data_dict = {'model': 'ir.ui.menu', 'form': {'display_type': True,'chart_account_id':ref('account.chart0'),'display_account':'bal_all','filter': 'filter_no','amount_currency': 0,'landscape':0,'period_manner': 'actual','fiscalyear_id': fy_id ,'query_line':'True ','target_move': 'all','periods': period_list,'journal_ids':journal_ids,'id':ref('account.bal'),'active_ids':acc_ids }}
338 (data, format) = netsvc.LocalService('report.pl.account.horizontal').create(cr, uid, [], data_dict, {})
339 if tools.config['test_report_directory']:
340 file(os.path.join(tools.config['test_report_directory'], 'account-profit-loss-horizontal.'+format), 'wb+').write(data)