Skip to content

Commit

Permalink
[FIX] stock_average_daily_sale: Don't test the not refreshed material…
Browse files Browse the repository at this point in the history
…ized view
  • Loading branch information
rousseldenis committed Oct 11, 2023
1 parent 08a8786 commit 7a4c896
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 20 deletions.
3 changes: 2 additions & 1 deletion stock_average_daily_sale/models/stock_average_daily_sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ def _check_view(self):
try:
cr = registry(self._cr.dbname).cursor()
new_self = self.with_env(self.env(cr=cr)) # TDE FIXME
new_self.env.cr.execute("SELECT COUNT(1) FROM %s", (AsIs(self._table),))
with new_self.env.cr.savepoint():
new_self.env.cr.execute("SELECT COUNT(1) FROM %s", (AsIs(self._table),))
return True
except ObjectNotInPrerequisiteState:
_logger.warning(
Expand Down
19 changes: 0 additions & 19 deletions stock_average_daily_sale/tests/test_average_daily_sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,22 +205,3 @@ def test_view_refreshed(self):
self.env["stock.average.daily.sale"].search_read(
[("product_id", "=", self.product_1.id)]
)

def test_view_not_refreshed(self):
with self.assertLogs(
"odoo.addons.stock_average_daily_sale.models.stock_average_daily_sale",
level="WARNING",
) as logger:
self.env["stock.average.daily.sale"].search(
[("product_id", "=", self.product_1.id)]
)
self.assertIn(
str("The materialized view has not been populated. Launch the cron."),
str(logger.output),
)
# Check if we can still query database
product = self.env["product.product"].search([("id", "=", self.product_1.id)])
self.assertEqual(
product,
self.product_1,
)

0 comments on commit 7a4c896

Please sign in to comment.