task_manage.py 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import datetime
  2. from odoo import models, fields, api, utils
  3. from odoo.exceptions import ValidationError
  4. from addons_main.archives.models.base import base_bill
  5. from odoo.utils import constant
  6. class TaskManage(base_bill.Bill):
  7. _name = 'jc_cooperation.task_manage'
  8. _description = u'协作平台:任务'
  9. _order = 'id desc'
  10. _inherit = ['mail.thread']
  11. _module = 'jc_cooperation'
  12. task_name = fields.Char(string=u'任务名称', required=True)
  13. task_type_id = fields.Many2one('archives.common_archive', string=u'任务类型', domain=[('archive_name', '=', 141)])
  14. task_assignor_id = fields.Many2one('archives.staff', string=u'指派人', track_visibility='always')
  15. task_manager_id = fields.Many2one('archives.staff', string=u'负责人', track_visibility='always')
  16. project_schedule_id = fields.Many2one('jc_cooperation.project_schedule', string=u'项目')
  17. closing_date = fields.Date(string=u'截止日期', track_visibility='always')
  18. completion_degree = fields.Integer(string=u'完成度%', track_visibility='always')
  19. company_id = fields.Many2one('res.company', string=u'公司', ondelete='restrict',
  20. default=lambda self: self.env['res.company']._company_default_get())
  21. department_id = fields.Many2one('archives.department', string=u'部门', ondelete='restrict')
  22. task_description = fields.Html(string=u'任务描述', track_visibility='always')
  23. complete_description = fields.Html(string=u'完成描述', track_visibility='always')
  24. active = fields.Boolean(default=True)
  25. color = fields.Integer(string=u'颜色')
  26. process_id = fields.Many2one('archives.common_archive', domain=[('archive_name', '=', 203)],
  27. string=u'任务阶段', group_expand='_read_group_process_ids',
  28. track_visibility='onchange')
  29. is_false = fields.Boolean(string='False', help='仅用于判断值为False的方法中。===请勿赋值===', readonly=True)
  30. source_bill_detail_id = fields.Integer(string=u'来源单据明细')
  31. def do_customer_setting(self):
  32. """
  33. 个性设置按钮
  34. :return:
  35. """
  36. table_show_name = self._description
  37. return self.env['archives.set_customer_setting'].send_and_open(need_set_fields, self._name, table_show_name)
  38. @api.model
  39. def default_get(self, fields_):
  40. res = super(TaskManage, self).default_get(fields_)
  41. self.env['archives.set_customer_setting'].set_default(res, self._name, fields_, need_set_fields)
  42. return res
  43. @api.model
  44. def _read_group_process_ids(self, stages, domain, order):
  45. """ Read group customization in order to display all the stages in the
  46. kanban view, even if they are empty
  47. """
  48. _domain = [('archive_name', '=', 203)]
  49. process_ids = stages._search(_domain, order=order)
  50. return stages.browse(process_ids)
  51. def after_save(self, bill):
  52. super(TaskManage, self).after_save(bill)
  53. for i in bill:
  54. if i.source_bill_detail_id:
  55. project_schedule = self.env['jc_cooperation.project_schedule_detail'].browse(i.source_bill_detail_id)
  56. project_schedule.write({'completion_degree': i.completion_degree})
  57. need_set_fields = ['task_type_id', 'task_process_id', 'task_assignor_id', 'task_manager_id', 'company_id',
  58. 'department_id']