53 lines
1.9 KiB
Python
53 lines
1.9 KiB
Python
"""Inherit res.partner: add follow-up state fields."""
|
|
|
|
from odoo import _, api, fields, models
|
|
|
|
|
|
FOLLOWUP_STATUS = [
|
|
('no_action', 'No Action Needed'),
|
|
('action_due', 'Action Due'),
|
|
('paused', 'Paused'),
|
|
('blocked', 'Blocked'),
|
|
('with_credit_team', 'With Credit Team'),
|
|
]
|
|
|
|
|
|
class ResPartner(models.Model):
|
|
_inherit = "res.partner"
|
|
|
|
fusion_followup_status = fields.Selection(
|
|
FOLLOWUP_STATUS, default='no_action', tracking=True,
|
|
help="Current follow-up status as computed by the engine.")
|
|
fusion_followup_paused_until = fields.Date(
|
|
tracking=True,
|
|
help="Pause follow-ups for this partner until this date.")
|
|
fusion_followup_last_level_id = fields.Many2one(
|
|
'fusion.followup.level',
|
|
help="The most-recent follow-up level this partner has been contacted at.")
|
|
fusion_followup_last_run_date = fields.Datetime(readonly=True)
|
|
fusion_followup_run_ids = fields.One2many(
|
|
'fusion.followup.run', 'partner_id', string='Follow-up History')
|
|
fusion_followup_run_count = fields.Integer(
|
|
compute='_compute_fusion_followup_run_count')
|
|
fusion_followup_risk_score = fields.Integer(
|
|
readonly=True, default=0,
|
|
help="Latest computed payment risk (0-100). Updated by cron.")
|
|
fusion_followup_risk_band = fields.Selection([
|
|
('low', 'Low'), ('medium', 'Medium'),
|
|
('high', 'High'), ('critical', 'Critical'),
|
|
], default='low', readonly=True)
|
|
|
|
def _compute_fusion_followup_run_count(self):
|
|
for partner in self:
|
|
partner.fusion_followup_run_count = len(partner.fusion_followup_run_ids)
|
|
|
|
def action_view_followup_history(self):
|
|
self.ensure_one()
|
|
return {
|
|
'type': 'ir.actions.act_window',
|
|
'res_model': 'fusion.followup.run',
|
|
'view_mode': 'list,form',
|
|
'domain': [('partner_id', '=', self.id)],
|
|
'context': {'default_partner_id': self.id},
|
|
}
|