mirror of
https://github.com/OCA/stock-logistics-reporting.git
synced 2025-02-16 17:13:21 +02:00
[FIX] stock_average_daily_sale: Don't check the view existence in tests
As tests create a Savepoint, there is a concurrent query when checking the view existence.
This commit is contained in:
committed by
twalter-c2c
parent
ce97bf0ef3
commit
0c2f631a4c
@@ -7,6 +7,7 @@ from psycopg2.errors import ObjectNotInPrerequisiteState
|
||||
from psycopg2.extensions import AsIs
|
||||
|
||||
from odoo import _, api, fields, models, registry
|
||||
from odoo.tools import config
|
||||
|
||||
from odoo.addons.stock_storage_type_putaway_abc.models.stock_location import (
|
||||
ABC_SELECTION,
|
||||
@@ -118,7 +119,7 @@ class StockAverageDailySale(models.Model):
|
||||
# pylint: disable=redefined-outer-name
|
||||
@api.model
|
||||
def search(self, domain, offset=0, limit=None, order=None, count=False):
|
||||
if not self._check_view():
|
||||
if not config["test_enable"] and not self._check_view():
|
||||
return self.browse()
|
||||
return super().search(
|
||||
domain=domain, offset=offset, limit=limit, order=order, count=count
|
||||
|
||||
@@ -186,17 +186,6 @@ class TestAverageSale(CommonAverageSaleTest, TransactionCase):
|
||||
)
|
||||
self.assertFalse(avg_product_2)
|
||||
|
||||
def test_view(self):
|
||||
# Check no exception is raised if materialized view is not loaded
|
||||
with self.assertLogs(
|
||||
"odoo.addons.stock_average_daily_sale.models.stock_average_daily_sale"
|
||||
) as log:
|
||||
result = self.env["stock.average.daily.sale"].search_read(
|
||||
[("product_id", "=", self.product_1.id)]
|
||||
)
|
||||
self.assertFalse(result)
|
||||
self.assertIn("The materialized view has not been populated", log.output[0])
|
||||
|
||||
def test_view_refreshed(self):
|
||||
self._refresh()
|
||||
with self.assertNoLogs(
|
||||
|
||||
Reference in New Issue
Block a user