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.

70 lines
2.6 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2018 Tecnativa - David Vidal
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. from odoo.tests import common
  5. @common.at_install(False)
  6. @common.post_install(True)
  7. class TestPointOfSaleStockPickingInvoiceLink(common.HttpCase):
  8. def setUp(self):
  9. super(TestPointOfSaleStockPickingInvoiceLink, self).setUp()
  10. self.partner = self.env['res.partner'].create({
  11. 'name': 'Mr. Odoo',
  12. })
  13. self.product_1 = self.env['product.product'].create({
  14. 'name': 'Test variant 1',
  15. 'standard_price': 1.0,
  16. 'type': 'product',
  17. })
  18. self.product_2 = self.env['product.product'].create({
  19. 'name': 'Test variant 1',
  20. 'standard_price': 1.0,
  21. 'type': 'product',
  22. })
  23. self.PosOrder = self.env['pos.order']
  24. self.pos_config = self.env.ref('point_of_sale.pos_config_main')
  25. def test_stock_picking_invoice_link(self):
  26. """The picking is created and the lines are related to their moves"""
  27. self.pos_config.open_session_cb()
  28. pos_order = self.PosOrder.create({
  29. 'session_id': self.pos_config.current_session_id.id,
  30. 'partner_id': self.partner.id,
  31. 'pricelist_id': self.partner.property_product_pricelist.id,
  32. 'lines': [
  33. (0, 0, {
  34. 'name': "POSLINE/0001",
  35. 'product_id': self.product_1.id,
  36. 'price_unit': 450,
  37. 'qty': 2.0,
  38. }),
  39. (0, 0, {
  40. 'name': "POSLINE/0002",
  41. 'product_id': self.product_2.id,
  42. 'price_unit': 450,
  43. 'qty': 2.0,
  44. }),
  45. (0, 0, {
  46. 'name': "POSLINE/0003",
  47. 'product_id': self.product_1.id,
  48. 'price_unit': 450,
  49. 'qty': 2.0,
  50. }),
  51. ],
  52. })
  53. context_make_payment = {
  54. "active_ids": [pos_order.id],
  55. "active_id": pos_order.id,
  56. }
  57. pos_make_payment = self.env['pos.make.payment'].with_context(
  58. context_make_payment).create({'amount': 950})
  59. context_payment = {'active_id': pos_order.id}
  60. pos_make_payment.with_context(context_payment).check()
  61. pos_order.create_picking()
  62. res = pos_order.action_pos_order_invoice()
  63. invoice = self.env['account.invoice'].browse(res['res_id'])
  64. self.assertTrue(invoice.picking_ids)
  65. for line in invoice.invoice_line_ids:
  66. self.assertEqual(len(line.move_line_ids), 1)