Skip to content

Commit

Permalink
fixup! Imp p_main_supplierinfo default sellers for variant
Browse files Browse the repository at this point in the history
  • Loading branch information
TDu committed May 24, 2022
1 parent 42ac04a commit 1188715
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions product_main_supplierinfo/tests/test_product_main_supplier.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,68 @@ def setUpClass(cls):
cls.seller_2bis = cls.env.ref("product.product_supplierinfo_2bis")
cls.seller_2bis.sequence = 3
cls.company_2 = cls.env.company.create({"name": "Company2"})
# For the test case 4
cls.attribute = cls.env["product.attribute"].create({"name": "Size"})
cls.attribute_value_1 = cls.env["product.attribute.value"].create(
{"name": "L", "attribute_id": cls.attribute.id}
)
cls.attribute_value_2 = cls.env["product.attribute.value"].create(
{"name": "XL", "attribute_id": cls.attribute.id}
)
cls.template1 = cls.env["product.template"].create(
{
"name": "Hat",
"attribute_line_ids": [
(
0,
0,
{
"attribute_id": cls.attribute.id,
"value_ids": [
(
6,
0,
[
cls.attribute_value_1.id,
cls.attribute_value_2.id,
],
)
],
},
),
],
}
)
cls.product_1 = cls.template1.product_variant_ids[0]
cls.product_2 = cls.template1.product_variant_ids[1]
cls.date_old = "2000-01-01"
cls.date_older = "2000-12-31"
cls.product_template_supply = cls.seller_2.copy(
{
"product_tmpl_id": cls.product_2.product_tmpl_id.id,
"sequence": 1,
"date_start": cls.date_older,
"date_end": cls.date_old,
}
)
cls.product_1_supply = cls.seller_1.copy(
{
"product_tmpl_id": cls.product_1.product_tmpl_id.id,
"product_id": cls.product_1.id,
"sequence": 2,
"date_start": cls.date_older,
"date_end": cls.date_old,
}
)
cls.product_2_supply = cls.seller_2.copy(
{
"product_tmpl_id": cls.product_2.product_tmpl_id.id,
"product_id": cls.product_2.id,
"sequence": 3,
"date_start": cls.date_older,
"date_end": cls.date_old,
}
)

def test_main_seller_1(self):
""""Case 1: all the sellers share the same company."""
Expand Down Expand Up @@ -45,3 +107,8 @@ def test_main_seller_3(self):
self.seller_1.date_start = tomorrow
self.seller_2.date_end = yesterday
self.assertEqual(self.product.main_seller_id, self.seller_2bis)

def test_main_seller_4(self):
"""Case 4: No valid supplier so select one related to the variant."""
self.assertEqual(self.product_1.main_seller_id, self.product_1_supply)
self.assertEqual(self.product_2.main_seller_id, self.product_2_supply)

0 comments on commit 1188715

Please sign in to comment.