[IMP] ensan_donation_request: add branch to products domain

This commit is contained in:
Abdurrahman Saber 2025-12-23 17:19:20 +04:00
parent 9d44fd62b1
commit 20f4ce66d5
1 changed files with 11 additions and 2 deletions

View File

@ -1,6 +1,9 @@
from odoo import models, fields, api
from odoo.http import request
from odoo.osv import expression
import logging
_logger = logging.getLogger(__name__)
class Website(models.Model):
@ -13,6 +16,12 @@ class Website(models.Model):
if '/campaigns' in request.httprequest.full_path:
products = request.env['donation.request'].search([('stage_type', '=', 'approve'), ('show_in_most_active_page', '=', True)]).product_id
domain = expression.AND([domain, [('id', 'in', products.ids)]])
params = request.httprequest.args
if params.get('branch'):
try:
branch_id = int(params.get('branch'))
domain = expression.AND([domain, [('department_ids', 'in', [branch_id])]])
except:
_logger.error(f"Invalid branch: {params.get('branch')}")
pass
return domain