|
1 | 1 | # Copyright 2023 ACSONE SA/NV |
| 2 | +# Copyright 2025 Michael Tietz (MT Software) <mtietz@mt-software.de> |
2 | 3 | # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
3 | 4 |
|
4 | 5 |
|
@@ -125,3 +126,25 @@ def test_draft_sale_order_with_picking_cancel(self): |
125 | 126 | self.assertEqual(sale.order_line.product_qty_canceled, 0) |
126 | 127 | self.assertEqual(sale.order_line.qty_to_deliver, 10) |
127 | 128 | self.assertEqual(sale.order_line.product_qty_remains_to_deliver, 10) |
| 129 | + |
| 130 | + def test_cancel_decrease_product_uom_qty(self): |
| 131 | + sale = self.sale |
| 132 | + sale.company_id.on_sale_line_cancel_decrease_line_qty = True |
| 133 | + sale.with_context(disable_cancel_warning=True).action_cancel() |
| 134 | + sale.picking_ids.unlink() |
| 135 | + sale.action_draft() |
| 136 | + sale.action_confirm() |
| 137 | + line = self.sale.order_line |
| 138 | + self.assertEqual(line.product_uom_qty, 10) |
| 139 | + ship = self.sale.picking_ids |
| 140 | + ship.action_assign() |
| 141 | + ship.move_ids.move_line_ids.qty_done = 5 |
| 142 | + ship.with_context(cancel_backorder=False)._action_done() |
| 143 | + self.wiz.with_context( |
| 144 | + active_id=line.id, active_model="sale.order.line" |
| 145 | + ).cancel_remaining_qty() |
| 146 | + self.assertEqual(line.product_qty_canceled, 0) |
| 147 | + self.assertEqual(line.product_qty_remains_to_deliver, 0) |
| 148 | + self.assertEqual(line.qty_to_deliver, 0) |
| 149 | + self.assertEqual(line.qty_delivered, 5) |
| 150 | + self.assertEqual(line.product_uom_qty, 5) |
0 commit comments