完善采购合同上传功能

This commit is contained in:
mgw
2024-12-26 11:22:16 +08:00
parent 7ab2894ae8
commit b0e993dd53
4 changed files with 93 additions and 5 deletions

View File

@@ -45,6 +45,8 @@ class IrAttachmentWizard(models.TransientModel):
def action_upload_file(self):
self.ensure_one()
# 获取当前用户的 partner_id
current_partner = self.env.user.partner_id
# 首先创建 ir.attachment
attachment = self.env['ir.attachment'].create({
'name': self.filename,
@@ -64,6 +66,14 @@ class IrAttachmentWizard(models.TransientModel):
'folder_id': workspace.id,
'res_model': self.res_model,
'res_id': self.res_id,
'partner_id': current_partner.id,
})
# 更新采购订单的合同文档字段
purchase_order = self.env['purchase.order'].browse(self.res_id)
purchase_order.write({
'contract_document_id': document.id,
'is_upload_contract_file': True
})
# 显示成功消息并关闭向导
@@ -80,6 +90,7 @@ class IrAttachmentWizard(models.TransientModel):
}
}
}
return message

View File

@@ -12,7 +12,7 @@
<field name="res_id" invisible="1"/>
</group>
<footer>
<button name="action_upload_file" string="上传" type="object" class="btn-primary"/>
<button name="action_upload_file" string="确认上传" type="object" class="btn-primary"/>
<button string="取消" class="btn-secondary" special="cancel"/>
</footer>
</form>