43 lines
1.5 KiB
Python
43 lines
1.5 KiB
Python
from odoo import fields, models
|
|
|
|
|
|
class DanceWhatsappLog(models.Model):
|
|
_name = "dance.whatsapp.log"
|
|
_description = "Dance WhatsApp Delivery Log"
|
|
_order = "create_date desc, id desc"
|
|
|
|
template_id = fields.Many2one("dance.whatsapp.template", ondelete="set null")
|
|
trigger = fields.Selection(
|
|
[
|
|
("absence", "Student Absent"),
|
|
("fee_due", "Fee Due"),
|
|
("session_cancelled", "Session Cancelled"),
|
|
],
|
|
required=True,
|
|
)
|
|
student_id = fields.Many2one("res.partner", string="Student", ondelete="set null")
|
|
guardian_id = fields.Many2one("res.partner", string="Guardian", ondelete="set null")
|
|
invoice_id = fields.Many2one("account.move", string="Invoice", ondelete="set null")
|
|
attendance_id = fields.Many2one("dance.attendance", string="Attendance", ondelete="set null")
|
|
session_id = fields.Many2one("dance.session", string="Session", ondelete="set null")
|
|
phone = fields.Char()
|
|
message = fields.Text(required=True)
|
|
status = fields.Selection(
|
|
[
|
|
("pending", "Pending"),
|
|
("sent", "Sent"),
|
|
("failed", "Failed"),
|
|
],
|
|
default="pending",
|
|
required=True,
|
|
)
|
|
error_message = fields.Text()
|
|
|
|
def action_mark_sent(self):
|
|
self.write({"status": "sent", "error_message": False})
|
|
return True
|
|
|
|
def action_mark_failed(self, error_message):
|
|
self.write({"status": "failed", "error_message": error_message})
|
|
return True
|