12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- import datetime
- from odoo import models, fields, api, utils
- from odoo.exceptions import ValidationError
- from addons_main.archives.models.base import base_bill
- from odoo.utils import constant
- class TaskManage(base_bill.Bill):
- _name = 'jc_cooperation.task_manage'
- _description = u'协作平台:任务'
- _order = 'id desc'
- _inherit = ['mail.thread']
- _module = 'jc_cooperation'
- task_name = fields.Char(string=u'任务名称', required=True)
- task_type_id = fields.Many2one('archives.common_archive', string=u'任务类型', domain=[('archive_name', '=', 141)])
- task_assignor_id = fields.Many2one('archives.staff', string=u'指派人', track_visibility='always')
- task_manager_id = fields.Many2one('archives.staff', string=u'负责人', track_visibility='always')
- project_schedule_id = fields.Many2one('jc_cooperation.project_schedule', string=u'项目')
- closing_date = fields.Date(string=u'截止日期', track_visibility='always')
- completion_degree = fields.Integer(string=u'完成度%', track_visibility='always')
- company_id = fields.Many2one('res.company', string=u'公司', ondelete='restrict',
- default=lambda self: self.env['res.company']._company_default_get())
- department_id = fields.Many2one('archives.department', string=u'部门', ondelete='restrict')
- task_description = fields.Html(string=u'任务描述', track_visibility='always')
- complete_description = fields.Html(string=u'完成描述', track_visibility='always')
- active = fields.Boolean(default=True)
- color = fields.Integer(string=u'颜色')
- process_id = fields.Many2one('archives.common_archive', domain=[('archive_name', '=', 203)],
- string=u'任务阶段', group_expand='_read_group_process_ids',
- track_visibility='onchange')
- is_false = fields.Boolean(string='False', help='仅用于判断值为False的方法中。===请勿赋值===', readonly=True)
- source_bill_detail_id = fields.Integer(string=u'来源单据明细')
- def do_customer_setting(self):
- """
- 个性设置按钮
- :return:
- """
- table_show_name = self._description
- return self.env['archives.set_customer_setting'].send_and_open(need_set_fields, self._name, table_show_name)
- @api.model
- def default_get(self, fields_):
- res = super(TaskManage, self).default_get(fields_)
- self.env['archives.set_customer_setting'].set_default(res, self._name, fields_, need_set_fields)
- return res
- @api.model
- def _read_group_process_ids(self, stages, domain, order):
- """ Read group customization in order to display all the stages in the
- kanban view, even if they are empty
- """
- _domain = [('archive_name', '=', 203)]
- process_ids = stages._search(_domain, order=order)
- return stages.browse(process_ids)
- def after_save(self, bill):
- super(TaskManage, self).after_save(bill)
- for i in bill:
- if i.source_bill_detail_id:
- project_schedule = self.env['jc_cooperation.project_schedule_detail'].browse(i.source_bill_detail_id)
- project_schedule.write({'completion_degree': i.completion_degree})
- need_set_fields = ['task_type_id', 'task_process_id', 'task_assignor_id', 'task_manager_id', 'company_id',
- 'department_id']
|