Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] sale_order_line_case_number: add tests #54

Merged
merged 2 commits into from
Feb 6, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sale_order_line_case_number/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_sale_order_line_case_number
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
from odoo.tests.common import TransactionCase


class TestSaleOrderLineCaseNumber(TransactionCase):
def setUp(self):
super(TestSaleOrderLineCaseNumber, self).setUp()
self.product1 = self.env["product.template"].create(
{
"name": "Product1",
"list_price": 100.00,
"default_code": "Test",
"case_number": "123",
}
)
self.product2 = self.env["product.template"].create(
{
"name": "Product2",
"list_price": 100.00,
"default_code": "Test2",
"case_number": "123",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"case_number": "123",
"case_number": "456",

To make the intention clearer.

}
)
self.partner = self.env["res.partner"].create({"name": "Customer - test"})

def _create_sale_order(self, product):
sale_order = self.env["sale.order"].create(
{
"partner_id": self.partner.id,
"order_line": [
(
0,
0,
{
"name": product.name,
"product_id": product.product_variant_ids.id,
"product_uom_qty": 1,
"price_unit": 100.00,
},
)
],
}
)
return sale_order

def test_sale_order_line_case_number(self):
order = self._create_sale_order(self.product1)
order_line = order.order_line
order_line.product_id_change()
self.assertEqual(order_line.name, "[Test][123] Product1")

order = self._create_sale_order(self.product2)
order_line = order.order_line
order_line.product_id_change()
self.assertEqual(order_line.name, "[Test2][123] Product2")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.assertEqual(order_line.name, "[Test2][123] Product2")
self.assertEqual(order_line.name, "[Test2][456] Product2")