|
@ -87,7 +87,13 @@ class DonationDonation(models.Model): |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
year_donation_date=fields.Integer('Year donation date',compute='_compute_year_donation_date',store=True) |
|
|
year_donation_date=fields.Integer('Year donation date',compute='_compute_year_donation_date',store=True) |
|
|
|
|
|
|
|
|
|
|
|
print_email_history_ids=fields.One2many( |
|
|
|
|
|
'opendons.donation.print_email_history', |
|
|
|
|
|
'donation_id', |
|
|
|
|
|
string='print or email history ', |
|
|
|
|
|
readonly=True |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
def _compute_year_donation_date(self): |
|
|
def _compute_year_donation_date(self): |
|
|
for rec in self: |
|
|
for rec in self: |
|
|
rec.year_donation_date=rec.donation_date.year |
|
|
rec.year_donation_date=rec.donation_date.year |
|
@ -96,14 +102,13 @@ class DonationDonation(models.Model): |
|
|
#raise Warning(self.recurring_template) |
|
|
#raise Warning(self.recurring_template) |
|
|
if self.recurring_template=='active': |
|
|
if self.recurring_template=='active': |
|
|
|
|
|
|
|
|
sepa_payment_method=self.env['account.payment.method'].search([('code','=','sepa_direct_debit')]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sepa_payment_method=self.env['account.payment.method'].search([('code','=','sepa_direct_debit')],limit=1) |
|
|
if sepa_payment_method: |
|
|
if sepa_payment_method: |
|
|
|
|
|
|
|
|
id=int(sepa_payment_method.id) |
|
|
|
|
|
return 4 |
|
|
|
|
|
else: |
|
|
|
|
|
raise Warning('veuillez configurer la méthode de paiment SEPA') |
|
|
|
|
|
|
|
|
sepa_payment_mode=self.env['account.payment.mode'].search([('payment_method_id','=',int(sepa_payment_method.id))],limit=1) |
|
|
|
|
|
if sepa_payment_mode: |
|
|
|
|
|
self.payment_mode_id=sepa_payment_mode.id |
|
|
|
|
|
else: |
|
|
|
|
|
raise Warning(_('Please configure a SEPA payment mode')) |
|
|
|
|
|
|
|
|
payment_mode_id = fields.Many2one( |
|
|
payment_mode_id = fields.Many2one( |
|
|
"account.payment.mode", |
|
|
"account.payment.mode", |
|
@ -166,7 +171,20 @@ class DonationDonation(models.Model): |
|
|
self.mandate_id=False |
|
|
self.mandate_id=False |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@api.onchange("payment_mode_id") |
|
|
|
|
|
def donation_payment_mode_id_change(self): |
|
|
|
|
|
if self.recurring_template=='active' and self.payment_mode_id: |
|
|
|
|
|
sepa_payment_method=self.env['account.payment.method'].search([('code','=','sepa_direct_debit')],limit=1) |
|
|
|
|
|
if sepa_payment_method: |
|
|
|
|
|
sepa_payment_mode=self.env['account.payment.mode'].search([('payment_method_id','=',int(sepa_payment_method.id))],limit=1) |
|
|
|
|
|
if sepa_payment_mode: |
|
|
|
|
|
if self.payment_mode_id!=sepa_payment_mode.id : |
|
|
|
|
|
self.payment_mode_id=sepa_payment_mode.id |
|
|
|
|
|
|
|
|
|
|
|
else: |
|
|
|
|
|
raise ValidationError(_('Please configure SEPA Payment')) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@api.onchange('operation_id') |
|
|
@api.onchange('operation_id') |
|
|
def _onchange_operation_id(self): |
|
|
def _onchange_operation_id(self): |
|
@ -563,7 +581,27 @@ class DonationDonation(models.Model): |
|
|
'res_id': wiz.id, |
|
|
'res_id': wiz.id, |
|
|
'context': self.env.context, |
|
|
'context': self.env.context, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def show_print_wizard(self): |
|
|
|
|
|
self.ensure_one() |
|
|
|
|
|
assert self.recurring_template == "active" |
|
|
|
|
|
view=self.env.ref('opendons.recurring_donation_view') |
|
|
|
|
|
|
|
|
|
|
|
wiz=self.env['opendons.recurringdonationprint.wizard'].create({'donation_id':self.id}) |
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
|
'name': _('Print letter'), |
|
|
|
|
|
'type': 'ir.actions.act_window', |
|
|
|
|
|
'view_type': 'form', |
|
|
|
|
|
'view_mode': 'form', |
|
|
|
|
|
'res_model': 'opendons.recurringdonationprint.wizard', |
|
|
|
|
|
'views': [(view.id, 'form')], |
|
|
|
|
|
'view_id': view.id, |
|
|
|
|
|
'target': 'new', |
|
|
|
|
|
'res_id': wiz.id, |
|
|
|
|
|
'context': self.env.context, |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# self.write({"recurring_template": "stopped"}) |
|
|
# self.write({"recurring_template": "stopped"}) |
|
|