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.
		
		
		
		
		
			
		
			
				
					
					
						
							105 lines
						
					
					
						
							4.5 KiB
						
					
					
				
			
		
		
		
			
			
			
		
		
	
	
							105 lines
						
					
					
						
							4.5 KiB
						
					
					
				| # -*- coding: utf-8 -*- | |
| ############################################################################# | |
| # | |
| #    Cybrosys Technologies Pvt. Ltd. | |
| # | |
| #    Copyright (C) 2022-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 LESSER | |
| #    GENERAL PUBLIC LICENSE (LGPL 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. | |
| # | |
| #    You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE | |
| #    (LGPL v3) along with this program. | |
| #    If not, see <http://www.gnu.org/licenses/>. | |
| # | |
| ############################################################################# | |
| from odoo import api, models | |
| from odoo.http import request | |
| import ast | |
| 
 | |
| 
 | |
| class AccountMoveLine(models.Model): | |
|     """Function is updated to avoid conflict for new and old odoo V15 addons""" | |
|     _inherit = "account.move.line" | |
| 
 | |
|     @api.model | |
|     def _query_get(self, domain=None): | |
|         self.check_access_rights('read') | |
|         context = dict(self._context or {}) | |
|         domain = domain or [] | |
|         if not isinstance(domain, (list, tuple)): | |
|             domain = ast.literal_eval(domain) | |
| 
 | |
|         date_field = 'date' | |
|         if context.get('aged_balance'): | |
|             date_field = 'date_maturity' | |
|         if context.get('date_to'): | |
|             domain += [(date_field, '<=', context['date_to'])] | |
|         if context.get('date_from'): | |
|             if not context.get('strict_range'): | |
|                 domain += ['|', (date_field, '>=', context['date_from']), | |
|                            ('account_id.include_initial_balance', '=', True)] | |
|             elif context.get('initial_bal'): | |
|                 domain += [(date_field, '<', context['date_from'])] | |
|             else: | |
|                 domain += [(date_field, '>=', context['date_from'])] | |
| 
 | |
|         state = context.get('state') | |
|         if state and state.lower() != 'all': | |
|             domain += [('parent_state', '=', state)] | |
|         if context.get('reconcile_date'): | |
|             domain += ['|', ('reconciled', '=', False), '|', ( | |
|                 'matched_debit_ids.max_date', '>', context['reconcile_date']), | |
|                        ( | |
|                            'matched_credit_ids.max_date', '>', | |
|                            context['reconcile_date'])] | |
|         if context.get('account_tag_ids'): | |
|             domain += [ | |
|                 ('account_id.tag_ids', 'in', context['account_tag_ids'].ids)] | |
|         if context.get('journal_ids'): | |
|             domain += [('journal_id', 'in', context['journal_ids'])] | |
|         if context.get('account_ids'): | |
|             domain += [('account_id', 'in', context['account_ids'].ids)] | |
|         if context.get('analytic_line_ids'): | |
|             domain += [ | |
|                 ('analytic_line_ids', 'in', context['analytic_line_ids'].ids)] | |
|         if context.get('partner_ids'): | |
|             domain += [('partner_id', 'in', context['partner_ids'].ids)] | |
|         if context.get('partner_categories'): | |
|             domain += [('partner_id.category_id', 'in', | |
|                         context['partner_categories'].ids)] | |
|         company_ids = self.get_current_company_value() | |
|         domain += [('company_id', 'in', company_ids)] | |
|         where_clause = "" | |
|         where_clause_params = [] | |
|         tables = '' | |
|         if domain: | |
|             domain.append( | |
|                 ('display_type', 'not in', ('line_section', 'line_note'))) | |
|             domain.append(('parent_state', '!=', 'cancel')) | |
|             query = self._where_calc(domain) | |
|             # Wrap the query with 'company_id IN (...)' to avoid bypassing | |
|             # company access rights. | |
|             self._apply_ir_rules(query) | |
|             tables, where_clause, where_clause_params = query.get_sql() | |
|         return tables, where_clause, where_clause_params | |
| 
 | |
|     def get_current_company_value(self): | |
|         cookies_cids = [int(r) for r in | |
|                         request.httprequest.cookies.get('cids').split(",")] \ | |
|             if request.httprequest.cookies.get('cids') \ | |
|             else [request.env.user.company_id.id] | |
|         for company_id in cookies_cids: | |
|             if company_id not in self.env.user.company_ids.ids: | |
|                 cookies_cids.remove(company_id) | |
|         if not cookies_cids: | |
|             cookies_cids = [self.env.company.id] | |
|         if len(cookies_cids) == 1: | |
|             cookies_cids.append(0) | |
|         return cookies_cids
 | |
| 
 |