Server IP : 127.0.0.2 / Your IP : 3.147.103.209 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/account/tests/ |
Upload File : |
from odoo.addons.account.tests.account_test_classes import AccountingTestCase from odoo.exceptions import Warning class TestAccountSupplierInvoice(AccountingTestCase): def test_supplier_invoice(self): tax = self.env['account.tax'].create({ 'name': 'Tax 10.0', 'amount': 10.0, 'amount_type': 'fixed', }) analytic_account = self.env['account.analytic.account'].create({ 'name': 'test account', }) # Should be changed by automatic on_change later invoice_account = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_receivable').id)], limit=1).id invoice_line_account = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_expenses').id)], limit=1).id invoice = self.env['account.invoice'].create({'partner_id': self.env.ref('base.res_partner_2').id, 'account_id': invoice_account, 'type': 'in_invoice', }) self.env['account.invoice.line'].create({'product_id': self.env.ref('product.product_product_4').id, 'quantity': 1.0, 'price_unit': 100.0, 'invoice_id': invoice.id, 'name': 'product that cost 100', 'account_id': invoice_line_account, 'invoice_line_tax_ids': [(6, 0, [tax.id])], 'account_analytic_id': analytic_account.id, }) # check that Initially supplier bill state is "Draft" self.assertTrue((invoice.state == 'draft'), "Initially vendor bill state is Draft") #change the state of invoice to open by clicking Validate button invoice.action_invoice_open() #I cancel the account move which is in posted state and verifies that it gives warning message with self.assertRaises(Warning): invoice.move_id.button_cancel() def test_supplier_invoice2(self): tax_fixed = self.env['account.tax'].create({ 'sequence': 10, 'name': 'Tax 10.0 (Fixed)', 'amount': 10.0, 'amount_type': 'fixed', 'include_base_amount': True, }) tax_percent_included_base_incl = self.env['account.tax'].create({ 'sequence': 20, 'name': 'Tax 50.0% (Percentage of Price Tax Included)', 'amount': 50.0, 'amount_type': 'division', 'include_base_amount': True, }) tax_percentage = self.env['account.tax'].create({ 'sequence': 30, 'name': 'Tax 20.0% (Percentage of Price)', 'amount': 20.0, 'amount_type': 'percent', 'include_base_amount': False, }) analytic_account = self.env['account.analytic.account'].create({ 'name': 'test account', }) # Should be changed by automatic on_change later invoice_account = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_receivable').id)], limit=1).id invoice_line_account = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_expenses').id)], limit=1).id invoice = self.env['account.invoice'].create({'partner_id': self.env.ref('base.res_partner_2').id, 'account_id': invoice_account, 'type': 'in_invoice', }) invoice_line = self.env['account.invoice.line'].create({'product_id': self.env.ref('product.product_product_4').id, 'quantity': 5.0, 'price_unit': 100.0, 'invoice_id': invoice.id, 'name': 'product that cost 100', 'account_id': invoice_line_account, 'invoice_line_tax_ids': [(6, 0, [tax_fixed.id, tax_percent_included_base_incl.id, tax_percentage.id])], 'account_analytic_id': analytic_account.id, }) invoice.compute_taxes() # check that Initially supplier bill state is "Draft" self.assertTrue((invoice.state == 'draft'), "Initially vendor bill state is Draft") #change the state of invoice to open by clicking Validate button invoice.action_invoice_open() # Check if amount and corresponded base is correct for all tax scenarios given on a computational base # Keep in mind that tax amount can be changed by the user at any time before validating (based on the invoice and tax laws applicable) invoice_tax = invoice.tax_line_ids.sorted(key=lambda r: r.sequence) self.assertEquals(invoice_tax.mapped('amount'), [50.0, 550.0, 220.0]) self.assertEquals(invoice_tax.mapped('base'), [500.0, 550.0, 1100.0]) #I cancel the account move which is in posted state and verifies that it gives warning message with self.assertRaises(Warning): invoice.move_id.button_cancel()