Created
October 9, 2015 01:27
-
-
Save zaoral/bb465161a5efda1f98d5 to your computer and use it in GitHub Desktop.
stock_forecast demo check
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - | |
| Check if the products used in the demo have quants associated. | |
| - | |
| !python {model: stock.picking, id: False}: | | |
| # Get all products information about quants | |
| product_obj = self.env['product.product'] | |
| quant_obj = self.env['stock.quant'] | |
| products = product_obj.search([]) | |
| products_w_quants = quant_obj.search([]).mapped('product_id') | |
| products_wo_quants = products - products_w_quants | |
| # Get browseables of the product used in the test. | |
| products_demo = product_obj.browse([ | |
| ref('product.product_product_3'), | |
| ref('product.product_product_5'), | |
| ref('product.product_product_8'), | |
| ref('product.product_product_4'), | |
| ref('product.product_product_11b'), | |
| ]) | |
| errors = [] | |
| # Check that the demo product have not pre-exist quants | |
| for product_demo in products_demo: | |
| if product_demo in products_w_quants: | |
| errors.append(product_demo) | |
| if errors: | |
| assert False, ('Can not use the next products as demo' + | |
| '\n- '.join([product.display_name for product in errors])) | |
| - | |
| Create a picking with past date | |
| - | |
| !record {model: stock.picking, id: new_test_date}: | |
| origin: 'Just testing' | |
| picking_type_id: stock.picking_type_in | |
| date: '2015-01-01 01:49:51' | |
| partner_id: base.res_partner_3 | |
| move_lines: | |
| - name: Just testing line | |
| product_id: product.product_product_3 | |
| product_uom: product.product_uom_unit | |
| picking_type_id: stock.picking_type_in | |
| product_uom_qty: 46900 | |
| location_dest_id: stock.stock_location_stock | |
| location_id: stock.stock_location_suppliers | |
| date: '2015-01-01 01:49:51' | |
| - | |
| Confirm picking | |
| - | |
| !python {model: stock.picking, id: False}: | | |
| picking = self.browse(ref('new_test_date')) | |
| picking.action_confirm() | |
| picking.do_transfer() | |
| assert set(picking.mapped('state')) == set(['done']), 'initial picking are not complete done' | |
| quants = picking.move_lines.mapped('quant_ids') | |
| quant_in_date = quants.mapped('in_date') | |
| print quant_in_date |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment