53 lines
2.5 KiB
Python
53 lines
2.5 KiB
Python
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
from odoo import models, fields, api, exceptions, _
|
|
|
|
|
|
class TradeProjectApproval(models.Model):
|
|
_name = 'trade.project.approval'
|
|
_description = '立项申请'
|
|
_inherit = ['soong.workflow.mixin', 'mail.thread.main.attachment', 'mail.activity.mixin']
|
|
|
|
code = fields.Char(string="流水号",
|
|
default=lambda self: self.env['ir.sequence'].next_by_code('trade_project_approval_code'))
|
|
users_id = fields.Many2one('res.users', string="申请人", default=lambda self: self.env.user.id)
|
|
department_id = fields.Many2one(related='users_id.employee_id.department_id', string="申请部门")
|
|
|
|
urgency_level = fields.Selection([('normal', '普件'), ('urgent', '急件'), ('emergency', '特急件')], string='紧急度',
|
|
default='normal')
|
|
date_application = fields.Date(string="申请日期")
|
|
text = fields.Text(string='正文')
|
|
name = fields.Char(string="项目名称")
|
|
project_classify_id = fields.Many2one('project.classify.setting', string="项目分类")
|
|
start_date = fields.Date(string="计划开始")
|
|
end_date = fields.Date(string="计划完成")
|
|
plan_duration = fields.Integer(string="计划工期")
|
|
funding_id = fields.Many2one('project.funding.setting', string="资金来源")
|
|
employee_id = fields.Many2one('hr.employee', string="分管领导")
|
|
project_invest = fields.Float(string="项目总投资")
|
|
projected_earnings = fields.Float(string="预计投资收益")
|
|
project_content = fields.Text(string="项目概括")
|
|
project_goal = fields.Text(string="项目目标")
|
|
expected_results = fields.Text(string="预期成果")
|
|
document_ids = fields.Many2many('ir.attachment', string="立项文件")
|
|
work_end = fields.Boolean(string="结束")
|
|
active = fields.Boolean('Active', default=True, tracking=True)
|
|
|
|
def _get_default_name_title(self):
|
|
return self._description if self._description else self._name
|
|
|
|
name_title = fields.Char(default=_get_default_name_title)
|
|
|
|
# 项目归属
|
|
project_belong_id = fields.Many2one('res.users', string="项目负责人")
|
|
project_department_id = fields.Many2one('hr.department', string="项目部门")
|
|
|
|
def approval_end(self):
|
|
for rec in self:
|
|
self.env['project.project'].create({
|
|
'name' : rec.name,
|
|
'user_id' : rec.project_belong_id.id,
|
|
'company_id': rec.user_id.employee_id.company_id.id,
|
|
})
|
|
|
|
|