采购协议
This commit is contained in:
@@ -21,12 +21,8 @@ class jikimo_purchase_tier_validation(models.Model):
|
||||
|
||||
def button_confirm(self):
|
||||
for record in self:
|
||||
# if record.need_validation and record.validation_status != 'validated':
|
||||
# raise ValidationError(_('此操作需要至少对一条记录进行审批。\n请发起审批申请。'))
|
||||
if record.state in ['to approve']:
|
||||
raise ValidationError(_('请先完成审批。'))
|
||||
# if record.state == 'approved':
|
||||
# record.state = 'purchase'
|
||||
res = super(jikimo_purchase_tier_validation, self).button_confirm()
|
||||
for record in self:
|
||||
if record.state == 'approved':
|
||||
@@ -39,45 +35,8 @@ class jikimo_purchase_tier_validation(models.Model):
|
||||
record.message_subscribe([record.partner_id.id])
|
||||
return res
|
||||
|
||||
# def button_confirm(self):
|
||||
# self = self.with_context(skip_validation=True)
|
||||
# return super().button_confirm()
|
||||
#
|
||||
# def _check_state_conditions(self, vals):
|
||||
# self.ensure_one()
|
||||
# if self._context.get('skip_validation'):
|
||||
# return False
|
||||
# return (
|
||||
# self._check_state_from_condition()
|
||||
# and vals.get(self._state_field) in self._state_to
|
||||
# )
|
||||
|
||||
def request_validation(self):
|
||||
for record in self:
|
||||
error_messages = []
|
||||
|
||||
# 检查必填字段
|
||||
required_fields = {
|
||||
'partner_ref': '合同名称',
|
||||
'contract_number': '合同编号'
|
||||
}
|
||||
|
||||
missing_fields = [
|
||||
name for field, name in required_fields.items()
|
||||
if not record[field]
|
||||
]
|
||||
|
||||
if missing_fields:
|
||||
error_messages.append('* 如下字段要求必须填写:%s' % '、'.join(missing_fields))
|
||||
|
||||
# 检查合同文件
|
||||
if not record.contract_document_id:
|
||||
error_messages.append('* 必须点击上传合同文件')
|
||||
|
||||
# 如果有任何错误,一次性显示所有错误信息
|
||||
if error_messages:
|
||||
raise ValidationError('\n'.join(error_messages))
|
||||
|
||||
# 添加通知消息
|
||||
if hasattr(record, 'message_post'):
|
||||
current_user = self.env.user.name
|
||||
|
||||
Reference in New Issue
Block a user