Server IP : 127.0.0.2 / Your IP : 18.116.47.33 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/delivery/tests/ |
Upload File : |
# -*- coding: utf-8 -*- from odoo.addons.account.tests.account_test_classes import AccountingTestCase class StockMoveInvoice(AccountingTestCase): def setUp(self): super(StockMoveInvoice, self).setUp() self.ProductProduct = self.env['product.product'] self.SaleOrder = self.env['sale.order'] self.AccountJournal = self.env['account.journal'] self.partner_18 = self.env.ref('base.res_partner_18') self.pricelist_id = self.env.ref('product.list0') self.product_11 = self.env.ref('product.product_product_11') self.product_icecream = self.env.ref('stock.product_icecream') self.product_uom_kgm = self.env.ref('product.product_uom_kgm') self.normal_delivery = self.env.ref('delivery.normal_delivery_carrier') def test_01_delivery_stock_move(self): # Test if the stored fields of stock moves are computed with invoice before delivery flow # Set a weight on ipod 16GB self.product_11.write({ 'weight': 0.25, }) self.sale_prepaid = self.SaleOrder.create({ 'partner_id': self.partner_18.id, 'partner_invoice_id': self.partner_18.id, 'partner_shipping_id': self.partner_18.id, 'pricelist_id': self.pricelist_id.id, 'order_line': [(0, 0, { 'name': 'Ice Cream', 'product_id': self.product_icecream.id, 'product_uom_qty': 2, 'product_uom': self.product_uom_kgm.id, 'price_unit': 750.00, })], 'carrier_id': self.normal_delivery.id }) # I add delivery cost in Sale order self.sale_prepaid.delivery_set() # I confirm the SO. self.sale_prepaid.action_confirm() self.sale_prepaid.action_invoice_create() # I check that the invoice was created self.assertEqual(len(self.sale_prepaid.invoice_ids), 1, "Invoice not created.") # I confirm the invoice self.invoice = self.sale_prepaid.invoice_ids self.invoice.action_invoice_open() # I pay the invoice. self.invoice = self.sale_prepaid.invoice_ids self.invoice.action_invoice_open() self.journal = self.AccountJournal.search([('type', '=', 'cash'), ('company_id', '=', self.sale_prepaid.company_id.id)], limit=1) self.invoice.pay_and_reconcile(self.journal, self.invoice.amount_total) # Check the SO after paying the invoice self.assertNotEqual(self.sale_prepaid.invoice_count, 0, 'order not invoiced') self.assertTrue(self.sale_prepaid.invoice_status == 'invoiced', 'order is not invoiced') self.assertEqual(len(self.sale_prepaid.picking_ids), 1, 'pickings not generated') # Check the stock moves moves = self.sale_prepaid.picking_ids.move_lines self.assertEqual(moves[0].product_qty, 2, 'wrong product_qty') self.assertEqual(moves[0].weight, 2.0, 'wrong move weight') # Ship self.picking = self.sale_prepaid.picking_ids.action_done()