Skip to content

Commit

Permalink
[17.0][UPD] deltatech_sale tests
Browse files Browse the repository at this point in the history
  • Loading branch information
VoicuStefan2001 committed Aug 6, 2024
1 parent e87dc01 commit 4c33e77
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions deltatech_sale/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_sale
43 changes: 43 additions & 0 deletions deltatech_sale/tests/test_sale.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from odoo.exceptions import UserError
from odoo.tests import Form
from odoo.tests.common import TransactionCase


class TestSaleOrderLine(TransactionCase):
def setUp(self):
super().setUp()
# Set up the environment
self.Product = self.env["product.product"]
self.Partner = self.env["res.partner"]

# Create a product
self.product = self.Product.create(
{
"name": "Test Product",
"type": "consu",
"list_price": 100.0,
"standard_price": 50.0,
}
)

# Create a customer
self.partner = self.Partner.create(
{
"name": "Test Customer",
"email": "[email protected]",
}
)

def test_onchange_product_id_no_customer(self):
# Create a sale order without a customer
so = Form(self.env["sale.order"])
# Try to add a product to the sale order line without a customer
with self.assertRaises(UserError):
so.order_line.new()

def test_onchange_product_id_customer(self):
so = Form(self.env["sale.order"])
so.partner_id = self.partner
with so.order_line.new() as line_form:
line_form.product_id = self.product
line_form.product_uom_qty = 1

0 comments on commit 4c33e77

Please sign in to comment.