odoo/addons/stock_dropshipping/test/dropship.yml

79 lines
3.2 KiB
YAML

-
Create a vendor
-
!record {model: res.partner, id: supplier_dropship}:
name: Vendor of Dropshipping test
-
Create new product without any routes
-
!record {model: product.product, id: drop_shop_product, view: False}:
name: Pen drive
type: product
categ_id: product.product_category_1
list_price: 100.0
standard_price: 0.0
type: product
seller_ids:
- delay: 1
name: supplier_dropship
min_qty: 2.0
uom_id: product.product_uom_unit
uom_po_id: product.product_uom_unit
-
Create a sales order with a line of 200 PCE incoming shipment, with route_id drop shipping.
-
!record {model: sale.order, id: sale_order_drp_shpng}:
partner_id: base.res_partner_2
note: Create sale order for drop shipping
payment_term_id: account.account_payment_term
order_line:
- product_id: drop_shop_product
product_uom_qty: 200
price_unit: 1.00
route_id: route_drop_shipping
-
Confirm sales order
-
!python {model: sale.order, id: sale_order_drp_shpng}: |
self.action_confirm()
-
Check the sales order created a procurement group which has a procurement of 200 pieces
-
!python {model: procurement.group, id: False}: |
sale_record = self.env["sale.order"].browse(ref('sale_order_drp_shpng'))
assert sale_record.procurement_group_id.procurement_ids[0].product_qty == 200
-
Check a quotation was created to a certain vendor and confirm so it becomes a confirmed purchase order
-
!python {model: purchase.order, id: False}: |
from odoo import netsvc
sale_record = self.env["sale.order"].browse(ref('sale_order_drp_shpng'))
procurement_order = sale_record.procurement_group_id.procurement_ids[0]
purchase = procurement_order.purchase_line_id.order_id
purchase.button_confirm()
po_id = self.env['purchase.order'].search([('partner_id', '=', ref('supplier_dropship'))])
assert purchase.state == 'purchase', 'Purchase order should be in the approved state'
-
Use 'Receive Products' button to immediately view this picking, it should have created a picking with 200 pieces
-
!python {model: purchase.order, id: False}: |
po_id = self.search([('partner_id', '=', ref('supplier_dropship'))]).ids
assert len(po_id) == 1, 'There should be one picking'
-
Send the 200 pieces.
-
!python {model: stock.picking, id: False}: |
po = self.env['purchase.order'].search([('partner_id', '=', ref('supplier_dropship'))])
assert po.ids and len(po.ids) == 1, 'Problem with the Purchase Order detected'
pickings = po[0].picking_ids
pickings.do_transfer()
-
Check one quant was created in Customers location with 200 pieces and one move in the history_ids
-
!python {model: stock.quant, id: False}: |
quants = self.search([('location_id', '=', ref('stock.stock_location_customers')), ('product_id', '=', ref("drop_shop_product"))])
assert quants, 'No Quant found'
assert len(quants.ids) == 1, 'There should be exactly one quant'
assert len(quants[0].history_ids) == 1, 'The quant should have exactly 1 move in its history'