完善采购合同上传功能
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user