You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							69 lines
						
					
					
						
							2.8 KiB
						
					
					
				
			
		
		
		
			
			
			
		
		
	
	
							69 lines
						
					
					
						
							2.8 KiB
						
					
					
				
								# -*- coding: utf-8 -*-
							 | 
						|
								################################################################################
							 | 
						|
								#
							 | 
						|
								#    Cybrosys Technologies Pvt. Ltd.
							 | 
						|
								#
							 | 
						|
								#    Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
							 | 
						|
								#    Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>)
							 | 
						|
								#
							 | 
						|
								#    You can modify it under the terms of the GNU AFFERO
							 | 
						|
								#    GENERAL PUBLIC LICENSE (AGPL v3), Version 3.
							 | 
						|
								#
							 | 
						|
								#    This program is distributed in the hope that it will be useful,
							 | 
						|
								#    but WITHOUT ANY WARRANTY; without even the implied warranty of
							 | 
						|
								#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
							 | 
						|
								#    GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details.
							 | 
						|
								#
							 | 
						|
								#    You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
							 | 
						|
								#    (AGPL v3) along with this program.
							 | 
						|
								#    If not, see <http://www.gnu.org/licenses/>.
							 | 
						|
								#
							 | 
						|
								################################################################################
							 | 
						|
								from odoo import http
							 | 
						|
								from odoo.http import request
							 | 
						|
								
							 | 
						|
								
							 | 
						|
								class CertificatesGroupBy(http.Controller):
							 | 
						|
								    """This is used to certificates group by in tree view"""
							 | 
						|
								
							 | 
						|
								    @http.route(['/certificatesgroupby'], type='json', auth="public",
							 | 
						|
								                website=True)
							 | 
						|
								    def certificates_group_by(self, **kwargs):
							 | 
						|
								        """Call from rpc for group by, and it returns the corresponding
							 | 
						|
								        values"""
							 | 
						|
								        context = []
							 | 
						|
								        group_value = kwargs.get("search_value")
							 | 
						|
								        if group_value == '1':
							 | 
						|
								            context = []
							 | 
						|
								            type_ids = request.env['certificates.types'].sudo().search([])
							 | 
						|
								            for types in type_ids:
							 | 
						|
								                certificates_ids = request.env['certificates'].sudo().search([
							 | 
						|
								                    ('certificates_types_id', '=', types.id),
							 | 
						|
								                    ('customer_id', '=', request.env.user.partner_id.id)
							 | 
						|
								                ])
							 | 
						|
								                if certificates_ids:
							 | 
						|
								                    context.append({
							 | 
						|
								                        'name': types.certificate_type,
							 | 
						|
								                        'data': certificates_ids
							 | 
						|
								                    })
							 | 
						|
								        if group_value == '2':
							 | 
						|
								            context = []
							 | 
						|
								            tag_ids = request.env['certificates.tags'].sudo().search([])
							 | 
						|
								            for tags in tag_ids:
							 | 
						|
								                certificates_ids = request.env['certificates'].sudo().search([
							 | 
						|
								                    ('certificates_tags_ids', '=', tags.id),
							 | 
						|
								                    ('customer_id', '=', request.env.user.partner_id.id)
							 | 
						|
								                ])
							 | 
						|
								                if certificates_ids:
							 | 
						|
								                    context.append({
							 | 
						|
								                        'name': tags.certificates_tags,
							 | 
						|
								                        'data': certificates_ids
							 | 
						|
								                    })
							 | 
						|
								        values = {
							 | 
						|
								            'certificates': context,
							 | 
						|
								        }
							 | 
						|
								        response = http.Response(
							 | 
						|
								            template='certificate_license_expiry'
							 | 
						|
								                     '.certificates_group_by_template',
							 | 
						|
								            qcontext=values)
							 | 
						|
								        return response.render()
							 | 
						|
								
							 |