refactor: update stock quantity report domain logic to use odoo.fields.Domain and add purchase module dependency.

This commit is contained in:
Suherdy Yacob 2026-03-10 11:49:41 +07:00
parent 14cde1242d
commit 87b5563cff
2 changed files with 3 additions and 3 deletions

View File

@ -16,7 +16,7 @@
""", """,
'category': 'Extra Tools', 'category': 'Extra Tools',
'author': 'Suherdy Yacob', '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': [ 'data': [
'security/ir.model.access.csv', 'security/ir.model.access.csv',
'security/ir_rule.xml', 'security/ir_rule.xml',

View File

@ -1,5 +1,5 @@
from odoo import models, api from odoo import models, api
from odoo.osv import expression from odoo.fields import Domain
class ReportStockQuantity(models.Model): class ReportStockQuantity(models.Model):
_inherit = 'report.stock.quantity' _inherit = 'report.stock.quantity'
@ -13,7 +13,7 @@ class ReportStockQuantity(models.Model):
allowed_wh = user.allowed_warehouse_ids | user.allowed_location_ids.warehouse_id allowed_wh = user.allowed_warehouse_ids | user.allowed_location_ids.warehouse_id
# If user has specific allowed warehouses/locations, restrict report # If user has specific allowed warehouses/locations, restrict report
if allowed_wh: 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 # 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. # the allowed locations don't belong to any warehouse (unlikely) or just user config issue.