|  | @ -8,31 +8,28 @@ import base64 | 
														
													
														
															
																|  |  | import logging |  |  | import logging | 
														
													
														
															
																|  |  | _logger = logging.getLogger(__name__) |  |  | _logger = logging.getLogger(__name__) | 
														
													
														
															
																|  |  |  |  |  |  | 
														
													
														
															
																|  |  | class PaymentTransaction(models.Model): |  |  |  | 
														
													
														
															
																|  |  | _inherit = 'payment.transaction' |  |  |  | 
														
													
														
															
																|  |  |  |  |  |  | 
														
													
														
															
																|  |  | donation_ids = fields.Many2many('donation.donation', 'donation_transaction_rel', 'transaction_id', 'donation_id', |  |  |  | 
														
													
														
															
																|  |  | string='Donations', copy=False, readonly=True) |  |  |  | 
														
													
														
															
																|  |  |  |  |  |  | 
														
													
														
															
																|  |  | def render_donation_button(self, donation, submit_txt=None, render_values=None): |  |  |  | 
														
													
														
															
																|  |  | values = { |  |  |  | 
														
													
														
															
																|  |  | 'partner_id': donation.partner_id.id, |  |  |  | 
														
													
														
															
																|  |  | 'type': self.type, |  |  |  | 
														
													
														
															
																|  |  | } |  |  |  | 
														
													
														
															
																|  |  | if render_values: |  |  |  | 
														
													
														
															
																|  |  | values.update(render_values) |  |  |  | 
														
													
														
															
																|  |  | # Not very elegant to do that here but no choice regarding the design. |  |  |  | 
														
													
														
															
																|  |  | self._log_payment_transaction_sent() |  |  |  | 
														
													
														
															
																|  |  | return self.acquirer_id.with_context(submit_class='btn btn-primary', submit_txt=submit_txt or _('Pay Now')).sudo().render( |  |  |  | 
														
													
														
															
																|  |  | self.reference, |  |  |  | 
														
													
														
															
																|  |  | donation.amount_total, |  |  |  | 
														
													
														
															
																|  |  | donation.currency_id.id, |  |  |  | 
														
													
														
															
																|  |  | values=values, |  |  |  | 
														
													
														
															
																|  |  | ) |  |  |  | 
														
													
														
															
																|  |  | # @api.onchange('state') |  |  |  | 
														
													
														
															
																|  |  | # def _onchange_state('state'): |  |  |  | 
														
													
														
															
																|  |  | #     """Disable dashboard display for test acquirer journal.""" |  |  |  | 
														
													
														
															
																|  |  | #     self.journal_id.update({'show_on_dashboard': self.state == 'enabled'}) |  |  |  | 
														
													
														
															
																|  |  |  |  |  | # class PaymentTransaction(models.Model): | 
														
													
														
															
																|  |  |  |  |  | #     _inherit = 'payment.transaction' | 
														
													
														
															
																|  |  |  |  |  |  | 
														
													
														
															
																|  |  |  |  |  | #     donation_ids = fields.Many2many('donation.donation', 'donation_transaction_rel', 'transaction_id', 'donation_id', | 
														
													
														
															
																|  |  |  |  |  | #                                       string='Donations', copy=False, readonly=True) | 
														
													
														
															
																|  |  |  |  |  |  | 
														
													
														
															
																|  |  |  |  |  | #     def render_donation_button(self, donation, submit_txt=None, render_values=None): | 
														
													
														
															
																|  |  |  |  |  | #         values = { | 
														
													
														
															
																|  |  |  |  |  | #             'partner_id': donation.partner_id.id, | 
														
													
														
															
																|  |  |  |  |  | #             'type': self.type, | 
														
													
														
															
																|  |  |  |  |  | #         } | 
														
													
														
															
																|  |  |  |  |  | #         if render_values: | 
														
													
														
															
																|  |  |  |  |  | #             values.update(render_values) | 
														
													
														
															
																|  |  |  |  |  | #         # Not very elegant to do that here but no choice regarding the design. | 
														
													
														
															
																|  |  |  |  |  | #         self._log_payment_transaction_sent() | 
														
													
														
															
																|  |  |  |  |  | #         return self.acquirer_id.with_context(submit_class='btn btn-primary', submit_txt=submit_txt or _('Pay Now')).sudo().render( | 
														
													
														
															
																|  |  |  |  |  | #             self.reference, | 
														
													
														
															
																|  |  |  |  |  | #             donation.amount_total, | 
														
													
														
															
																|  |  |  |  |  | #             donation.currency_id.id, | 
														
													
														
															
																|  |  |  |  |  | #             values=values, | 
														
													
														
															
																|  |  |  |  |  | #         ) | 
														
													
														
															
																|  |  |  |  |  |  | 
														
													
														
															
																|  |  |  |  |  |  | 
														
													
														
															
																|  |  |  |  |  |  | 
														
													
														
															
																|  |  |  |  |  |  | 
														
													
												
													
														
															
																|  | @ -40,9 +37,25 @@ class DonationDonation(models.Model): | 
														
													
														
															
																|  |  | _inherit = 'donation.donation' |  |  | _inherit = 'donation.donation' | 
														
													
														
															
																|  |  |  |  |  |  | 
														
													
														
															
																|  |  | invoice_id=fields.Many2one('account.move','invoice') |  |  | invoice_id=fields.Many2one('account.move','invoice') | 
														
													
														
															
																|  |  |  |  |  | transaction_id=fields.Many2one('payment.transaction','payment transaction') | 
														
													
														
															
																|  |  | state_done=fields.Boolean(compute='_compute_donation_state',store=True) |  |  | state_done=fields.Boolean(compute='_compute_donation_state',store=True) | 
														
													
														
															
																|  |  |  |  |  |  | 
														
													
														
															
																|  |  | @api.depends('invoice_id.payment_state') |  |  |  | 
														
													
														
															
																|  |  |  |  |  | # @api.depends('transaction_id.state') | 
														
													
														
															
																|  |  |  |  |  | # def transaction_state(self): | 
														
													
														
															
																|  |  |  |  |  | #     _logger.error("onchange_transaction_state") | 
														
													
														
															
																|  |  |  |  |  | #     if self.state=='done': | 
														
													
														
															
																|  |  |  |  |  | #         if self.donation_ids: | 
														
													
														
															
																|  |  |  |  |  | #             for donation_id in donation_ids: | 
														
													
														
															
																|  |  |  |  |  | #                 _logger.error("donation_id="+str(donation_id)) | 
														
													
														
															
																|  |  |  |  |  | #                 donation=request.env['donation.donation'].sudo().search([('id','=',int(donation_id))]) | 
														
													
														
															
																|  |  |  |  |  | #                 if donation:donation.state='done' | 
														
													
														
															
																|  |  |  |  |  |  | 
														
													
														
															
																|  |  |  |  |  | #         if self.membership_ids: | 
														
													
														
															
																|  |  |  |  |  | #             for membership_id in membership_ids: | 
														
													
														
															
																|  |  |  |  |  | #                 membership=request.env['kalachakra.membership'].sudo().search([('id','=',int(membership_id))]) | 
														
													
														
															
																|  |  |  |  |  | #                 if membership:membership.state='done' | 
														
													
														
															
																|  |  |  |  |  |  | 
														
													
														
															
																|  |  |  |  |  | @api.depends('invoice_id.payment_state','transaction_id.state') | 
														
													
														
															
																|  |  | def _compute_donation_state(self): |  |  | def _compute_donation_state(self): | 
														
													
														
															
																|  |  | for d in self: |  |  | for d in self: | 
														
													
														
															
																|  |  | if d.invoice_id: |  |  | if d.invoice_id: | 
														
													
												
													
														
															
																|  | @ -53,7 +66,23 @@ class DonationDonation(models.Model): | 
														
													
														
															
																|  |  | else: |  |  | else: | 
														
													
														
															
																|  |  | d.state='draft' |  |  | d.state='draft' | 
														
													
														
															
																|  |  | d.state_done=False |  |  | d.state_done=False | 
														
													
														
															
																|  |  |  |  |  |  | 
														
													
														
															
																|  |  |  |  |  | if d.transaction_id: | 
														
													
														
															
																|  |  |  |  |  | if d.transaction_id.state=='done': | 
														
													
														
															
																|  |  |  |  |  | d.state='done' | 
														
													
														
															
																|  |  |  |  |  | d.state_done=True | 
														
													
														
															
																|  |  |  |  |  | d.email_confirmation() | 
														
													
														
															
																|  |  |  |  |  |  | 
														
													
														
															
																|  |  |  |  |  |  | 
														
													
														
															
																|  |  |  |  |  | def email_confirmation(self): | 
														
													
														
															
																|  |  |  |  |  |  | 
														
													
														
															
																|  |  |  |  |  | mail_template = self.env['mail.template'].search([('name','=','confirmation_donation')]) | 
														
													
														
															
																|  |  |  |  |  |  | 
														
													
														
															
																|  |  |  |  |  | mail_template.email_to = self.partner_id.email | 
														
													
														
															
																|  |  |  |  |  |  | 
														
													
														
															
																|  |  |  |  |  | #mail_template.with_context({'end_date':self.end_date}).send_mail(self.id,False) | 
														
													
														
															
																|  |  |  |  |  | mail_template.send_mail(self.id,False) | 
														
													
														
															
																|  |  |  |  |  |  | 
														
													
														
															
																|  |  |  |  |  | return True | 
														
													
														
															
																|  |  |  |  |  |  | 
														
													
														
															
																|  |  | def bulk_remove_draft_donation(self): |  |  | def bulk_remove_draft_donation(self): | 
														
													
														
															
																|  |  | payment_transaction=self.env['payment.transaction'].search([('state','=','draft')]) |  |  | payment_transaction=self.env['payment.transaction'].search([('state','=','draft')]) | 
														
													
												
													
														
															
																|  | 
 |