添加功能
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import base64
|
||||
|
||||
from odoo.http import Controller, request, route
|
||||
from odoo import models, fields, api, http, SUPERUSER_ID, _
|
||||
from datetime import date, datetime, time
|
||||
@@ -17,6 +19,18 @@ class EmployeeLogin(Controller):
|
||||
record = request.env['yuthon.message.login'].sudo().browse(values['employee_id'])
|
||||
values['staff_name'] = record.staff_name
|
||||
if request.httprequest.method == 'POST':
|
||||
attachment = kw.get('attachment')
|
||||
if attachment:
|
||||
attachment_data = attachment.read()
|
||||
attachment_name = attachment.filename
|
||||
attachment_id = request.env['ir.attachment'].sudo().create({
|
||||
'name': attachment_name,
|
||||
'datas': base64.b64encode(attachment_data),
|
||||
'mimetype': attachment.content_type,
|
||||
'res_model': 'yuthon.message.login',
|
||||
'res_id': record.id,
|
||||
})
|
||||
record.write({'login_document_id': attachment_id.id})
|
||||
if "staff_name" in values and values.get("staff_name", ""):
|
||||
record.staff_name = values.get("staff_name", "")
|
||||
if "political" in values and values.get("political", ""):
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
<t t-call="yuthon_hr_employee_approval.frontend_layout">
|
||||
<div class="container py-5">
|
||||
<form class="oe_website_form_room" role="form" t-attf-action="/hr/employee/create" method="post"
|
||||
onsubmit="this.action = '/hr/employee/create' + location.hash">
|
||||
onsubmit="this.action = '/hr/employee/create' + location.hash" enctype="multipart/form-data">
|
||||
<input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
@@ -59,6 +59,10 @@
|
||||
<label for="staff_name" class="form-label">姓名</label>
|
||||
<input type="text" placeholder="姓名" name="staff_name" t-att-value="staff_name" id="staff_name"
|
||||
t-attf-class="form-control" style="background-color:#eee;"/>
|
||||
</div>
|
||||
<div class="mb-3 field-room_id">
|
||||
<label for="attachment" class="form-label">附件</label>
|
||||
<input type="file" class="form-control-file" name="attachment" id="attachment" style="background-color:#eee;"/>
|
||||
</div>
|
||||
<div class="mb-3 field-room_id">
|
||||
<label for="phone" class="form-label">电话</label>
|
||||
|
||||
Reference in New Issue
Block a user