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 import time class TestProductIdChange(AccountingTestCase): """Test that when an included tax is mapped by a fiscal position, the included tax must be subtracted to the price of the product. """ def setUp(self): super(TestProductIdChange, self).setUp() self.invoice_model = self.env['account.invoice'] self.fiscal_position_model = self.env['account.fiscal.position'] self.fiscal_position_tax_model = self.env['account.fiscal.position.tax'] self.tax_model = self.env['account.tax'] self.pricelist_model = self.env['product.pricelist'] self.res_partner_model = self.env['res.partner'] self.product_tmpl_model = self.env['product.template'] self.product_model = self.env['product.product'] self.invoice_line_model = self.env['account.invoice.line'] self.account_receivable = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_receivable').id)], limit=1) self.account_revenue = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_revenue').id)], limit=1) def test_product_id_change(self): partner = self.res_partner_model.create(dict(name="George")) tax_include_sale = self.tax_model.create(dict(name="Include tax", type_tax_use='sale', amount='21.00', price_include=True)) tax_include_purchase = self.tax_model.create(dict(name="Include tax", type_tax_use='purchase', amount='21.00', price_include=True)) tax_exclude_sale = self.tax_model.create(dict(name="Exclude tax", type_tax_use='sale', amount='0.00')) tax_exclude_purchase = self.tax_model.create(dict(name="Exclude tax", type_tax_use='purchase', amount='0.00')) product_tmpl = self.product_tmpl_model.create(dict(name="Voiture", list_price='121', taxes_id=[(6, 0, [tax_include_sale.id])], supplier_taxes_id=[(6, 0, [tax_include_purchase.id])])) product = self.product_model.create(dict(product_tmpl_id=product_tmpl.id, standard_price='242')) fp = self.fiscal_position_model.create(dict(name="fiscal position", sequence=1)) fp_tax_sale = self.fiscal_position_tax_model.create(dict(position_id=fp.id, tax_src_id=tax_include_sale.id, tax_dest_id=tax_exclude_sale.id)) fp_tax_purchase = self.fiscal_position_tax_model.create(dict(position_id=fp.id, tax_src_id=tax_include_purchase.id, tax_dest_id=tax_exclude_purchase.id)) out_invoice = self.invoice_model.create({ 'partner_id': partner.id, 'reference_type': 'none', 'name': 'invoice to client', 'account_id': self.account_receivable.id, 'type': 'out_invoice', 'date_invoice': time.strftime('%Y') + '-06-26', 'fiscal_position_id': fp.id, }) out_line = self.invoice_line_model.create({ 'product_id': product.id, 'quantity': 1, 'price_unit': 121.0, 'invoice_id': out_invoice.id, 'name': 'something out', 'account_id': self.account_revenue.id, }) in_invoice = self.invoice_model.create({ 'partner_id': partner.id, 'reference_type': 'none', 'name': 'invoice to supplier', 'account_id': self.account_receivable.id, 'type': 'in_invoice', 'date_invoice': time.strftime('%Y') + '-06-26', 'fiscal_position_id': fp.id, }) in_line = self.invoice_line_model.create({ 'product_id': product.id, 'quantity': 1, 'price_unit': 242.0, 'invoice_id': in_invoice.id, 'name': 'something in', 'account_id': self.account_revenue.id, }) out_line._onchange_product_id() self.assertEquals(100, out_line.price_unit, "The included tax must be subtracted to the price") in_line._onchange_product_id() self.assertEquals(200, in_line.price_unit, "The included tax must be subtracted to the price")