[IMP] Maifest for Github README.md on main apps
[odoo/odoo.git] / addons / stock_dropshipping / test / dropship.yml
1 -
2     Create a supplier
3 -
4   !record {model: res.partner, id: supplier_dropship}:
5     name: Supplier of Dropshipping test
6
7     Create new product without any routes
8
9     !record {model: product.product, id: drop_shop_product}:
10         name: Pen drive
11         type: product
12         categ_id: product.product_category_1
13         list_price: 100.0
14         standard_price: 0.0
15         type: product
16         seller_ids:
17           - delay: 1
18             name: supplier_dropship
19             min_qty: 2.0
20             qty: 5.0
21         uom_id: product.product_uom_unit
22         uom_po_id: product.product_uom_unit
23
24     Create a sales order with a line of 200 PCE incoming shipment, with route_id drop shipping.
25
26     !record {model: sale.order, id: sale_order_drp_shpng}:
27           partner_id: base.res_partner_2
28           note: Create sale order for drop shipping
29           payment_term: account.account_payment_term
30           order_line: 
31             - product_id: drop_shop_product
32               product_uom_qty: 200
33               price_unit: 1.00
34               route_id: route_drop_shipping
35
36     Confirm sales order
37
38     !workflow {model: sale.order, action: order_confirm, ref: sale_order_drp_shpng}
39
40     Check the sales order created a procurement group which has a procurement of 200 pieces
41
42     !python {model: procurement.group}: |
43         sale_record = self.pool.get("sale.order").browse(cr, uid, ref('sale_order_drp_shpng'))
44         assert self.browse(cr, uid, sale_record.procurement_group_id.id).procurement_ids[0].product_qty == 200 
45 -
46   I run scheduler.
47 -
48   !python {model: procurement.order}: |
49     self.run_scheduler(cr, uid)
50
51     Check a quotation was created to a certain supplier and confirm so it becomes a confirmed purchase order
52 -
53     !python {model: purchase.order}: |
54         from openerp import netsvc, workflow
55         sale_record = self.pool.get("sale.order").browse(cr, uid, ref('sale_order_drp_shpng'))
56         procurement_order = self.pool.get("procurement.group").browse(cr, uid, sale_record.procurement_group_id.id).procurement_ids[0]
57         purchase_id = procurement_order.purchase_line_id.order_id.id
58         
59         workflow.trg_validate(uid, 'purchase.order', purchase_id, 'purchase_confirm', cr)
60         po_id = self.pool.get('purchase.order').search(cr, uid, [('partner_id', '=', ref('supplier_dropship'))])
61         assert self.browse(cr, uid, purchase_id).state == 'approved', 'Purchase order should be in the approved state'
62
63     Use 'Receive Products' button to immediately view this picking, it should have created a picking with 200 pieces
64 -
65     !python {model: purchase.order}: |
66          po_id = self.search(cr, uid, [('partner_id', '=', ref('supplier_dropship'))])
67          self.view_picking(cr, uid, po_id)
68 -
69     Send the 200 pieces.
70
71     !python {model: stock.picking}: |
72         po_id = self.pool.get('purchase.order').search(cr, uid, [('partner_id', '=', ref('supplier_dropship'))])
73         assert po_id and len(po_id) == 1, 'Problem with the Purchase Order detected'
74         picking_ids = [pick.id for pick in self.pool.get('purchase.order').browse(cr, uid, po_id[0]).picking_ids]
75         self.do_transfer(cr, uid, picking_ids)
76
77   Check one quant was created in Customers location with 200 pieces and one move in the history_ids
78
79     !python {model: stock.quant}: |
80         quant_ids = self.search(cr, uid, [('location_id', '=', ref('stock.stock_location_customers')),('qty', '=', 200), ('product_id', '=', ref("drop_shop_product"))])
81         assert quant_ids, 'No Quant found'
82         assert len(quant_ids) == 1
83         assert len(self.browse(cr, uid, quant_ids)[0].history_ids) == 1