This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@http.route('/api/v1/mro/upload_file', type='http', auth="user", method=['POST'], website=True, csrf=False) | |
def upload_requirement_file(self, ufile, res_id=0, res_model, **kwargs): | |
file = ufile | |
if file: | |
# 附件模型 | |
Attachment = request.env['ir.attachment'] | |
# 创建附件 | |
attach = Attachment.create({ | |
'name': file.filename, | |
'res_model': res_model, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@http.route('/api/v1/mro/delete_file', type='json', auth="user", method=['POST'], website=True) | |
def del_requirement_file(self, **kwargs): | |
data = request.jsonrequest | |
if data: | |
attach_ids = data.get('ids', None) | |
domain = [('id', 'in', attach_ids)] | |
res_id = data.get('res_id', None) | |
res_model = data.get('res_model', None) | |
if res_id: | |
domain.append(('res_id', '=', res_id)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import logging | |
from odoo import models, fields, api | |
_logger = logging.getLogger(__name__) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
utc8_datetime = datetime.datetime.utcnow() + datetime.timedelta(hours=8) | |
min_datetime = datetime.datetime.combine(utc8_datetime.date(), datetime.time.min) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var params = {name: 'Lucy', addr: 'Street#233'} | |
var res = $.param(params) | |
console.log(res) // name=Lucy&addr=Street%23233 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// _oo0oo_ | |
// o8888888o | |
// 88" . "88 | |
// (| -_- |) | |
// 0\ = /0 | |
// ___/`---'\___ | |
// .' \\| |// '. | |
// / \\||| : |||// \ | |
// / _||||| -:- |||||- \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const arr = [4, 5, 3, 1, 6, 3, 4, 1] | |
let res = arr.reduce((countObj, ele) => { | |
if (ele in countObj) { | |
countObj[ele]++; | |
} else { | |
countObj[ele] = 1; | |
} | |
return countObj; | |
}, {}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="nav"> | |
<ul> | |
<li class="nav-item"> | |
<a href="javascript:;"><i class="my-icon nav-icon icon_1"></i><span>网站配置</span><i class="my-icon nav-more"></i></a> | |
<ul style="display: none;"> | |
<li><a href="javascript:;"><span>网站设置</span></a></li> | |
<li><a href="javascript:;"><span>友情链接</span></a></li> | |
<li><a href="javascript:;"><span>分类管理</span></a></li> | |
<li><a href="javascript:;"><span>系统日志</span></a></li> | |
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 为数字添加千分符 | |
function intcomma (num) { | |
if ($.isNumeric(num)) { | |
var DIGIT_PATTERN = /(^|\s)\d+(?=\.?\d*($|\s))/g; | |
var MILLI_PATTERN = /(?=(?!\b)(\d{3})+$)/g; | |
return num.toString().replace(DIGIT_PATTERN, function (m) { | |
return m.replace(MILLI_PATTERN, ','); | |
}); | |
} else { | |
return num; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function format (source, args) { | |
var result = source; | |
if (typeof(args) == "object") { | |
if (args.length == undefined) { | |
for (var key in args) { | |
if (args[key] != undefined) { | |
var reg = new RegExp("({" + key + "})", "g"); | |
result = result.replace(reg, args[key]); | |
} | |
} |
OlderNewer