增加更新脚本
This commit is contained in:
@@ -13,4 +13,20 @@ class InheritIrAttachment(models.Model):
|
||||
|
||||
public = fields.Boolean(string='公共文档', default=True)
|
||||
|
||||
file_size_display = fields.Char(string="File Size", compute="_compute_file_size_display")
|
||||
|
||||
@api.depends('file_size')
|
||||
def _compute_file_size_display(self):
|
||||
for rec in self:
|
||||
size = rec.file_size or 0
|
||||
if size < 1024:
|
||||
rec.file_size_display = f"{size} B"
|
||||
elif size < 1024 ** 2:
|
||||
rec.file_size_display = f"{size / 1024:.2f} KB"
|
||||
elif size < 1024 ** 3:
|
||||
rec.file_size_display = f"{size / 1024 ** 2:.2f} MB"
|
||||
else:
|
||||
rec.file_size_display = f"{size / 1024 ** 3:.2f} GB"
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from . import models
|
||||
from . import controllers
|
||||
@@ -0,0 +1 @@
|
||||
from . import main
|
||||
@@ -0,0 +1,42 @@
|
||||
import base64
|
||||
import json
|
||||
|
||||
from odoo import http, fields
|
||||
from odoo.http import request
|
||||
|
||||
|
||||
class YuthonNotice(http.Controller):
|
||||
|
||||
@http.route('/yuthon/yuthon/notice', methods=['POST'], type='http', auth='none', csrf=False)
|
||||
def index(self, **kwargs):
|
||||
id = kwargs.get('id')
|
||||
|
||||
data = request.env['yuthon.notice'].sudo().search([("id", "=", int(id))])
|
||||
documents = []
|
||||
for document in data.documents_ids:
|
||||
documents.append({
|
||||
'id': document.id,
|
||||
'name': document.name,
|
||||
'url': document.url,
|
||||
'type': document.type,
|
||||
'file_size': document.file_size,
|
||||
'file_size_display':document.file_size_display,
|
||||
'mimetype': document.mimetype,
|
||||
'datas': document.datas.decode('utf-8') if document.datas else None,
|
||||
})
|
||||
|
||||
result = {
|
||||
'id': data.id,
|
||||
'title': data.name,
|
||||
'code': data.code,
|
||||
'create_date1': fields.Date.to_string(data.create_date1),
|
||||
'notice_text': data.notice_text,
|
||||
'documents':documents,
|
||||
'user_name':data.users_id.name,
|
||||
'read_number': data.read_number,
|
||||
}
|
||||
return json.dumps({
|
||||
'data':result,
|
||||
'code':200,
|
||||
'message':'success'
|
||||
})
|
||||
@@ -2,3 +2,4 @@
|
||||
|
||||
from . import models
|
||||
from . import wizard
|
||||
from . import controllers
|
||||
@@ -0,0 +1 @@
|
||||
from . import main
|
||||
@@ -0,0 +1,50 @@
|
||||
import base64
|
||||
import json
|
||||
|
||||
from odoo import http, fields
|
||||
from odoo.http import request
|
||||
from odoo.tools import float_is_zero,float_round
|
||||
|
||||
|
||||
class YuthonSalary(http.Controller):
|
||||
|
||||
@http.route('/yuthon/yuthon/salary', methods=['POST'], type='http', auth='none', csrf=False)
|
||||
def index2(self, **kwargs):
|
||||
id = kwargs.get('id')
|
||||
|
||||
data = request.env['hr.payslip'].sudo().search(domain = [("id", "=", int(id))])
|
||||
lines_ids = []
|
||||
amount_total = 0.0
|
||||
for line in data.line_ids:
|
||||
if float_is_zero(line.total, precision_rounding=line.currency_id.rounding):
|
||||
continue
|
||||
total = float_round(line.total, precision_rounding=line.currency_id.rounding)
|
||||
amount_total += total
|
||||
lines_ids.append({
|
||||
'id':line.id,
|
||||
'name':line.name,
|
||||
'code':line.code,
|
||||
'category_id':line.category_id.name,
|
||||
'total':total,
|
||||
'amount':line.amount,
|
||||
|
||||
'sequence':line.sequence,
|
||||
'appears_on_payslip':line.appears_on_payslip,
|
||||
'slip_id':line.slip_id.id,
|
||||
})
|
||||
|
||||
result = {
|
||||
'id':data.id,
|
||||
'name':data.name,
|
||||
'payslip_run_id':data.payslip_run_id.name,
|
||||
'date_from':fields.Date.to_string(data.date_from),
|
||||
'date_to':fields.Date.to_string(data.date_to),
|
||||
'lines_ids':lines_ids,
|
||||
'amount_total':amount_total,
|
||||
}
|
||||
|
||||
return json.dumps({
|
||||
'data':result,
|
||||
'code':200,
|
||||
'message':'success'
|
||||
})
|
||||
@@ -1 +1,2 @@
|
||||
from . import models
|
||||
from . import models
|
||||
from . import controllers
|
||||
@@ -0,0 +1 @@
|
||||
from . import main
|
||||
@@ -0,0 +1,57 @@
|
||||
import base64
|
||||
import json
|
||||
|
||||
from odoo import http, fields
|
||||
from odoo.http import request
|
||||
from odoo.tools import float_is_zero,float_round
|
||||
|
||||
|
||||
class YuthonWillTask(http.Controller):
|
||||
|
||||
@http.route('/yuthon/yuthon/will/task', methods=['POST'], type='http', auth='none', csrf=False)
|
||||
def index2(self, **kwargs):
|
||||
id = kwargs.get('id')
|
||||
|
||||
data = request.env['yuthon.will.task'].sudo().search(domain = [("id", "=", int(id))])
|
||||
|
||||
employee_ids = []
|
||||
for em in data.employee_ids:
|
||||
employee_ids.append({
|
||||
'id':em.id,
|
||||
'name':em.name,
|
||||
'image_1920':em.image_128.decode('utf-8') if em.image_128 else '',
|
||||
})
|
||||
result = {
|
||||
'id':data.id,
|
||||
'name':data.name,
|
||||
'code':data.code,
|
||||
'start_date':fields.Date.to_string(data.start_date),
|
||||
'request_hour_from':data.request_hour_from,
|
||||
'request_hour_to':data.request_hour_to,
|
||||
'priority':data.priority,
|
||||
'user_id':data.user_id.name,
|
||||
'user_avatar':base64.b64decode(data.user_id.avatar_128).decode('utf-8') if data.user_id.avatar_128 else '',
|
||||
'remarks':data.remarks,
|
||||
'address':data.address,
|
||||
'employee_ids':employee_ids,
|
||||
}
|
||||
|
||||
# 转换 request_hour_from 和 request_hour_to 取模型 yuthon.will.task 的 request_hour_from 的selection
|
||||
request_hour_from_selection = request.env['yuthon.will.task'].sudo().fields_get(allfields=['request_hour_from'])['request_hour_from']['selection']
|
||||
request_hour_to_selection = request.env['yuthon.will.task'].sudo().fields_get(allfields=['request_hour_to'])['request_hour_to']['selection']
|
||||
|
||||
for f in request_hour_from_selection:
|
||||
if f[0] == data.request_hour_from:
|
||||
result['request_hour_from'] = f[1]
|
||||
for f in request_hour_to_selection:
|
||||
if f[0] == data.request_hour_to:
|
||||
result['request_hour_to'] = f[1]
|
||||
|
||||
# 计算 start_date 星期几
|
||||
result['start_date_week'] = fields.Date.from_string(result['start_date']).strftime('%A')
|
||||
|
||||
return json.dumps({
|
||||
'data':result,
|
||||
'code':200,
|
||||
'message':'success'
|
||||
})
|
||||
Reference in New Issue
Block a user