Server IP : 127.0.0.2 / Your IP : 18.221.172.197 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/stock/test/ |
Upload File : |
- Create a new stockable product - !record {model: product.product, id: product_wise}: name: Wise Unit type: product categ_id: product.product_category_1 uom_id: product.product_uom_unit uom_po_id: product.product_uom_unit - Create an incoming picking for this product of 10 PCE from suppliers to stock - !record {model: stock.picking, id: pick1_wise}: name: Incoming picking (wise unit) partner_id: base.res_partner_2 picking_type_id: picking_type_in move_lines: - product_id: product_wise product_uom_qty: 10.00 location_id: stock_location_suppliers location_dest_id: stock_location_stock - Confirm and assign picking and prepare partial - !python {model: stock.picking, id: pick1_wise}: | self.action_confirm() self.do_prepare_partial() - Put 6 pieces in shelf1 and 4 pieces in shelf2 - !python {model: stock.picking, id: pick1_wise}: | stock_pack = self.env['stock.pack.operation'] stock_quant_pack = self.env['stock.quant.package'] package1 = stock_quant_pack.create({'name': 'Pack 1'}) self.pack_operation_ids[0].write({ 'result_package_id': package1.id, 'product_qty': 4, 'location_dest_id': ref('stock_location_components') }) new_pack1 = stock_pack.create({ 'product_id': ref('product_wise'), 'product_uom_id': ref('product.product_uom_unit'), 'picking_id': ref('pick1_wise'), 'product_qty': 6.0, 'location_id': ref('stock_location_suppliers'), 'location_dest_id': ref('stock_location_14') }) - Transfer the receipt - !python {model: stock.picking, id: pick1_wise}: | self.do_transfer() - Check the system created 2 quants - !python {model: stock.quant, id: False}: | records = self.search([('product_id','=',ref('product_wise'))]) assert len(records.ids) == 2, "The number of quants created is not correct" - Make a delivery order of 5 pieces to the customer - !record {model: stock.picking, id: delivery_order_wise1}: name: outgoing picking 1 (wise unit) partner_id: base.res_partner_4 picking_type_id: stock.picking_type_out move_lines: - product_id: product_wise product_uom_qty: 5.0 location_id: stock_location_stock location_dest_id: stock_location_customers - Assign and confirm - !python {model: stock.picking, id: delivery_order_wise1}: | self.action_confirm() self.action_assign() - Make a delivery order of 5 pieces to the customer - !record {model: stock.picking, id: delivery_order_wise2}: name: outgoing picking 2 (wise unit) partner_id: base.res_partner_4 picking_type_id: stock.picking_type_out move_lines: - product_id: product_wise product_uom_qty: 5.0 location_id: stock_location_stock location_dest_id: stock_location_customers - Assign and confirm - !python {model: stock.picking, id: delivery_order_wise2}: | self.action_confirm() self.action_assign() - The operator is a wise guy and decides to do the opposite of what Odoo proposes. He uses the products reserved on picking 1 on picking 2 and vice versa - !python {model: stock.picking, id: False}: | stock_pack = self.env['stock.pack.operation'] picking1 = self.browse(ref('delivery_order_wise1')) picking2 = self.browse(ref('delivery_order_wise2')) pack_ids1 = [x.id for x in picking1.pack_operation_ids] pack_ids2 = [x.id for x in picking2.pack_operation_ids] self.env['stock.pack.operation'].browse(pack_ids1).write({'picking_id': picking2.id}) self.env['stock.pack.operation'].browse(pack_ids2).write({'picking_id': picking1.id}) link_obj = self.env['stock.move.operation.link'] # The recompute remaining qtys does not take into account that pack operations change picking links = link_obj.search([('operation_id', 'in', pack_ids1 + pack_ids2)]) links.unlink() - Process this picking - !python {model: stock.picking, id: delivery_order_wise1}: | self.do_transfer() - Check there was no negative quant created by this picking - !python {model: stock.quant, id: False}: | records = self.search([('product_id','=',ref('product_wise')), ('qty', '<', 0.0)]) assert len(records.ids) == 0, 'This should not have created a negative quant' - Check the other delivery order has changed its state back to partially available - !python {model: stock.picking, id: delivery_order_wise2}: | assert self.state == 'partially_available', "Delivery order 2 should be back in confirmed state" - Process the second picking - !python {model: stock.picking, id: delivery_order_wise2}: | self.do_transfer() - Check all quants are in Customers and there are no negative quants anymore - !python {model: stock.quant, id: False}: | records = self.search([('product_id','=',ref('product_wise'))]) assert all([x.location_id.id==ref('stock_location_customers') and x.qty > 0.0 for x in records]), "Negative quant or wrong location detected"