|
@ -28,13 +28,6 @@ class DonationDonation(models.Model): |
|
|
|
|
|
|
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
start_date = fields.Date( |
|
|
|
|
|
string='Start Date', |
|
|
|
|
|
index=True, |
|
|
|
|
|
required=True, |
|
|
|
|
|
default=datetime.today(), |
|
|
|
|
|
track_visibility='onchange' |
|
|
|
|
|
) |
|
|
|
|
|
end_date = fields.Date( |
|
|
end_date = fields.Date( |
|
|
string='End Date', |
|
|
string='End Date', |
|
|
index=True, |
|
|
index=True, |
|
@ -104,27 +97,34 @@ class DonationRecurringGenerate(models.TransientModel): |
|
|
for donation in donations: |
|
|
for donation in donations: |
|
|
generate=True |
|
|
generate=True |
|
|
existing_recur_donations = doo.search([("source_recurring_id", "=",int(donation.id))]) |
|
|
existing_recur_donations = doo.search([("source_recurring_id", "=",int(donation.id))]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if donation.donation_date>fields.Date.context_today(self): |
|
|
|
|
|
generate=False |
|
|
|
|
|
|
|
|
delta=0 |
|
|
delta=0 |
|
|
if donation.frequency=='annually':delta=365 |
|
|
if donation.frequency=='annually':delta=365 |
|
|
if donation.frequency=='half-yearly':delta=365/2 |
|
|
if donation.frequency=='half-yearly':delta=365/2 |
|
|
if donation.frequency=='quarterly':delta=365/4 |
|
|
if donation.frequency=='quarterly':delta=365/4 |
|
|
if donation.frequency=='bimonthly':delta=365/6 |
|
|
if donation.frequency=='bimonthly':delta=365/6 |
|
|
if donation.frequency=='monthly':delta=365/12 |
|
|
if donation.frequency=='monthly':delta=365/12 |
|
|
|
|
|
|
|
|
if existing_recur_donations: |
|
|
if existing_recur_donations: |
|
|
for d in existing_recur_donations: |
|
|
for d in existing_recur_donations: |
|
|
days_diff=(d.donation_date-fields.Date.context_today(self)).days |
|
|
days_diff=(d.donation_date-fields.Date.context_today(self)).days |
|
|
if days_diff<=delta: |
|
|
if days_diff<=delta: |
|
|
generate=False |
|
|
generate=False |
|
|
break |
|
|
break |
|
|
#raise UserError("generate="+str(generate)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if generate==True: |
|
|
if generate==True: |
|
|
default = { |
|
|
default = { |
|
|
"recurring_template":'', |
|
|
"recurring_template":'', |
|
|
"donation_date": fields.Date.context_today(self), |
|
|
"donation_date": fields.Date.context_today(self), |
|
|
"source_recurring_id": donation.id, |
|
|
"source_recurring_id": donation.id, |
|
|
"payment_ref": '', |
|
|
"payment_ref": '', |
|
|
|
|
|
"payment_mode_id":donation.payment_mode_id.id, |
|
|
|
|
|
"mandate_required":'True', |
|
|
|
|
|
"mandate_id":donation.mandate_id.id, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
new_donation = donation.copy(default=default) |
|
|
new_donation = donation.copy(default=default) |
|
|