Skip to content

Commit

Permalink
[FIX] product_barcode_constraint_per_company
Browse files Browse the repository at this point in the history
Fix test
  • Loading branch information
dessanhemrayev authored and geomer198 committed Nov 10, 2023
1 parent 9d5fa9f commit 5431e29
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions product_barcode_constraint_per_company/tests/test_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from psycopg2 import IntegrityError

from odoo.tests.common import SavepointCase
from odoo import _
from odoo.tests.common import SavepointCase, tagged
from odoo.tools.misc import mute_logger


@tagged("post_install", "-at_install")
class TestModule(SavepointCase):
@classmethod
def setUpClass(cls):
Expand All @@ -22,9 +24,11 @@ def test_create_same_company(self):
product_1 = self._create_product("Product 11", self.company_1)
self.assertEqual(product_1.company_id, self.company_1)
self.assertEqual(product_1.product_tmpl_id.company_id, self.company_1)

with self.assertRaises(IntegrityError), mute_logger("odoo.sql_db"):
self._create_product("Product 12", self.company_1)
with mute_logger("odoo.sql_db"), self.assertRaises(
IntegrityError,
msg=_("A barcode can only be assigned to one product per company !"),
):
self._create_product("Product 2", self.company_1)

def test_create_different_company(self):
product_1 = self._create_product("Product 21", self.company_1)
Expand Down

0 comments on commit 5431e29

Please sign in to comment.