Skip to content

Commit

Permalink
[FIX]通过代码写入的时候,不应该报审批后不允许修改 osbzr#1703,创建和删除同样修复
Browse files Browse the repository at this point in the history
  • Loading branch information
floraXiao committed Apr 20, 2018
1 parent 89dd308 commit 5a4ae02
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions good_process/models/mail_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,21 @@ def good_process_refused(self, active_id, active_model):
return_vals = u'已经通过不能拒绝!'
return return_vals, message or ''

def is_current_model(self):
"""检查是否是当前对象"""
action_id = self.env.context['params']['action']
if not action_id:
return False
current_model = self.env['ir.actions.act_window'].browse(action_id).res_model
if current_model != self._name:
return False
else:
return True

@api.model
def create(self, vals):
if not self.is_current_model():
return super(MailThread, self).create(vals)
thread_row = super(MailThread, self).create(vals)
approvers = self.__add_approver__(thread_row, self._name, thread_row.id)
thread_row._approver_num = len(approvers)
Expand All @@ -167,6 +180,8 @@ def write(self, vals):
'''
如果单据的审批流程已经开始(第一个人同意了才算开始) —— 至少一个审批人已经审批通过,不允许对此单据进行修改。
'''
if not self.is_current_model():
return super(MailThread, self).write(vals)
for th in self:
ignore_fields = ['_approver_num',
'_to_approver_ids',
Expand Down Expand Up @@ -203,6 +218,8 @@ def write(self, vals):

@api.multi
def unlink(self):
if not self.is_current_model():
return super(MailThread, self).unlink()
for th in self:
if not len(th._to_approver_ids) and th._approver_num:
raise ValidationError(u"已审批不可删除")
Expand Down

0 comments on commit 5a4ae02

Please sign in to comment.