Skip to content

Commit

Permalink
[17.0][UT] purchase_product_pack: test purchase order
Browse files Browse the repository at this point in the history
  • Loading branch information
antonyht27 committed May 31, 2024
1 parent 31c2f69 commit 7c7d755
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions purchase_product_pack/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
39 changes: 39 additions & 0 deletions purchase_product_pack/tests/test_purchase_order.py
Original file line number Diff line number Diff line change
@@ -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)


0 comments on commit 7c7d755

Please sign in to comment.