mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[REF] rma: change rules by routes in warehouse
This commit is contained in:
committed by
AaronHForgeFlow
parent
758a2a7d3f
commit
e33ffe9280
@@ -1069,7 +1069,101 @@ class TestRma(common.TransactionCase):
|
||||
with self.assertRaisesRegex(ValidationError, "No quantity to transfer"):
|
||||
wizard._create_picking()
|
||||
|
||||
def test_08_supplier_rma_single_line(self):
|
||||
def test_08_customer_rma_multi_step(self):
|
||||
"""
|
||||
Receive a product and then return it using a multi-step route.
|
||||
"""
|
||||
# Alter the customer RMA route to make it multi-step
|
||||
# Get rid of the duplicated rule
|
||||
self.env.ref("rma.rule_rma_customer_out_pull").active = False
|
||||
self.env.ref("rma.rule_rma_customer_in_pull").active = False
|
||||
cust_in_pull_rule = self.customer_route.rule_ids.filtered(
|
||||
lambda r: r.location_id == self.stock_rma_location
|
||||
)
|
||||
cust_in_pull_rule.location_id = self.input_location
|
||||
cust_out_pull_rule = self.customer_route.rule_ids.filtered(
|
||||
lambda r: r.location_src_id == self.env.ref("rma.location_rma")
|
||||
)
|
||||
cust_out_pull_rule.location_src_id = self.output_location
|
||||
cust_out_pull_rule.procure_method = "make_to_order"
|
||||
self.env["stock.rule"].create(
|
||||
{
|
||||
"name": "RMA->Output",
|
||||
"action": "pull",
|
||||
"warehouse_id": self.wh.id,
|
||||
"location_src_id": self.env.ref("rma.location_rma").id,
|
||||
"location_id": self.output_location.id,
|
||||
"procure_method": "make_to_stock",
|
||||
"route_id": self.customer_route.id,
|
||||
"picking_type_id": self.env.ref("stock.picking_type_internal").id,
|
||||
}
|
||||
)
|
||||
self.env["stock.rule"].create(
|
||||
{
|
||||
"name": "Output->Customer",
|
||||
"action": "pull",
|
||||
"warehouse_id": self.wh.id,
|
||||
"location_src_id": self.output_location.id,
|
||||
"location_id": self.customer_location.id,
|
||||
"procure_method": "make_to_order",
|
||||
"route_id": self.customer_route.id,
|
||||
"picking_type_id": self.env.ref("stock.picking_type_internal").id,
|
||||
}
|
||||
)
|
||||
self.env["stock.rule"].create(
|
||||
{
|
||||
"name": "Customer->Input",
|
||||
"action": "pull",
|
||||
"warehouse_id": self.wh.id,
|
||||
"location_src_id": self.customer_location.id,
|
||||
"location_id": self.input_location.id,
|
||||
"procure_method": "make_to_stock",
|
||||
"route_id": self.customer_route.id,
|
||||
"picking_type_id": self.env.ref("stock.picking_type_internal").id,
|
||||
}
|
||||
)
|
||||
self.env["stock.rule"].create(
|
||||
{
|
||||
"name": "Input->RMA",
|
||||
"action": "pull",
|
||||
"warehouse_id": self.wh.id,
|
||||
"location_src_id": self.input_location.id,
|
||||
"location_id": self.env.ref("rma.location_rma").id,
|
||||
"procure_method": "make_to_order",
|
||||
"route_id": self.customer_route.id,
|
||||
"picking_type_id": self.env.ref("stock.picking_type_internal").id,
|
||||
}
|
||||
)
|
||||
# Set a standard price on the products
|
||||
self.product_1.standard_price = 10
|
||||
self._create_inventory(
|
||||
self.product_1, 20.0, self.env.ref("stock.stock_location_customers")
|
||||
)
|
||||
products2move = [
|
||||
(self.product_1, 3),
|
||||
]
|
||||
self.product_1.categ_id.rma_customer_operation_id = self.rma_cust_replace_op_id
|
||||
rma_customer_id = self._create_rma_from_move(
|
||||
products2move,
|
||||
"customer",
|
||||
self.env.ref("base.res_partner_2"),
|
||||
dropship=False,
|
||||
)
|
||||
rma = rma_customer_id.rma_line_ids
|
||||
rma.action_rma_to_approve()
|
||||
self.assertEqual(rma.qty_to_receive, 3)
|
||||
self.assertEqual(rma.qty_received, 0)
|
||||
self._receive_rma(rma)
|
||||
self.assertEqual(len(rma.move_ids), 2)
|
||||
self.assertEqual(rma.qty_to_receive, 0)
|
||||
self.assertEqual(rma.qty_received, 3)
|
||||
self.assertEqual(rma.qty_to_deliver, 3)
|
||||
self._deliver_rma(rma)
|
||||
self.assertEqual(rma.qty_to_deliver, 0)
|
||||
self.assertEqual(rma.qty_delivered, 3)
|
||||
self.assertEqual(len(rma.move_ids), 4)
|
||||
|
||||
def test_09_supplier_rma_single_line(self):
|
||||
rma_line_id = self.rma_supplier_id.rma_line_ids[0].id
|
||||
wizard = self.rma_make_picking.with_context(
|
||||
active_ids=[rma_line_id],
|
||||
|
||||
Reference in New Issue
Block a user