test_purchase_order_process.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. from .common import PurchaseTestCommon
  2. class TestPurchaseOrderProcess(PurchaseTestCommon):
  3. def test_00_cancel_purchase_order_flow(self):
  4. """ Test cancel purchase order with group user."""
  5. # In order to test the cancel flow,start it from canceling confirmed purchase order.
  6. purchase_order = self.env['purchase.order'].create({
  7. 'partner_id': self.env['res.partner'].create({'name': 'My Partner'}).id,
  8. 'state': 'draft',
  9. })
  10. po_edit_with_user = purchase_order.with_user(self.res_users_purchase_user)
  11. # Confirm the purchase order.
  12. po_edit_with_user.button_confirm()
  13. # Check the "Approved" status after confirmed RFQ.
  14. self.assertEqual(po_edit_with_user.state, 'purchase', 'Purchase: PO state should be "Purchase')
  15. # First cancel receptions related to this order if order shipped.
  16. po_edit_with_user.picking_ids.action_cancel()
  17. # Able to cancel purchase order.
  18. po_edit_with_user.button_cancel()
  19. # Check that order is cancelled.
  20. self.assertEqual(po_edit_with_user.state, 'cancel', 'Purchase: PO state should be "Cancel')
  21. def test_01_packaging_propagation(self):
  22. """Create a PO with lines using packaging, check the packaging propagate
  23. to its move.
  24. """
  25. product = self.env['product.product'].create({
  26. 'name': 'Product with packaging',
  27. 'type': 'product',
  28. })
  29. packaging = self.env['product.packaging'].create({
  30. 'name': 'box',
  31. 'product_id': product.id,
  32. })
  33. po = self.env['purchase.order'].create({
  34. 'partner_id': self.env['res.partner'].create({'name': 'My Partner'}).id,
  35. 'order_line': [
  36. (0, 0, {
  37. 'product_id': product.id,
  38. 'product_qty': 1.0,
  39. 'product_uom': product.uom_id.id,
  40. 'product_packaging_id': packaging.id,
  41. })],
  42. })
  43. po.button_confirm()
  44. self.assertEqual(po.order_line.move_ids.product_packaging_id, packaging)