from odoo.tests.common import TransactionCase


class TestProductAvailableLink(TransactionCase):
    def setUp(self):
        super().setUp()
        self.product = self.env["product.product"].create(
            {
                "name": "Test Product",
                "sale_ok": True,
                "available_in_pos": True,
            }
        )

    def test_uncheck_sale_ok_disables_available_in_pos(self):
        self.product.sale_ok = False
        self.assertFalse(self.product.available_in_pos)

    def test_write_sale_ok_false_disables_available_in_pos(self):
        self.product.write({"sale_ok": False})
        self.assertFalse(self.product.available_in_pos)
