Server IP : 127.0.0.2 / Your IP : 3.141.164.124 Web Server : Apache/2.4.18 (Ubuntu) System : User : www-data ( ) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /opt/odoo/addons/hr_expense/tests/ |
Upload File : |
# -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. from odoo.tests.common import TransactionCase class TestCheckJournalEntry(TransactionCase): """ Check journal entries when the expense product is having tax which is tax included. """ def setUp(self): super(TestCheckJournalEntry, self).setUp() self.tax = self.env['account.tax'].create({ 'name': 'Expense 10%', 'amount': 10, 'amount_type': 'percent', 'type_tax_use': 'purchase', 'price_include': True, }) self.product = self.env.ref('hr_expense.air_ticket') self.product.write({'supplier_taxes_id': [(6, 0, [self.tax.id])]}) self.employee = self.env.ref('hr.employee_mit') # Create payable account for the expense user_type = self.env.ref('account.data_account_type_payable') account_payable = self.env['account.account'].create({ 'code': 'X1111', 'name': 'HR Expense - Test Payable Account', 'user_type_id': user_type.id, 'reconcile': True }) self.employee.address_home_id.property_account_payable_id = account_payable.id # Create expenses account for the expense user_type = self.env.ref('account.data_account_type_expenses') account_expense = self.env['account.account'].create({ 'code': 'X2120', 'name': 'HR Expense - Test Purchase Account', 'user_type_id': user_type.id }) # Assign it to the air ticket product self.product.write({'property_account_expense_id': account_expense.id}) # Create Sale Journal company = self.env.ref('base.main_company') self.env['account.journal'].create({ 'name': 'Purchase Journal - Test', 'code': 'HRTPJ', 'type': 'purchase', 'company_id': company.id }) self.expense = self.env['hr.expense.sheet'].create({ 'name': 'Expense for John Smith', 'employee_id': self.employee.id, }) self.expense_line = self.env['hr.expense'].create({ 'name': 'Car Travel Expenses', 'employee_id': self.employee.id, 'product_id': self.product.id, 'unit_amount': 700.00, 'tax_ids': [(6, 0, [self.tax.id])], 'sheet_id': self.expense.id, }) def test_journal_entry(self): # Submitted to Manager self.assertEquals(self.expense.state, 'submit', 'Expense is not in Reported state') # Approve self.expense.approve_expense_sheets() self.assertEquals(self.expense.state, 'approve', 'Expense is not in Approved state') # Create Expense Entries self.expense.action_sheet_move_create() self.assertEquals(self.expense.state, 'post', 'Expense is not in Waiting Payment state') self.assertTrue(self.expense.account_move_id.id, 'Expense Journal Entry is not created') # [(line.debit, line.credit, line.tax_line_id.id) for line in self.expense.expense_line_ids.account_move_id.line_ids] # should git this result [(0.0, 700.0, False), (63.64, 0.0, 179), (636.36, 0.0, False)] for line in self.expense.account_move_id.line_ids: if line.credit: self.assertAlmostEquals(line.credit, 700.00) else: if not line.tax_line_id == self.tax: self.assertAlmostEquals(line.debit, 636.36) else: self.assertAlmostEquals(line.debit, 63.64)