Merge pull request #5937 from expsa/advance_date_error
[FIX] ensan_donation_request: error in advance_next_date
This commit is contained in:
commit
7335836843
|
|
@ -310,23 +310,19 @@ class DonationRecurring(models.Model):
|
|||
if not date_ref:
|
||||
date_ref = fields.Date.context_today(self)
|
||||
domain = self._get_donations_to_process_domain(date_ref)
|
||||
|
||||
records = self.search(domain)
|
||||
for rec in records:
|
||||
try:
|
||||
for rec in records:
|
||||
new_line = rec._create_donation_line()
|
||||
unprocessed_lines = rec.recurring_line_ids.filtered(lambda l: not l.sale_order_id)
|
||||
if unprocessed_lines:
|
||||
for line in unprocessed_lines:
|
||||
rec._create_sale_order(line)
|
||||
new_line = rec._create_donation_line()
|
||||
if not new_line:
|
||||
continue
|
||||
rec._create_sale_order(new_line)
|
||||
rec._advance_next_date()
|
||||
except Exception as e:
|
||||
rec.message_post(body=_("⛔ Unexpected error:<br/><pre>%s</pre>") % str(e))
|
||||
continue
|
||||
|
||||
self.message_post(body=_("⛔ Unexpected error:<br/><pre>%s</pre>") % str(e))
|
||||
raise
|
||||
return True
|
||||
|
||||
@api.model
|
||||
|
|
@ -340,14 +336,16 @@ class DonationRecurring(models.Model):
|
|||
]
|
||||
|
||||
def _advance_next_date(self):
|
||||
for rec in self:
|
||||
interval = rec.recurring_interval or 1
|
||||
if rec.frequency == 'daily':
|
||||
rec.recurring_next_date += relativedelta(days=interval)
|
||||
elif rec.frequency == 'weekly':
|
||||
rec.recurring_next_date += relativedelta(weeks=interval)
|
||||
elif rec.frequency == 'monthly':
|
||||
rec.recurring_next_date += relativedelta(months=interval)
|
||||
self.ensure_one()
|
||||
interval = self.recurring_interval or 1
|
||||
next_date = self.recurring_next_date
|
||||
if self.frequency == 'daily':
|
||||
next_date = next_date + relativedelta(days=interval)
|
||||
elif self.frequency == 'weekly':
|
||||
next_date = next_date + relativedelta(weeks=interval)
|
||||
elif self.frequency == 'monthly':
|
||||
next_date = next_date + relativedelta(months=interval)
|
||||
self.recurring_next_date = next_date
|
||||
|
||||
def unlink(self):
|
||||
bot = self.env.ref('base.partner_root').id
|
||||
|
|
|
|||
Loading…
Reference in New Issue