|
5 | 5 | from odoo.exceptions import UserError
|
6 | 6 | from odoo.tests.common import TransactionCase
|
7 | 7 |
|
| 8 | +from odoo.addons.mail.tests.common import mail_new_test_user |
| 9 | + |
8 | 10 |
|
9 | 11 | class TestPurchaseManualDelivery(TransactionCase):
|
10 | 12 | def setUp(self):
|
@@ -357,3 +359,67 @@ def test_05_purchase_order_in_progress(self):
|
357 | 359 | location_ids=location.ids
|
358 | 360 | )
|
359 | 361 | self.assertEqual(qty.get((product_in_progress.id, location.id)), 3)
|
| 362 | + |
| 363 | + def test_06_purchase_order_manual_delivery_double_validation(self): |
| 364 | + """ |
| 365 | + Confirm Purchase Order 1, check no incoming shipments have been |
| 366 | + pre-created. Approve Purchase Order 1, check no incoming shipments |
| 367 | + have been pre-created. |
| 368 | + """ |
| 369 | + self.user_purchase_user = mail_new_test_user( |
| 370 | + self.env, |
| 371 | + name="Pauline Poivraisselle", |
| 372 | + login="pauline", |
| 373 | + email="pur@example.com", |
| 374 | + notification_type="inbox", |
| 375 | + groups="purchase.group_purchase_user", |
| 376 | + ) |
| 377 | + |
| 378 | + # make double validation two step |
| 379 | + self.env.company.write( |
| 380 | + {"po_double_validation": "two_step", "po_double_validation_amount": 2000.00} |
| 381 | + ) |
| 382 | + |
| 383 | + # Create draft RFQ |
| 384 | + po_vals = { |
| 385 | + "partner_id": self.ref("base.res_partner_3"), |
| 386 | + "order_line": [ |
| 387 | + ( |
| 388 | + 0, |
| 389 | + 0, |
| 390 | + { |
| 391 | + "name": self.product1.name, |
| 392 | + "product_id": self.product1.id, |
| 393 | + "product_qty": 5.0, |
| 394 | + "product_uom": self.product1.uom_po_id.id, |
| 395 | + "price_unit": 5000000.0, |
| 396 | + }, |
| 397 | + ) |
| 398 | + ], |
| 399 | + } |
| 400 | + self.po = ( |
| 401 | + self.env["purchase.order"] |
| 402 | + .with_user(self.user_purchase_user) |
| 403 | + .create(po_vals) |
| 404 | + ) |
| 405 | + |
| 406 | + # confirm RFQ |
| 407 | + self.po.button_confirm_manual() |
| 408 | + self.assertTrue(self.po.order_line.pending_to_receive) |
| 409 | + self.assertEqual(self.po.order_line.existing_qty, 0) |
| 410 | + self.assertFalse( |
| 411 | + self.po.picking_ids, |
| 412 | + "Purchase Manual Delivery: no picking should had been created", |
| 413 | + ) |
| 414 | + self.assertEqual(self.po.state, "to approve") |
| 415 | + |
| 416 | + # PO approved by manager |
| 417 | + self.po.env.user.groups_id += self.env.ref("purchase.group_purchase_manager") |
| 418 | + self.po.button_approve() |
| 419 | + self.assertTrue(self.po.order_line.pending_to_receive) |
| 420 | + self.assertEqual(self.po.order_line.existing_qty, 0) |
| 421 | + self.assertFalse( |
| 422 | + self.po.picking_ids, |
| 423 | + "Purchase Manual Delivery: no picking should had been created", |
| 424 | + ) |
| 425 | + self.assertEqual(self.po.state, "purchase") |
0 commit comments