104 lines
3.2 KiB
Python
104 lines
3.2 KiB
Python
from odoo import api, fields, models
|
|
|
|
|
|
class McsCeoAction(models.Model):
|
|
_name = "mcs.ceo.action"
|
|
_description = "CEO Action"
|
|
_inherit = ["mail.thread", "mail.activity.mixin"]
|
|
_order = "priority_rank, date_due, id desc"
|
|
|
|
title = fields.Char(required=True, tracking=True)
|
|
category = fields.Selection(
|
|
[
|
|
("sales", "Sales"),
|
|
("finance", "Finance"),
|
|
("client", "Client"),
|
|
("people", "People"),
|
|
("strategy", "Strategy"),
|
|
("approval", "Approval"),
|
|
("collection", "Collection"),
|
|
("partnership", "Partnership"),
|
|
],
|
|
required=True,
|
|
default="strategy",
|
|
tracking=True,
|
|
)
|
|
priority = fields.Selection(
|
|
[
|
|
("critical", "Critical"),
|
|
("high", "High"),
|
|
("normal", "Normal"),
|
|
("low", "Low"),
|
|
],
|
|
required=True,
|
|
default="normal",
|
|
tracking=True,
|
|
)
|
|
priority_rank = fields.Integer(compute="_compute_priority_rank", store=True)
|
|
state = fields.Selection(
|
|
[
|
|
("open", "Open"),
|
|
("waiting", "Waiting"),
|
|
("blocked", "Blocked"),
|
|
("completed", "Completed"),
|
|
("cancelled", "Cancelled"),
|
|
],
|
|
required=True,
|
|
default="open",
|
|
tracking=True,
|
|
)
|
|
date_due = fields.Date(string="Due Date", tracking=True)
|
|
responsible_user_id = fields.Many2one(
|
|
"res.users", string="Responsible User", default=lambda self: self.env.user
|
|
)
|
|
partner_id = fields.Many2one(
|
|
"res.partner",
|
|
string="Related Client",
|
|
domain=[("mcs_is_client_account", "=", True)],
|
|
)
|
|
project_id = fields.Many2one("project.project", string="Related Project")
|
|
lead_id = fields.Many2one("crm.lead", string="Related CRM Opportunity")
|
|
currency_id = fields.Many2one(
|
|
"res.currency", default=lambda self: self.env.company.currency_id
|
|
)
|
|
expected_financial_impact = fields.Monetary(string="Expected Financial Impact")
|
|
business_impact = fields.Text(string="Business Impact")
|
|
next_action = fields.Char(string="Next Action", tracking=True)
|
|
blocker = fields.Text(tracking=True)
|
|
notes = fields.Html()
|
|
date_created = fields.Date(
|
|
string="Created Date", default=fields.Date.context_today, readonly=True
|
|
)
|
|
date_completed = fields.Date(string="Completed Date", readonly=True, tracking=True)
|
|
|
|
@api.depends("priority")
|
|
def _compute_priority_rank(self):
|
|
ranks = {"critical": 0, "high": 1, "normal": 2, "low": 3}
|
|
for action in self:
|
|
action.priority_rank = ranks.get(action.priority, 9)
|
|
|
|
def action_open(self):
|
|
self.write({"state": "open"})
|
|
return True
|
|
|
|
def action_waiting(self):
|
|
self.write({"state": "waiting"})
|
|
return True
|
|
|
|
def action_blocked(self):
|
|
self.write({"state": "blocked"})
|
|
return True
|
|
|
|
def action_completed(self):
|
|
self.write(
|
|
{
|
|
"state": "completed",
|
|
"date_completed": fields.Date.context_today(self),
|
|
}
|
|
)
|
|
return True
|
|
|
|
def action_cancelled(self):
|
|
self.write({"state": "cancelled"})
|
|
return True
|