diff --git a/soong_workflow/models/soong_workflow.py b/soong_workflow/models/soong_workflow.py index df9239944..573f9c08a 100644 --- a/soong_workflow/models/soong_workflow.py +++ b/soong_workflow/models/soong_workflow.py @@ -60,6 +60,35 @@ class SoongWorkflow(models.Model): employee_ids = fields.Many2many('hr.employee', string="人员") role_ids = fields.Many2many('soong.user.role', 'soong_workflow_role_rel', 'workflow_id', 'user_role_id', string="角色") + def update_opinions(self): + soong_ids = self.env["soong.workflow"].browse( + self._context.get('active_ids', self._context.get('active_id'))) + btn_opinion_map = { + '转交': ('transfer_comment_id', '拟同意,请审批。'), + '退回': ('return_comment_id', '请修改再报。'), + '确认': ('confirm_comment_id', '已阅。'), + '结束': ('end_comment_id', '同意。') + } + all_opinion_texts = [v[1] for v in btn_opinion_map.values()] + note_records = self.env['soong.note'].search([('name', 'in', all_opinion_texts)]) + note_text_to_rec = {note.name: note for note in note_records} + for rec in soong_ids: + if not rec.node_ids: + continue + for node in rec.node_ids: + if not node.button_ids: + continue + for button in node.button_ids: + if button.name in btn_opinion_map: + field_name, opinion_text = btn_opinion_map[button.name] + note_rec = note_text_to_rec.get(opinion_text) + if not note_rec: + note_rec = self.env['soong.note'].create({'name': opinion_text}) + note_text_to_rec[opinion_text] = note_rec + node.write({field_name: note_rec.id}) + + + def change_opinions_wizard(self): soong_ids = self.env["soong.workflow"].browse( self._context.get('active_ids', self._context.get('active_id'))) diff --git a/yuthon_hr_employee/views/yuthon_medical_manage_views.xml b/yuthon_hr_employee/views/yuthon_medical_manage_views.xml index aea562e51..7ab64a56e 100644 --- a/yuthon_hr_employee/views/yuthon_medical_manage_views.xml +++ b/yuthon_hr_employee/views/yuthon_medical_manage_views.xml @@ -4,7 +4,7 @@ yuthon.medical.manage.tree yuthon.medical.manage - +