refactor: update stock quantity report domain logic to use odoo.fields.Domain and add purchase module dependency.
This commit is contained in:
parent
14cde1242d
commit
87b5563cff
@ -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',
|
||||||
|
|||||||
@ -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.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user