Server IP : 127.0.0.2 / Your IP : 3.138.36.87 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_users import AccountTestUsers class TestSearch(AccountTestUsers): """Tests for search on name_search (account.account) The name search on account.account is quite complexe, make sure we have all the correct results """ def test_name_search(self): ac_ids = self.account_type_model.search([], limit=1) self.atax = self.account_model.create(dict( name="Tax Received", code="X121", user_type_id=ac_ids.id, reconcile=True, )).id, "X121 Tax Received" self.apurchase = self.account_model.create(dict( name="Purchased Stocks", code="X1101", user_type_id=ac_ids.id, reconcile=True, )).id, "X1101 Purchased Stocks" self.asale = self.account_model.create(dict( name="Product Sales", code="XX200", user_type_id=ac_ids.id, reconcile=True, )).id, "XX200 Product Sales" self.all_ids = [self.atax[0], self.apurchase[0], self.asale[0]] atax_ids = self.account_model.name_search(name="Tax", operator='ilike', args=[('id', 'in', self.all_ids)]) self.assertEqual(set([self.atax[0]]), set([a[0] for a in atax_ids]), "name_search 'ilike Tax' should have returned Tax Received account only") atax_ids = self.account_model.name_search(name="Tax", operator='not ilike', args=[('id', 'in', self.all_ids)]) self.assertEqual(set([self.apurchase[0], self.asale[0]]), set([a[0] for a in atax_ids]), "name_search 'not ilike Tax' should have returned all but Tax Received account") apur_ids = self.account_model.name_search(name='Purchased Stocks', operator='ilike', args=[('id', 'in', self.all_ids)]) self.assertEqual(set([self.apurchase[0]]), set([a[0] for a in apur_ids]), "name_search 'ilike Purchased Stocks' should have returned Purchased Stocks account only") apur_ids = self.account_model.name_search(name='Purchased Stocks', operator='not ilike', args=[('id', 'in', self.all_ids)]) self.assertEqual(set([self.atax[0], self.asale[0]]), set([a[0] for a in apur_ids]), "name_search 'not ilike X1101' should have returned all but Purchased Stocks account") asale_ids = self.account_model.name_search(name='Product Sales', operator='ilike', args=[('id', 'in', self.all_ids)]) self.assertEqual(set([self.asale[0]]), set([a[0] for a in asale_ids]), "name_search 'ilike 200 Sales' should have returned Product Sales account only") asale_ids = self.account_model.name_search(name='Product Sales', operator='not ilike', args=[('id', 'in', self.all_ids)]) self.assertEqual(set([self.atax[0], self.apurchase[0]]), set([a[0] for a in asale_ids]), "name_search 'not ilike 200 Sales' should have returned all but Product Sales account") asale_ids = self.account_model.name_search(name='XX200', operator='ilike', args=[('id', 'in', self.all_ids)]) self.assertEqual(set([self.asale[0]]), set([a[0] for a in asale_ids]), "name_search 'ilike XX200' should have returned Product Sales account only") def test_property_unset_search(self): res_partner_model = self.env['res.partner'] account_payment_term_model = self.env['account.payment.term'] a_partner = res_partner_model.create({'name': 'test partner'}) a_payment_term = account_payment_term_model.create({'name': 'test payment term'}) partners = res_partner_model.search([('property_payment_term_id', '=', False), ('id', '=', a_partner.id)]) self.assertTrue(partners, "unset property field 'propety_payment_term' should have been found") a_partner.write({'property_payment_term_id': a_payment_term}) partners = res_partner_model.search([('property_payment_term_id', '=', False), ('id', '=', a_partner.id)]) self.assertFalse(partners, "set property field 'propety_payment_term' should not have been found")