test_sale.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # -*- coding: utf-8 -*-
  2. # © 2016 Cédric Pigeon, Acsone SA/NV (http://www.acsone.eu)
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. import openerp.tests.common as common
  5. class TestSale(common.TransactionCase):
  6. def setUp(self):
  7. common.TransactionCase.setUp(self)
  8. self.product_35 = self.env.ref("product.product_product_35")
  9. self.product_36 = self.env.ref("product.product_product_36")
  10. def test_import_product(self):
  11. """ Create SO
  12. Import products
  13. Check products are presents
  14. """
  15. so = self.env["sale.order"].create(
  16. {"partner_id": self.env.ref("base.res_partner_2").id,
  17. })
  18. wiz_obj = self.env['sale.import.products']
  19. wizard = wiz_obj.with_context(active_id=so.id,
  20. active_model='sale.order')
  21. products = [(6, 0, [self.product_35.id, self.product_36.id])]
  22. wizard_id = wizard.create({'products': products})
  23. wizard_id.create_items()
  24. wizard_id.items[0].quantity = 4
  25. wizard_id.items[1].quantity = 6
  26. wizard_id.select_products()
  27. self.assertEqual(len(so.order_line), 2)
  28. for line in so.order_line:
  29. if line.product_id.id == self.product_35.id:
  30. self.assertEqual(line.product_uom_qty, 4)
  31. else:
  32. self.assertEqual(line.product_uom_qty, 6)