flectra/addons/stock_dropshipping/test/dropship.yml

77 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, 'SO should have procurement group'
-
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 flectra import netsvc
sale_record = self.env["sale.order"].browse(ref('sale_order_drp_shpng'))
purchase = self.env['purchase.order'].search([('partner_id', '=', ref('supplier_dropship'))])
branch = self.env['res.branch'].browse(ref('base_branch_company.data_branch_1'))
purchase.write({'branch_id': branch.id})
purchase.button_confirm()
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.move_lines.quantity_done = pickings.move_lines.product_qty
pickings.button_validate()
-
Check one move line was created in Customers location with 200 pieces
-
!python {model: stock.move.line, id: False}: |
move_line = self.search([('location_dest_id', '=', ref('stock.stock_location_customers')), ('product_id', '=', ref("drop_shop_product"))])
assert move_line, 'No move line found'
assert len(move_line.ids) == 1, 'There should be exactly one move line'