You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.9 KiB

7 years ago
  1. # -*- coding: utf-8 -*-
  2. # © 2016 Akretion France
  3. from odoo.tests.common import TransactionCase
  4. class TestSmsSendPicking(TransactionCase):
  5. def setUp(self):
  6. super(TestSmsSendPicking, self).setUp()
  7. self.partner = self.env['res.partner'].create({
  8. 'name': 'test man',
  9. 'mobile': '336789123',
  10. 'email': 'testcustomer+3@test.com',
  11. })
  12. self.product = self.env.ref('product.product_product_4')
  13. self.picking_out = self.env['stock.picking'].create({
  14. 'picking_type_id': self.ref('stock.picking_type_out'),
  15. 'location_id': self.env.ref('stock.stock_location_stock').id,
  16. 'location_dest_id': (
  17. self.env.ref('stock.stock_location_customers').id
  18. ),
  19. 'partner_id': self.partner.id
  20. })
  21. self.env['stock.move'].create({
  22. 'name': 'a move',
  23. 'product_id': self.product.id,
  24. 'product_uom_qty': 3.0,
  25. 'product_uom': self.product.uom_id.id,
  26. 'picking_id': self.picking_out.id,
  27. 'location_id': self.env.ref('stock.stock_location_stock').id,
  28. 'location_dest_id': (
  29. self.env.ref('stock.stock_location_customers').id
  30. )
  31. })
  32. self.picking_out.action_assign()
  33. self.picking_out.force_assign()
  34. def test_availability_flag(self):
  35. self.assertEqual(False, self.picking_out.availability_sent_by_sms)
  36. self.picking_out._cron_send_picking_availability_by_sms()
  37. self.assertEqual(True, self.picking_out.availability_sent_by_sms)
  38. def test_sms_created(self):
  39. dom = [('message', 'ilike',
  40. 'Your picking %s %%' % self.picking_out.name)]
  41. self.assertTrue(len(self.env['sms.sms'].search(dom)) == 0)
  42. self.picking_out._cron_send_picking_availability_by_sms()
  43. self.assertTrue(len(self.env['sms.sms'].search(dom)) == 1)