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.
		
		
		
		
		
			
		
			
				
					
					
						
							60 lines
						
					
					
						
							2.2 KiB
						
					
					
				
			
		
		
		
			
			
			
		
		
	
	
							60 lines
						
					
					
						
							2.2 KiB
						
					
					
				| # -*- coding: utf-8 -*- | |
| ############################################################################### | |
| # | |
| #    Cybrosys Technologies Pvt. Ltd. | |
| # | |
| #    Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) | |
| #    Author: Afra K (odoo@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 _, api, fields, models | |
| from odoo.exceptions import UserError | |
| 
 | |
| 
 | |
| class PaymentProvider(models.Model): | |
|     """ Inherits the payment provider to add the credit payment """ | |
|     _inherit = 'payment.provider' | |
| 
 | |
|     code = fields.Selection(selection_add=[('credit_pay', 'Credit Payment')], | |
|                             ondelete={'credit_pay': 'set default'}) | |
| 
 | |
|     # === COMPUTE METHODS ===# | |
| 
 | |
|     @api.depends('code') | |
|     def _compute_view_configuration_fields(self): | |
|         """ Override of payment to hide the credentials page. | |
|  | |
|         :return: None | |
|         """ | |
|         super()._compute_view_configuration_fields() | |
|         self.filtered( | |
|             lambda p: p.code == 'credit_pay').show_credentials_page = False | |
| 
 | |
|     def _compute_feature_support_fields(self): | |
|         """ Override of `payment` to enable additional features. """ | |
|         super()._compute_feature_support_fields() | |
|         self.filtered(lambda p: p.code == 'credit_pay').update({ | |
|             'support_manual_capture': 'partial', | |
|             'support_refund': 'partial', | |
|             'support_tokenization': True, | |
|         }) | |
| 
 | |
|     # === CONSTRAINT METHODS ===# | |
| 
 | |
|     @api.constrains('state', 'code') | |
|     def _check_provider_state(self): | |
|         if self.filtered(lambda p: p.code == 'credit_pay' and p.state not in ( | |
|                 'test', 'disabled')): | |
|             raise UserError(_("Demo providers should never be enabled."))
 | |
| 
 |