[add] Send an sms for donors when their campaign completes
This commit is contained in:
parent
47023dd682
commit
9fba748c3c
|
|
@ -53,12 +53,20 @@ class DonationRequest(models.Model):
|
|||
for rec in self:
|
||||
if rec.total_amount < rec.category_id.minimum_request_amount:
|
||||
raise ValidationError(_('Total Amount must be greater than or equal %.2f!') % rec.category_id.minimum_request_amount)
|
||||
|
||||
|
||||
@api.depends('remaining_amount')
|
||||
def _compute_stage_id(self):
|
||||
for rec in self:
|
||||
if rec.product_id and rec.remaining_amount <= 0:
|
||||
new_stage = self.env.ref('ensan_donation_request.stage_done')
|
||||
new_stage = self.env.ref('ensan_donation_request.stage_done')
|
||||
if rec.stage_id != new_stage:
|
||||
sms_template_id = rec.env.company.donation_request_completed_sms_template_id
|
||||
if sms_template_id and rec.user_id and rec.user_id.partner_id:
|
||||
rec._message_sms_with_template(
|
||||
template=sms_template_id,
|
||||
put_in_queue=True,
|
||||
partner_ids=rec.user_id.partner_id.ids
|
||||
)
|
||||
else:
|
||||
new_stage = rec.stage_id
|
||||
rec.stage_id = new_stage
|
||||
|
|
|
|||
|
|
@ -25,15 +25,20 @@ class ResConfigSettings(models.TransientModel):
|
|||
donation_recurring_deleted_sms_template_id = fields.Many2one(
|
||||
'sms.template', related='company_id.donation_recurring_deleted_sms_template_id', readonly=False
|
||||
)
|
||||
donation_request_completed_sms_template_id = fields.Many2one('sms.template',
|
||||
related='company_id.donation_request_completed_sms_template_id',readonly=False)
|
||||
|
||||
|
||||
class ResCompany(models.Model):
|
||||
_inherit = 'res.company'
|
||||
|
||||
donation_request_confirmation_sms_template_id = fields.Many2one('sms.template', required=True)
|
||||
donation_request_completed_sms_template_id = fields.Many2one('sms.template', required=True)
|
||||
donation_recurring_created_sms_template_id = fields.Many2one('sms.template')
|
||||
donation_recurring_paused_sms_template_id = fields.Many2one('sms.template')
|
||||
donation_recurring_resumed_sms_template_id = fields.Many2one('sms.template')
|
||||
donation_recurring_cancelled_sms_template_id = fields.Many2one('sms.template')
|
||||
donation_recurring_charged_sms_template_id = fields.Many2one('sms.template')
|
||||
donation_recurring_deleted_sms_template_id = fields.Many2one('sms.template')
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,11 @@
|
|||
class="col-lg-3 o_light_label"/>
|
||||
<field name="donation_request_confirmation_sms_template_id"/>
|
||||
</div>
|
||||
<div class="row mt16">
|
||||
<label for="donation_request_completed_sms_template_id" string="SMS Completed Template"
|
||||
class="col-lg-3 o_light_label"/>
|
||||
<field name="donation_request_completed_sms_template_id"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue