mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
search range 完成pivot
todo:时差
This commit is contained in:
@@ -13,7 +13,7 @@ Search by date or number range in List view and Pivot view
|
|||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
|
||||||
""",
|
""",
|
||||||
'depends': ['web'],
|
'depends': ['web','app_odoo_customize'],
|
||||||
'data': [
|
'data': [
|
||||||
'views/template_view.xml',
|
'views/template_view.xml',
|
||||||
# data
|
# data
|
||||||
|
|||||||
@@ -67,69 +67,15 @@ PivotView.include({
|
|||||||
format : time.strftime_to_moment_format(l10n.date_format),
|
format : time.strftime_to_moment_format(l10n.date_format),
|
||||||
}
|
}
|
||||||
|
|
||||||
// self.$buttons.find('.app-search').remove();
|
// Dropdown list
|
||||||
|
|
||||||
var app_fields = [];
|
|
||||||
_.each(self.fields, function(value, key, list){
|
|
||||||
if (value.store && value.type === "datetime" || value.type === "date") {
|
|
||||||
app_fields.push([key, value.string]);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (app_fields.length > 0) {
|
|
||||||
self.$search_button = $(QWeb.render('odooApp.buttons', {'app_fields': app_fields}))
|
|
||||||
self.$search_button.find('.app_start_date').datetimepicker(datepickers_options);
|
|
||||||
self.$search_button.find('.app_end_date').datetimepicker(datepickers_options);
|
|
||||||
self.$search_button.find('.app_start_date').on('change', function() {
|
|
||||||
self.tgl_search();
|
|
||||||
});
|
|
||||||
self.$search_button.find('.app_end_date').on('change', function() {
|
|
||||||
self.tgl_search();
|
|
||||||
});
|
|
||||||
self.$search_button.find('.app_select_field').on('change', function() {
|
|
||||||
self.tgl_search();
|
|
||||||
});
|
|
||||||
self.$search_button.appendTo($node);
|
|
||||||
}
|
|
||||||
|
|
||||||
app_fields = [];
|
|
||||||
_.each(self.fields, function(value, key, list){
|
|
||||||
if (value.string && value.string.length > 1 && value.store && (value.type === "integer" || value.type === "float" || value.type === "monetary")) {
|
|
||||||
app_fields.push([key, value.string]);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
if (app_fields.length > 0) {
|
|
||||||
self.$search_range = $(QWeb.render('odooApp.SearchRange', {'app_fields': app_fields}))
|
|
||||||
self.$search_range.find('.app_select_range_field').on('change', function() {
|
|
||||||
self.tgl_search();
|
|
||||||
});
|
|
||||||
self.$search_range.find('.app_start_range').on('change', function() {
|
|
||||||
self.tgl_search();
|
|
||||||
});
|
|
||||||
self.$search_range.find('.app_end_range').on('change', function() {
|
|
||||||
self.tgl_search();
|
|
||||||
});
|
|
||||||
self.$search_range.appendTo($node);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dropdown list cho phep chon nhieu
|
|
||||||
|
|
||||||
$(QWeb.render("TGL.TreeSearch.Placeholder", {})).appendTo($node);
|
$(QWeb.render("TGL.TreeSearch.Placeholder", {})).appendTo($node);
|
||||||
|
|
||||||
_.each(ts_context, function(item){
|
_.each(ts_context, function(item){
|
||||||
|
|
||||||
var field = _.find(self.fields, function(value, key, list){
|
var field = _.find(self.fields, function(value, key, list){
|
||||||
return value.type == 'many2one' && value.relation && key === item.name;
|
return value.type == 'many2one' && value.relation && key === item.name;
|
||||||
});
|
});
|
||||||
|
|
||||||
// _.each(self.fields, function(value, key, list){
|
|
||||||
// if (value.string && value.string.length > 1 && value.store && (value.type === "integer" || value.type === "float")) {
|
|
||||||
// app_fields.push([value.name, value.string]);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
if (field) {
|
if (field) {
|
||||||
self.ts_fields.push(item.name);
|
self.ts_fields.push(item.name);
|
||||||
|
|
||||||
@@ -143,15 +89,73 @@ PivotView.include({
|
|||||||
|
|
||||||
$multi_search.find('li').click(self.tgl_on_button_click.bind(self));
|
$multi_search.find('li').click(self.tgl_on_button_click.bind(self));
|
||||||
|
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
$multi_search.appendTo($('.treesearch_placeholder'));
|
$multi_search.appendTo($('.treesearch_placeholder'));
|
||||||
}, 3000);
|
}, 2000);
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// self.$buttons.find('.app-search').remove();
|
||||||
|
|
||||||
|
var date_fields = [];
|
||||||
|
// 增加参数控制app_show_search_date
|
||||||
|
new Model('ir.config_parameter').call('search_read', [[['key', '=', 'app_show_search_date']], ['value']]).then(function (show) {
|
||||||
|
if (show.length >= 1 && (show[0]['value'] == "True")) {
|
||||||
|
_.each(self.fields, function (value, key, list) {
|
||||||
|
if (value.store && value.type === "datetime" || value.type === "date") {
|
||||||
|
date_fields.push([key, value.string]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (date_fields.length > 0) {
|
||||||
|
self.$search_button = $(QWeb.render('odooApp.buttons', {'date_fields': date_fields}))
|
||||||
|
self.$search_button.find('.app_start_date').datetimepicker(datepickers_options);
|
||||||
|
self.$search_button.find('.app_end_date').datetimepicker(datepickers_options);
|
||||||
|
self.$search_button.find('.app_start_date').on('change', function () {
|
||||||
|
self.tgl_search();
|
||||||
|
});
|
||||||
|
self.$search_button.find('.app_end_date').on('change', function () {
|
||||||
|
self.tgl_search();
|
||||||
|
});
|
||||||
|
self.$search_button.find('.app_select_field').on('change', function () {
|
||||||
|
self.tgl_search();
|
||||||
|
});
|
||||||
|
setTimeout(function () {
|
||||||
|
self.$search_button.insertBefore($('.treesearch_placeholder'));
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var number_fields = [];
|
||||||
|
|
||||||
|
// 增加参数控制app_show_search_number
|
||||||
|
new Model('ir.config_parameter').call('search_read', [[['key', '=', 'app_show_search_number']], ['value']]).then(function (show) {
|
||||||
|
if (show.length >= 1 && (show[0]['value'] == "True")) {
|
||||||
|
number_fields = [];
|
||||||
|
_.each(self.fields, function (value, key, list) {
|
||||||
|
if (value.string && value.string.length > 1 && value.store && (value.type === "integer" || value.type === "float" || value.type === "monetary")) {
|
||||||
|
number_fields.push([key, value.string]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (number_fields.length > 0) {
|
||||||
|
self.$search_range = $(QWeb.render('odooApp.SearchRange', {'number_fields': number_fields}))
|
||||||
|
self.$search_range.find('.app_select_range_field').on('change', function () {
|
||||||
|
self.tgl_search();
|
||||||
|
});
|
||||||
|
self.$search_range.find('.app_start_range').on('change', function () {
|
||||||
|
self.tgl_search();
|
||||||
|
});
|
||||||
|
self.$search_range.find('.app_end_range').on('change', function () {
|
||||||
|
self.tgl_search();
|
||||||
|
});
|
||||||
|
setTimeout(function () {
|
||||||
|
self.$search_range.insertBefore($('.treesearch_placeholder'));
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
do_search: function(domain, context, group_by) {
|
do_search: function(domain, context, group_by) {
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ ListView.include({
|
|||||||
|
|
||||||
var l10n = _t.database.parameters;
|
var l10n = _t.database.parameters;
|
||||||
var datepickers_options = {
|
var datepickers_options = {
|
||||||
pickTime: false,
|
pickTime: true,
|
||||||
startDate: moment({ y: 1900 }),
|
startDate: moment({ y: 1900 }),
|
||||||
endDate: moment().add(200, "y"),
|
endDate: moment().add(200, "y"),
|
||||||
calendarWeeks: true,
|
calendarWeeks: true,
|
||||||
@@ -134,7 +134,7 @@ ListView.include({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Dropdown list cho phep chon nhieu
|
// Dropdown list
|
||||||
_.each(this.ts_context, function(item){
|
_.each(this.ts_context, function(item){
|
||||||
var field = _.find(self.columns, function(column){
|
var field = _.find(self.columns, function(column){
|
||||||
return column.type == 'many2one' && column.relation && column.name === item.name;
|
return column.type == 'many2one' && column.relation && column.name === item.name;
|
||||||
@@ -213,7 +213,7 @@ ListView.include({
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
});
|
});
|
||||||
|
// todo: 时区处理
|
||||||
if (self.$search_button) {
|
if (self.$search_button) {
|
||||||
var start_date = self.$search_button.find('.app_start_date').val(),
|
var start_date = self.$search_button.find('.app_start_date').val(),
|
||||||
end_date = self.$search_button.find('.app_end_date').val(),
|
end_date = self.$search_button.find('.app_end_date').val(),
|
||||||
|
|||||||
@@ -15,11 +15,11 @@
|
|||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span style="float: left; margin-left: 2px;">
|
<span style="float: left; margin-left: 2px;">
|
||||||
<input style="height: 30px;" class="app_start_date form-control" size="14" placeholder="Start date" type="text" />
|
<input style="height: 30px;" class="app_start_date form-control" size="15" placeholder="Start date" type="text" />
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span style="float: left; margin-left: 2px;">
|
<span style="float: left; margin-left: 2px;">
|
||||||
<input style="height: 30px;" class="app_end_date form-control" size="14" placeholder="End date" type="text" />
|
<input style="height: 30px;" class="app_end_date form-control" size="15" placeholder="End date" type="text" />
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<!-- <button style="margin-left: 2px; padding: 5px 10px;" class="app_search_date_rate btn btn-primary" title="Field">Lọc</button> -->
|
<!-- <button style="margin-left: 2px; padding: 5px 10px;" class="app_search_date_rate btn btn-primary" title="Field">Lọc</button> -->
|
||||||
@@ -78,12 +78,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</t>
|
</t>
|
||||||
|
|
||||||
<!-- <t t-extend="PivotView.buttons">
|
|
||||||
<t t-jquery="> :last" t-operation="after">
|
|
||||||
<div class="treesearch_placeholder" />
|
|
||||||
</t>
|
|
||||||
</t> -->
|
|
||||||
|
|
||||||
<t t-name="TGL.TreeSearch.Placeholder">
|
<t t-name="TGL.TreeSearch.Placeholder">
|
||||||
<div class="treesearch_placeholder" />
|
<div class="treesearch_placeholder" />
|
||||||
</t>
|
</t>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<template id="assets_backend" inherit_id="web.assets_backend">
|
<template id="assets_backend" inherit_id="web.assets_backend">
|
||||||
<xpath expr="." position="inside">
|
<xpath expr="." position="inside">
|
||||||
<link rel="stylesheet" type="text/css" href="/app_search_range/static/src/css/main.css"/>
|
<link rel="stylesheet" type="text/css" href="/app_search_range/static/src/css/app_search_range.css"/>
|
||||||
<script type="text/javascript" src="/app_search_range/static/src/js/pivot.js"></script>
|
<script type="text/javascript" src="/app_search_range/static/src/js/pivot.js"></script>
|
||||||
<script type="text/javascript" src="/app_search_range/static/src/js/tree.js"></script>
|
<script type="text/javascript" src="/app_search_range/static/src/js/tree.js"></script>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
|||||||
Reference in New Issue
Block a user