def test_print_report(self): self.env['account.invoice.line'].create({ 'invoice_id': self.supplier_invoice.id, 'name': 'Product Text', 'price_unit': 10.0, 'account_id': self.env.ref('l10n_generic_coa.1_conf_o_income').id, }) self.supplier_invoice.action_invoice_open() self.assertEqual( self.supplier_invoice.move_id.line_ids[0].payment_mode_id, self.supplier_invoice.payment_mode_id) (res, _) = report.render_report( self.env.cr, self.env.uid, [self.supplier_invoice.id], 'account.report_invoice', {}) self.assertRegexpMatches(res, self.supplier_bank.acc_number) self.supplier_invoice.partner_bank_id = False self.supplier_invoice.payment_mode_id\ .show_bank_account_from_journal = True (res, _) = report.render_report( self.env.cr, self.env.uid, [self.supplier_invoice.id], 'account.report_invoice', {}) self.assertRegexpMatches(res, self.journal_bank.acc_number) payment_mode = self.supplier_invoice.payment_mode_id self.supplier_invoice.payment_mode_id = False payment_mode.bank_account_link = 'variable' payment_mode.variable_journal_ids = [ (6, 0, [self.journal.id])] self.supplier_invoice.payment_mode_id = payment_mode.id self.supplier_invoice.payment_mode_id_change() (res, _) = report.render_report( self.env.cr, self.env.uid, [self.supplier_invoice.id], 'account.report_invoice', {}) self.assertRegexpMatches( res, self.journal_bank.acc_number)
def test_00_payment_advice_flow(self): # I create a new Payment Advice with NEFT Transaction Enable payment_advice = self.Advice.create({ 'name': 'NEFT Advice', 'bank_id': self.bank_1.id, 'line_ids': [(0, 0, { 'employee_id': self.employee_fp.id, 'name': '90125452552', 'ifsc_code': 'abn45215145', 'bysal': 25000.00, }), (0, 0, { 'employee_id': self.employee_al.id, 'name': '00014521111232', 'ifsc_code': 'sbi45452145', 'bysal': 20000.00, })], }) # I check that the Payment Advice is in "Draft" self.assertEqual(payment_advice.state, 'draft') # Now I confirm Payment Advice payment_advice.confirm_sheet() # I check that the Payment Advice state is "Confirmed" self.assertEqual(payment_advice.state, 'confirm') # In order to test the PDF report defined on a Payment Advice, we will print a Print Advice Report when NEFT is checked data, format = render_report(self.env.cr, self.env.uid, payment_advice.ids, 'l10n_in_hr_payroll.report_payrolladvice', {}, {}) if config.get('test_report_directory'): file(os.path.join(config['test_report_directory'], 'l10n_in_hr_payroll_summary_report' + format), 'wb+').write(data)
def generateReport(cr, uid, model, report_service_name, ids, data=None, context=None, version7=False): """Generate the report and return it as a tuple (result, format) where `result` is the report document and `format` is the file extension. """ if not data: data = {} data.update({'model': model}) if not version7: try: # version 10 and higher from odoo.report import render_report except: # version 8 to 9 from openerp.report import render_report return render_report(cr, uid, ids, report_service_name, data, context=context) else: # version 7 from openerp import netsvc report_service = netsvc.LocalService('report.' + report_service_name) return report_service.create(cr, uid, ids, data, context=context)
def test_due_list(self): invoice = self.env['account.invoice'].create({ 'partner_id': self.partner.id, 'payment_term_id': self.payment_term_normal.id, 'type': 'out_invoice', 'account_id': self.account.id, 'invoice_line_ids': [(0, 0, { 'product_id': self.product_id.id, 'price_unit': 100.0, 'account_id': self.other_account.id, 'name': self.product_id.name, })] }) self.assertFalse(invoice.multi_due) invoice.payment_term_id = self.payment_term_multi.id invoice._onchange_payment_term_date_invoice() invoice.action_invoice_open() self.assertTrue(invoice.multi_due) self.assertEqual(len(invoice.multi_date_due.split()), 2) due_date = fields.Date.to_string(fields.date.today() + timedelta(days=60)) (res, _) = report.render_report(self.env.cr, self.env.uid, [invoice.id], 'account.report_invoice', {}) self.assertRegexpMatches(res, due_date) self.assertRegexpMatches(res, '75.0')
def test_report_webkit(self): report_ids = self.env["ir.actions.report.xml"].search([]).ids data, format = render_report( self.env.cr, self.env.uid, report_ids, "webkit.ir.actions.report.xml", {}, context=self.env.context ) if tools.config["test_report_directory"]: file( os.path.join(tools.config["test_report_directory"], "report_webkit_demo_report." + format), "wb+" ).write(data)
def test_print_report(self): invoice = self.make_invoice() data, format = render_report( self.env.cr, self.env.uid, [invoice.id], 'l10n_ch_payment_slip.one_slip_per_page_from_invoice', {}, context={'force_pdf': True}, ) self.assertTrue(data) self.assertEqual(format, 'pdf')
def test_report_webkit(self): report_ids = self.env['ir.actions.report.xml'].search([]).ids data, format = render_report(self.env.cr, self.env.uid, report_ids, 'webkit.ir.actions.report.xml', {}, context=self.env.context) if tools.config['test_report_directory']: file( os.path.join(tools.config['test_report_directory'], 'report_webkit_demo_report.' + format), 'wb+').write(data)
def test_print_multi_report_merge_on_disk(self): self.env.user.company_id.merge_mode = 'on_disk' invoice1 = self.make_invoice() invoice2 = self.make_invoice() data, format = render_report( self.env.cr, self.env.uid, [invoice1.id, invoice2.id], 'l10n_ch_payment_slip.one_slip_per_page_from_invoice', {}, context={'force_pdf': True}, ) self.assertTrue(data) self.assertEqual(format, 'pdf')
def create_document(self, res_model, res_id): self.ensure_one() Attachment = self.env[ 'ir.attachment'] # TDE FIXME: should remove dfeault_type from context # create a mail_mail based on values, without attachments #values = self.generate_document(res_id) #document_name = values.pop('name') document_name = 'document_name' attachments = [] report_name = self.render_template(document_name, res_model, res_id) report = template.report_template report_service = report.report_name if report.report_type in ['qweb-html', 'qweb-pdf']: result, format = Template.env['report'].get_pdf( [res_id], report_service), 'pdf' else: result, format = odoo_report.render_report( self._cr, self._uid, [res_id], report_service, {'model': template.model}, Template._context) # TODO in trunk, change return format to binary to match message_post expected format result = base64.b64encode(result) if not report_name: report_name = 'report.' + report_service ext = "." + format if not report_name.endswith(ext): report_name += ext attachments.append((report_name, result)) # manage attachments for attachment in attachments: attachment_data = { 'name': attachment[0], 'datas_fname': attachment[0], 'datas': attachment[1], 'type': 'binary', 'res_model': 'hr.document', 'res_id': res_id, } attachment_ids.append(Attachment.create(attachment_data).id) if attachment_ids: values['attachment_ids'] = [(6, 0, attachment_ids)] mail.write({'attachment_ids': [(6, 0, attachment_ids)]}) if force_send: mail.send(raise_exception=raise_exception) return mail.id # TDE CLEANME: return mail + api.returns ?
def create_report(self, report_name=False, file_name=False): ''' Creates report from report_name that contains records of res_ids and saves in report directory of module as file_name. @param res_ids : List of record ids @param report_name : Report name defined in .py file of report @param file_name : Name of temporary file to store data @return: On success returns tuple (True,filename) otherwise tuple (False,execeotion) ''' if not report_name or not self._ids: return (False, Exception('Report name and Resources \ ids are required !')) try: result, format = render_report(self.env.cr, self.env.uid, self._ids, report_name, {}, {}) except Exception, e: return (False, str(e))
def test_riba_flow(self): recent_date = self.env['account.invoice'].search( [('date_invoice', '!=', False)], order='date_invoice desc', limit=1).date_invoice invoice = self.env['account.invoice'].create({ 'date_invoice': recent_date, 'journal_id': self.sale_journal.id, 'partner_id': self.partner.id, 'payment_term_id': self.account_payment_term_riba.id, 'account_id': self.account_rec1_id.id, 'invoice_line_ids': [(0, 0, { 'name': 'product1', 'product_id': self.product1.id, 'quantity': 1.0, 'price_unit': 450.00, 'account_id': self.sale_account.id })] }) invoice.action_invoice_open() riba_move_line_id = False for move_line in invoice.move_id.line_ids: if move_line.account_id.id == self.account_rec1_id.id: riba_move_line_id = move_line.id line_ids = self.move_line_model.search([ '&', '|', ('riba', '=', 'True'), ('unsolved_invoice_ids', '!=', False), ('account_id.internal_type', '=', 'receivable'), ('reconciled', '=', False), ('distinta_line_ids', '=', False) ]) self.assertEqual(len(line_ids), 1) self.assertEqual(line_ids[0].id, move_line.id) self.assertTrue(riba_move_line_id) # issue wizard wizard_riba_issue = self.env['riba.issue'].create( {'configuration_id': self.riba_config.id}) action = wizard_riba_issue.with_context({ 'active_ids': [riba_move_line_id] }).create_list() riba_list_id = action and action['res_id'] or False riba_list = self.distinta_model.browse(riba_list_id) riba_list.confirm() self.assertEqual(riba_list.state, 'accepted') self.assertEqual(invoice.state, 'paid') self.assertEqual(len(riba_list.acceptance_move_ids), 1) self.assertEqual(len(riba_list.payment_ids), 0) riba_list.acceptance_move_ids[0].assert_balanced() # I print the distina report data, format = render_report( self.env.cr, self.env.uid, riba_list.ids, 'l10n_it_ricevute_bancarie.distinta_qweb', {}, {}) if config.get('test_report_directory'): file( os.path.join(config['test_report_directory'], 'riba-list.' + format), 'wb+').write(data) # accreditation wizard wiz_accreditation = self.env['riba.accreditation'].with_context({ "active_model": "riba.distinta", "active_ids": [riba_list_id], "active_id": riba_list_id, }).create({ 'bank_amount': 445, 'expense_amount': 5, }) wiz_accreditation.create_move() self.assertEqual(riba_list.state, 'accredited') riba_list.accreditation_move_id.assert_balanced() bank_accreditation_line = False for accr_line in riba_list.accreditation_move_id.line_ids: if accr_line.account_id.id == self.bank_account.id: bank_accreditation_line = accr_line break self.assertTrue(bank_accreditation_line) # register the bank statement with the bank accreditation st = self.env['account.bank.statement'].create({ 'journal_id': self.bank_journal.id, 'name': 'bank statement', 'line_ids': [(0, 0, { 'name': 'riba', 'amount': 445, })] }) # must be possible to close the bank statement line with the # accreditation journal item generate by riba move_lines_for_rec = st.line_ids[0].get_move_lines_for_reconciliation() self.assertTrue( bank_accreditation_line.id in [l.id for l in move_lines_for_rec]) # bank notifies cash in bank_move = self.move_model.create({ 'journal_id': self.bank_journal.id, 'line_ids': [ (0, 0, { 'partner_id': self.partner.id, 'account_id': self.sbf_effects.id, 'credit': 450, 'debit': 0, 'name': 'sbf effects', }), (0, 0, { 'partner_id': self.partner.id, 'account_id': self.riba_account.id, 'credit': 0, 'debit': 450, 'name': 'Banca conto ricevute bancarie', }), ] }) to_reconcile = self.env['account.move.line'] line_set = (bank_move.line_ids | riba_list.acceptance_move_ids[0].line_ids) for line in line_set: if line.account_id.id == self.sbf_effects.id: to_reconcile |= line self.assertEqual(len(to_reconcile), 2) to_reconcile.reconcile() # refresh otherwise riba_list.payment_ids is not recomputed riba_list.refresh() self.assertEqual(riba_list.state, 'paid') self.assertEqual(len(riba_list.payment_ids), 1) self.assertEqual(len(riba_list.line_ids), 1) self.assertEqual(riba_list.line_ids[0].state, 'paid') to_reconcile.remove_move_reconcile() self.assertEqual(riba_list.state, 'accredited') self.assertEqual(riba_list.line_ids[0].state, 'accredited')
def generate_email(self, res_ids, fields=None): """Generates an email from the template for given the given model based on records given by res_ids. :param template_id: id of the template to render. :param res_id: id of the record to use for rendering the template (model is taken from template definition) :returns: a dict containing all relevant fields for creating a new mail.mail entry, with one extra key ``attachments``, in the format [(report_name, data)] where data is base64 encoded. """ self.ensure_one() multi_mode = True if isinstance(res_ids, (int, long)): res_ids = [res_ids] multi_mode = False if fields is None: fields = ['subject', 'body_html', 'email_from', 'email_to', 'partner_to', 'email_cc', 'reply_to', 'scheduled_date'] res_ids_to_templates = self.get_email_template(res_ids) # templates: res_id -> template; template -> res_ids templates_to_res_ids = {} for res_id, template in res_ids_to_templates.iteritems(): templates_to_res_ids.setdefault(template, []).append(res_id) results = dict() for template, template_res_ids in templates_to_res_ids.iteritems(): Template = self.env['mail.template'] # generate fields value for all res_ids linked to the current template if template.lang: Template = Template.with_context(lang=template._context.get('lang')) for field in fields: Template = Template.with_context(safe=field in {'subject'}) generated_field_values = Template.render_template( getattr(template, field), template.model, template_res_ids, post_process=(field == 'body_html')) for res_id, field_value in generated_field_values.iteritems(): results.setdefault(res_id, dict())[field] = field_value # compute recipients if any(field in fields for field in ['email_to', 'partner_to', 'email_cc']): results = template.generate_recipients(results, template_res_ids) # update values for all res_ids for res_id in template_res_ids: values = results[res_id] # body: add user signature, sanitize if 'body_html' in fields and template.user_signature: signature = self.env.user.signature if signature: values['body_html'] = tools.append_content_to_html(values['body_html'], signature, plaintext=False) if values.get('body_html'): values['body'] = tools.html_sanitize(values['body_html']) # technical settings values.update( mail_server_id=template.mail_server_id.id or False, auto_delete=template.auto_delete, model=template.model, res_id=res_id or False, attachment_ids=[attach.id for attach in template.attachment_ids], ) # Add report in attachments: generate once for all template_res_ids if template.report_template: for res_id in template_res_ids: attachments = [] report_name = self.render_template(template.report_name, template.model, res_id) report = template.report_template report_service = report.report_name if report.report_type in ['qweb-html', 'qweb-pdf']: result, format = Template.env['report'].get_pdf([res_id], report_service), 'pdf' else: result, format = odoo_report.render_report(self._cr, self._uid, [res_id], report_service, {'model': template.model}, Template._context) # TODO in trunk, change return format to binary to match message_post expected format result = base64.b64encode(result) if not report_name: report_name = 'report.' + report_service ext = "." + format if not report_name.endswith(ext): report_name += ext attachments.append((report_name, result)) results[res_id]['attachments'] = attachments return multi_mode and results or results[res_ids[0]]
def test_00_payslip_flow(self): """ Testing payslip flow and report printing """ # I create an employee Payslip richard_payslip = self.env['hr.payslip'].create({ 'name': 'Payslip of Richard', 'employee_id': self.richard_emp.id }) payslip_input = self.env['hr.payslip.input'].search([ ('payslip_id', '=', richard_payslip.id) ]) # I assign the amount to Input data payslip_input.write({'amount': 5.0}) # I verify the payslip is in draft state self.assertEqual(richard_payslip.state, 'draft', 'State not changed!') context = { "lang": "en_US", "tz": False, "active_model": "ir.ui.menu", "department_id": False, "section_id": False, "active_ids": [self.ref("hr_payroll.menu_department_tree")], "active_id": self.ref("hr_payroll.menu_department_tree") } # I click on 'Compute Sheet' button on payslip richard_payslip.with_context(context).compute_sheet() # Then I click on the 'Confirm' button on payslip richard_payslip.action_payslip_done() # I verify that the payslip is in done state self.assertEqual(richard_payslip.state, 'done', 'State not changed!') # I want to check refund payslip so I click on refund button. richard_payslip.refund_sheet() # I check on new payslip Credit Note is checked or not. payslip_refund = self.env['hr.payslip'].search([ ('name', 'like', 'Refund: ' + richard_payslip.name), ('credit_note', '=', True) ]) self.assertTrue(bool(payslip_refund), "Payslip not refunded!") # I want to generate a payslip from Payslip run. payslip_run = self.env['hr.payslip.run'].create({ 'date_end': '2011-09-30', 'date_start': '2011-09-01', 'name': 'Payslip for Employee' }) # I create record for generating the payslip for this Payslip run. payslip_employee = self.env['hr.payslip.employees'].create( {'employee_ids': [(4, self.richard_emp.ids)]}) # I generate the payslip by clicking on Generat button wizard. payslip_employee.with_context(active_id=payslip_run.id).compute_sheet() # I open Contribution Register and from there I print the Payslip Lines report. self.env['payslip.lines.contribution.register'].create({ 'date_from': '2011-09-30', 'date_to': '2011-09-01' }) # I print the payslip report data, format = render_report(self.env.cr, self.env.uid, richard_payslip.ids, 'hr_payroll.report_payslip', {}, {}) if config.get('test_report_directory'): file( os.path.join(config['test_report_directory'], 'hr_payroll-payslip.' + format), 'wb+').write(data) # I print the payslip details report data, format = render_report(self.env.cr, self.env.uid, richard_payslip.ids, 'hr_payroll.report_payslipdetails', {}, {}) if config.get('test_report_directory'): file( os.path.join(config['test_report_directory'], 'hr_payroll-payslipdetails.' + format), 'wb+').write(data) # I print the contribution register report context = { 'model': 'hr.contribution.register', 'active_ids': [self.ref('hr_payroll.hr_houserent_register')] } test_reports.try_report_action( self.env.cr, self.env.uid, 'action_payslip_lines_contribution_register', context=context, our_module='hr_payroll')
def test_00_payslip_flow(self): """ Testing payslip flow and report printing """ # I create an employee Payslip richard_payslip = self.env['hr.payslip'].create({ 'name': 'Payslip of Richard', 'employee_id': self.richard_emp.id }) payslip_input = self.env['hr.payslip.input'].search([('payslip_id', '=', richard_payslip.id)]) # I assign the amount to Input data payslip_input.write({'amount': 5.0}) # I verify the payslip is in draft state self.assertEqual(richard_payslip.state, 'draft', 'State not changed!') context = { "lang": "en_US", "tz": False, "active_model": "ir.ui.menu", "department_id": False, "section_id": False, "active_ids": [self.ref("hr_payroll.menu_department_tree")], "active_id": self.ref("hr_payroll.menu_department_tree") } # I click on 'Compute Sheet' button on payslip richard_payslip.with_context(context).compute_sheet() # Then I click on the 'Confirm' button on payslip richard_payslip.action_payslip_done() # I verify that the payslip is in done state self.assertEqual(richard_payslip.state, 'done', 'State not changed!') # I want to check refund payslip so I click on refund button. richard_payslip.refund_sheet() # I check on new payslip Credit Note is checked or not. payslip_refund = self.env['hr.payslip'].search([('name', 'like', 'Refund: '+ richard_payslip.name), ('credit_note', '=', True)]) self.assertTrue(bool(payslip_refund), "Payslip not refunded!") # I want to generate a payslip from Payslip run. payslip_run = self.env['hr.payslip.run'].create({ 'date_end': '2011-09-30', 'date_start': '2011-09-01', 'name': 'Payslip for Employee' }) # I create record for generating the payslip for this Payslip run. payslip_employee = self.env['hr.payslip.employees'].create({ 'employee_ids': [(4, self.richard_emp.ids)] }) # I generate the payslip by clicking on Generat button wizard. payslip_employee.with_context(active_id=payslip_run.id).compute_sheet() # I open Contribution Register and from there I print the Payslip Lines report. self.env['payslip.lines.contribution.register'].create({ 'date_from': '2011-09-30', 'date_to': '2011-09-01' }) # I print the payslip report data, format = render_report(self.env.cr, self.env.uid, richard_payslip.ids, 'hr_payroll.report_payslip', {}, {}) if config.get('test_report_directory'): file(os.path.join(config['test_report_directory'], 'hr_payroll-payslip.'+ format), 'wb+').write(data) # I print the payslip details report data, format = render_report(self.env.cr, self.env.uid, richard_payslip.ids, 'hr_payroll.report_payslipdetails', {}, {}) if config.get('test_report_directory'): file(os.path.join(config['test_report_directory'], 'hr_payroll-payslipdetails.'+ format), 'wb+').write(data) # I print the contribution register report context = {'model': 'hr.contribution.register', 'active_ids': [self.ref('hr_payroll.hr_houserent_register')]} test_reports.try_report_action(self.env.cr, self.env.uid, 'action_payslip_lines_contribution_register', context=context, our_module='hr_payroll')
def setUp(self): super(TestExam, self).setUp() self.additional_exam_obj = self.env['additional.exam'] self.additional_exam_result_obj = self.env['additional.exam.result'] self.exam_exam_obj = self.env['exam.exam'] self.time_table_obj = self.env['time.table'] self.exam_result_obj = self.env['exam.result'] self.time_table_line_obj = self.env['time.table.line'] self.exam_schedule_line_obj = self.env['exam.schedule.line'] self.exam_subject_obj = self.env['exam.subject'] self.hr_employee = self.env.ref('hr.employee_al') self.subject_id = self.env.ref('school.demo_subject_subject_1') self.std = self.env.ref('school.demo_standard_standard_1') self.standards = self.env.ref('school.demo_school_standard_1') self.student = self.env.ref('school.demo_student_student_7') self.subject_id = self.env.ref('school.demo_subject_subject_1') self.year_id = self.env.ref('school.demo_academic_year_2') self.grade_system = self.env.ref('school.demo_student_grade_1') self.standard_std = self.env.ref('school.demo_standard_standard_2') self.school_standard = self.env.ref('school.demo_school_standard_2') self.student_student = self.env.ref('school.demo_student_student_5') self.grade_line = self.env.ref('school.demo_student_grade_line_6') # Create Exam Timetable self.time_table = self.time_table_obj.\ create({'name': 'Mid Term Exam', 'year_id': self.year_id.id, 'timetable_type': 'exam', 'standard_id': self.school_standard.id, }) # Create timetable line self.time_table_line = self.time_table_line_obj.\ create({'exm_date': time.strftime('06-01-2017'), 'day_of_week': 'Thursday', 'subject_id': self.subject_id.id, 'start_time': 10.00, 'end_time': 12.00, 'teacher_id': self.hr_employee.id, 'table_id': self.time_table.id }) self.time_table_line.onchange_date_day() self.time_table_line._check_date() # Create Exam self.exam_exam = self.exam_exam_obj.\ create({'exam_code': '2017/06/097', 'name': 'Mid Term Exam', 'academic_year': self.year_id.id, 'grade_system': self.grade_system.id, 'start_date': time.strftime('06-01-2017'), 'end_date': time.strftime('06-4-2017'), 'standard_id': [(6, 0, (self.standard_std.ids))] }) self.exam_schedule_line = self.exam_schedule_line_obj.\ create({'standard_id': self.school_standard.id, 'timetable_id': self.time_table.id, 'exam_id': self.exam_exam.id }) self.exam_schedule_line.onchange_standard() self.exam_exam.check_date_exam() self.exam_exam.check_active() self.exam_exam.set_to_draft() self.exam_exam.set_running() self.exam_exam.set_finish() self.exam_exam.set_cancel() self.exam_exam._validate_date() self.exam_exam.generate_result() # Create exam result self.exam_result = self.exam_result_obj.\ create({'s_exam_ids': self.exam_exam.id, 'student_id': self.student_student.id, 'standard_id': self.school_standard.id, 'roll_no_id': 2, 'grade_system': self.grade_system.id, 'total': 80, 'percentage': 40, 'grade': 'B-', 'result': 'Pass' }) self.exam_result._compute_total() self.exam_result._compute_per() self.exam_result._compute_result() self.exam_result.onchange_student() self.exam_result.result_confirm() self.exam_result.re_evaluation_confirm() self.exam_result.result_re_evaluation() self.exam_result.set_done() # Create Subject self.exam_subject = self.exam_subject_obj.\ create({'subject_id': self.subject_id.id, 'maximum_marks': 100, 'minimum_marks': 35, 'obtain_marks': 40, 'grade_line_id': self.grade_line.id, 'marks_reeval': 40, 'exam_id': self.exam_result.id }) self.exam_subject._compute_grade() self.exam_subject._validate_marks() # Create additional exam self.additional_exam = self.additional_exam_obj.\ create({'additional_exam_code': '2017/06/098', 'standard_id': self.std.id, 'name': 'New Additional Exam', 'subject_id': self.subject_id.id, 'maximum_marks': 100, 'minimum_marks': 35, 'exam_date': time.strftime('06-30-2012'), 'create_date': time.strftime('03-31-2012'), 'write_date': time.strftime('05-30-2012'), }) # Create additional exam result self.additional_exam_result = self.additional_exam_result_obj.\ create({'a_exam_id': self.additional_exam.id, 'student_id': self.student.id, 'obtain_marks': 65, 'result': 'Pass' }) self.additional_exam_result.onchange_student() self.additional_exam_result._validate_marks() self.additional_exam_result._compute_student_result() data, format = render_report(self.env.cr, self.env.uid, self.additional_exam_result.ids, 'exam.additional_exam_result_report', {}, {}) if config.get('test_report_directory'): file( os.path.join(config['test_report_directory'], 'Additional Exam Result.' + format), 'wb+').write(data)