Files
gzth/yuthon_performance/models/yuthon_plan_management.py
T
2025-04-02 15:45:18 +08:00

80 lines
3.3 KiB
Python

from odoo import models, fields, api, exceptions, _
import datetime
class YuthonPlanManagement(models.Model):
_name = 'yuthon.plan.management'
_description = "个人工作任务"
_rec_name = 'name'
name = fields.Char('标题')
select_time = fields.Selection([('January', '一月'), ('February', '二月'), ('March', '三月'), ('April', '四月'),
('May', '五月'), ('June', '六月'), ('July', '七月'), ('July', '八月'),
('September', '九月'), ('October', '十月'), ('November', '十一月'), ('December', '十二月')
,('half', '上半年'), ('later', '下半年'), ('year', '年度')], string='选择时间', default=lambda self: self._get_default_month())
work_tasks_line_ids = fields.One2many('yuthon.work.tasks.line','plan_id',string='工作任务明细')
plan_management_ids = fields.One2many('yuthon.plan.management.line','plan_id',string='计划管理明细')
def button_plan_management(self):
employee = self.env.user.employee_id
index_list = []
index_ids = self.env['yuthon.index.management'].search([('employee_ids', 'in', employee.id)])
for index in index_ids:
index_list.append((0, 0, {
'task_type': index.index_type,
'goal': index.index_definition,
}))
self.plan_management_ids = index_list
@api.model
def _get_default_month(self):
current_month = datetime.datetime.now().strftime("%B") # 获取当前月份的英文名称
month_mapping_cn = {
"一月": "January",
"二月": "February",
"三月": "March",
"四月": "April",
"五月": "May",
"六月": "June",
"七月": "July",
"八月": "August",
"九月": "September",
"十月": "October",
"十一月": "November",
"十二月": "December",
}
return month_mapping_cn.get(current_month)
class YuthonWorkTasksLine(models.Model):
_name = 'yuthon.work.tasks.line'
_description = "工作任务明细"
plan_id = fields.Many2one('yuthon.plan.management','关联个人工作任务')
select_time = fields.Selection(related='plan_id.select_time',string='选择时间')
task_type = fields.Selection(related='task_id.index_type',string='任务类型')
task_id = fields.Many2one('yuthon.index.management',string='任务名称')
plan = fields.Char(related='task_id.compute_act',string='计划安排及具体措施行动')
goal = fields.Text('目标',help="质量、数量、成本等方面要求")
resource_requirements = fields.Text('资源需求')
summarize = fields.Text('完成情况总结')
class YuthonPlanManagementLine(models.Model):
_name = 'yuthon.plan.management.line'
_description = "个人工作任务明细"
plan_id = fields.Many2one('yuthon.plan.management', '关联个人工作任务')
select_time = fields.Selection(related='plan_id.select_time', string='选择时间')
sequence = fields.Integer('序号')
tasks_type = fields.Selection([('kpi', 'KPI'),
('gs', 'GS'), ('no', '否决指标')], string='任务类型')
goal = fields.Text('目标', help="质量、数量、成本等方面要求")