mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[FIX] stock_location_product_restriction: Don't fetch if ids are void
This commit is contained in:
committed by
Laurent Mignon (ACSONE)
parent
f0d683870c
commit
bd25f471b3
@@ -86,8 +86,15 @@ class StockLocation(models.Model):
|
||||
stock_quant.location_id
|
||||
HAVING count(distinct(product_id)) > 1
|
||||
"""
|
||||
self.env.cr.execute(SQL, (tuple(records.ids),))
|
||||
product_ids_by_location_id = dict(self.env.cr.fetchall())
|
||||
# Browse only real record ids
|
||||
ids = tuple(
|
||||
[record.id for record in records if not isinstance(record.id, fields.NewId)]
|
||||
)
|
||||
if not ids:
|
||||
product_ids_by_location_id = dict()
|
||||
else:
|
||||
self.env.cr.execute(SQL, (ids,))
|
||||
product_ids_by_location_id = dict(self.env.cr.fetchall())
|
||||
for record in self:
|
||||
record_id = record.id
|
||||
has_restriction_violation = False
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# Copyright 2020 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo.tests.common import TransactionCase
|
||||
from odoo.tests.common import Form, TransactionCase
|
||||
|
||||
|
||||
class TestStockLocation(TransactionCase):
|
||||
@@ -258,3 +257,8 @@ class TestStockLocation(TransactionCase):
|
||||
self.loc_lvl_1_1_1.flush_recordset()
|
||||
self.assertTrue(self.loc_lvl_1_1_1.has_restriction_violation)
|
||||
self.assertTrue(self.loc_lvl_1_1_1.restriction_violation_message)
|
||||
|
||||
def test_05(self):
|
||||
# Check location creation
|
||||
with Form(self.StockLocation) as location_form:
|
||||
location_form.name = "Test"
|
||||
|
||||
Reference in New Issue
Block a user