From 87b5563cfffb76fc2bdd93149bb9e42a539ad0ed Mon Sep 17 00:00:00 2001 From: Suherdy Yacob Date: Tue, 10 Mar 2026 11:49:41 +0700 Subject: [PATCH] refactor: update stock quantity report domain logic to use `odoo.fields.Domain` and add `purchase` module dependency. --- __manifest__.py | 2 +- models/report_stock_quantity.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/__manifest__.py b/__manifest__.py index 20bf56c..c7e40cd 100644 --- a/__manifest__.py +++ b/__manifest__.py @@ -16,7 +16,7 @@ """, 'category': 'Extra Tools', 'author': 'Suherdy Yacob', - 'depends': ['base', 'stock', 'mrp', 'approvals', 'stock_account', 'sale', 'quality_mrp'], + 'depends': ['base', 'stock', 'mrp', 'approvals', 'stock_account', 'sale', 'quality_mrp', 'purchase'], 'data': [ 'security/ir.model.access.csv', 'security/ir_rule.xml', diff --git a/models/report_stock_quantity.py b/models/report_stock_quantity.py index 03ccfb0..21fd006 100644 --- a/models/report_stock_quantity.py +++ b/models/report_stock_quantity.py @@ -1,5 +1,5 @@ from odoo import models, api -from odoo.osv import expression +from odoo.fields import Domain class ReportStockQuantity(models.Model): _inherit = 'report.stock.quantity' @@ -13,7 +13,7 @@ class ReportStockQuantity(models.Model): allowed_wh = user.allowed_warehouse_ids | user.allowed_location_ids.warehouse_id # If user has specific allowed warehouses/locations, restrict report if allowed_wh: - domain = expression.AND([domain, [('warehouse_id', 'in', allowed_wh.ids)]]) + domain = Domain(domain or []) & Domain([('warehouse_id', 'in', allowed_wh.ids)]) # Note: If allowed_wh is empty but allowed_location_ids is NOT empty, it means # the allowed locations don't belong to any warehouse (unlikely) or just user config issue.