From 20f4ce66d5c990a26bd55decbcc06d04b2e54a65 Mon Sep 17 00:00:00 2001 From: Abdurrahman Saber Date: Tue, 23 Dec 2025 17:19:20 +0400 Subject: [PATCH] [IMP] ensan_donation_request: add branch to products domain --- .../ensan_donation_request/models/website.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/odex25_donation/ensan_donation_request/models/website.py b/odex25_donation/ensan_donation_request/models/website.py index 595e62768..b2c3f1d28 100644 --- a/odex25_donation/ensan_donation_request/models/website.py +++ b/odex25_donation/ensan_donation_request/models/website.py @@ -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 -