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.

72 lines
2.9 KiB

  1. # coding: utf-8
  2. # Copyright (C) 2017: Opener B.V. (https://opener.amsterdam)
  3. # @author: Stefan Rijnhart <stefan@opener.am>
  4. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  5. from openerp.tests.common import TransactionCase
  6. class TestPosPickingLoad(TransactionCase):
  7. def test_pos_picking_load(self):
  8. product = self.env.ref('product.product_product_24')
  9. sale_order = self.env['sale.order'].create({
  10. 'partner_id': self.env.ref('base.res_partner_1').id,
  11. 'order_line': [(0, 0, {
  12. 'product_id': product.id,
  13. 'price_unit': 6,
  14. 'product_uom_qty': 2,
  15. })],
  16. 'order_policy': 'picking',
  17. })
  18. sale_order.action_button_confirm()
  19. self.assertTrue(sale_order.picking_ids)
  20. sale_order.picking_ids.picking_type_id.write({
  21. 'available_in_pos': True})
  22. config = self.env.ref('point_of_sale.pos_config_main').copy()
  23. config.write({
  24. 'picking_type_id': sale_order.picking_ids.picking_type_id.id})
  25. session = self.env['pos.session'].create({
  26. 'user_id': self.env.user.id,
  27. 'config_id': config.id})
  28. session.signal_workflow('open')
  29. self.env['pos.order'].create_from_ui([{
  30. 'to_invoice': False,
  31. 'data': {
  32. 'user_id': self.env.user.id,
  33. 'name': 'Order 00017-002-0003',
  34. 'partner_id': sale_order.partner_id.id,
  35. 'amount_paid': 12,
  36. 'pos_session_id': session.id,
  37. 'lines': [[0, 0, {
  38. 'product_id': product.id,
  39. 'price_unit': 6,
  40. 'name': product.name,
  41. 'discount': 0,
  42. 'qty': 2,
  43. 'tax_ids': [[6, False, []]],
  44. }]],
  45. 'statement_ids': [[0, 0, {
  46. 'journal_id': False,
  47. 'amount': 12,
  48. 'name': '2017-07-20 13:08:37',
  49. 'account_id': config.journal_ids[
  50. 0].default_debit_account_id.id,
  51. 'statement_id': session.statement_ids[0].id,
  52. }]],
  53. 'amount_tax': 0,
  54. 'origin_picking_id': sale_order.picking_ids.id,
  55. 'uid': '00017-002-0003',
  56. 'amount_return': 0,
  57. 'sequence_number': 3,
  58. 'amount_total': 12,
  59. },
  60. 'id': '00017-002-0003',
  61. }])
  62. pos_order = self.env['pos.order'].search(
  63. [('origin_picking_id', 'in', sale_order.picking_ids.ids)])
  64. self.assertTrue(pos_order)
  65. self.assertEqual(pos_order.origin_picking_id.state, 'cancel')
  66. self.assertIn(pos_order.picking_id, sale_order.picking_ids)
  67. self.assertEqual(
  68. pos_order.picking_id.group_id,
  69. pos_order.origin_picking_id.group_id)