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.
 
 

54 lines
2.2 KiB

from odoo import fields, models, _
from datetime import datetime,timedelta,date
class RecurringDonationWizard(models.TransientModel):
_name = 'opendons.recurringdonation.wizard'
_description = 'recurring donation wizard'
stopped_reason=fields.Selection(string='Stop reason',selection=[('motif1', 'Motif 1'), ('motif2', 'Motif 2')])
donation_id=fields.Integer('donation id')
template_pa_id=fields.Many2one('donation.donation.template_pa_id')
def stopRecurringDonation(self):
donation=self.env['donation.donation'].search([('id','=',self.donation_id)])
donation.recurring_template="stopped"
donation.stopped_reason=self.stopped_reason
donation.stopped_date=fields.Date.context_today(self)
class RecurringDonationprintWizard(models.TransientModel):
_name = 'opendons.recurringdonationprint.wizard'
_description = 'recurring donation print wizard'
template_id=fields.Many2one('opendons.template_pa_letter')
html_content=fields.Html(related='template_id.html_content')
donation_id=fields.Integer('donation id')
def print(self):
donation=self.env['donation.donation'].search([('id','=',self.donation_id)])
donation.template_pa_id=self.template_id
if self.html_content:
html_content_print=self.html_content
html_content_print=html_content_print.replace('{{partner_id.name}}',donation.partner_id.name)
html_content_print=html_content_print.replace('{{partner_id.firstname}}',donation.partner_id.firstname)
donation.html_content_print=html_content_print
#on trace l'action
vals={}
vals['template_name']=self.template_id.name
vals['chanel']='print'
vals['date_action']=datetime.now().date()
vals['donation_id']=donation.id
res=self.env['opendons.donation.print_email_history'].create(vals)
donation.write({'print_email_history_ids':[4,res.id]})
return self.env.ref("opendons.report_donation_recurring_letter").report_action(donation)
else:
raise Warning('please select a mail to print')