diff --git a/purchase_product_pack/tests/__init__.py b/purchase_product_pack/tests/__init__.py index d3ba0b783..1cc0319db 100644 --- a/purchase_product_pack/tests/__init__.py +++ b/purchase_product_pack/tests/__init__.py @@ -2,3 +2,4 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) from . import test_purchase_product_pack +from . import test_purchase_order diff --git a/purchase_product_pack/tests/test_purchase_order.py b/purchase_product_pack/tests/test_purchase_order.py new file mode 100644 index 000000000..3e49f07c0 --- /dev/null +++ b/purchase_product_pack/tests/test_purchase_order.py @@ -0,0 +1,39 @@ +from odoo.tests.common import TransactionCase +from odoo.exceptions import UserError + +class TestPurchaseOrder(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.purchase_order = cls.env["purchase.order"].create({ + "partner_id": cls.env.ref("base.res_partner_12").id, + }) + + cls.product = cls.env["product.product"].create({ + 'name': 'Test Product', + 'type': 'consu', + }) + + cls.pack_product = cls.env["product.product"].create({ + 'name': 'Pack Product', + 'type': 'consu', + 'pack_ok': True, + 'pack_type': 'detailed', + }) + + def test_copy_data(self): + order_line = self.env["purchase.order.line"].create({ + 'order_id': self.purchase_order.id, + 'product_id': self.product.id, + 'name': self.product.name, + 'product_qty': 1, + 'price_unit': 100, + }) + + data = self.purchase_order.copy_data() + self.assertTrue(data) + self.assertIn('order_line', data[0]) + self.assertEqual(len(data[0]['order_line']), 1) + self.assertEqual(data[0]['order_line'][0][2]['product_id'], self.product.id) + + \ No newline at end of file