mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
增加可配置的search range
This commit is contained in:
@@ -16,6 +16,8 @@ Search by date or number range in List view and Pivot view
|
|||||||
'depends': ['web'],
|
'depends': ['web'],
|
||||||
'data': [
|
'data': [
|
||||||
'views/template_view.xml',
|
'views/template_view.xml',
|
||||||
|
# data
|
||||||
|
'data/ir_config_parameter.xml',
|
||||||
],
|
],
|
||||||
'qweb': [
|
'qweb': [
|
||||||
'static/src/xml/*.xml',
|
'static/src/xml/*.xml',
|
||||||
|
|||||||
13
app_search_range/data/ir_config_parameter.xml
Normal file
13
app_search_range/data/ir_config_parameter.xml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<openerp>
|
||||||
|
<data noupdate="0">
|
||||||
|
<record id="app_show_search_date" model="ir.config_parameter">
|
||||||
|
<field name="key">app_show_search_date</field>
|
||||||
|
<field name="value">True</field>
|
||||||
|
</record>
|
||||||
|
<record id="app_show_search_number" model="ir.config_parameter">
|
||||||
|
<field name="key">app_show_search_number</field>
|
||||||
|
<field name="value">True</field>
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
|
</openerp>
|
||||||
@@ -68,32 +68,35 @@ ListView.include({
|
|||||||
|
|
||||||
self.$buttons.find('.app-search').remove();
|
self.$buttons.find('.app-search').remove();
|
||||||
|
|
||||||
// Tim kiem theo khoang thoi gian
|
|
||||||
|
|
||||||
var app_fields = [];
|
var app_fields = [];
|
||||||
_.each(self.columns, function(value, key, list){
|
_.each(self.columns, function(value, key, list){
|
||||||
if (value.store && value.type === "datetime" || value.type === "date") {
|
if (value.store && value.type === "datetime" || value.type === "date") {
|
||||||
app_fields.push([value.name, value.string]);
|
app_fields.push([value.name, value.string]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (app_fields.length > 0) {
|
// 增加参数控制app_show_search_date
|
||||||
self.$search_button = $(QWeb.render('odooApp.buttons', {'app_fields': app_fields}))
|
new Model('ir.config_parameter').call('search_read', [[['key', '=', 'app_show_search_date']], ['value']]).then(function (show) {
|
||||||
self.$search_button.find('.app_start_date').datetimepicker(datepickers_options);
|
if (show.length >= 1 && (show[0]['value'] == "True")) {
|
||||||
self.$search_button.find('.app_end_date').datetimepicker(datepickers_options);
|
if (app_fields.length > 0) {
|
||||||
// self.$search_button.find('.app_search_date_rate').click(function() {
|
self.$search_button = $(QWeb.render('odooApp.buttons', {'app_fields': app_fields}))
|
||||||
// self.tgl_search();
|
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.$search_button.find('.app_search_date_rate').click(function() {
|
||||||
self.tgl_search();
|
// self.tgl_search();
|
||||||
});
|
// });
|
||||||
self.$search_button.find('.app_end_date').on('change', function() {
|
self.$search_button.find('.app_start_date').on('change', function () {
|
||||||
self.tgl_search();
|
self.tgl_search();
|
||||||
});
|
});
|
||||||
self.$search_button.find('.app_select_field').on('change', function() {
|
self.$search_button.find('.app_end_date').on('change', function () {
|
||||||
self.tgl_search();
|
self.tgl_search();
|
||||||
});
|
});
|
||||||
self.$search_button.appendTo(self.$buttons);
|
self.$search_button.find('.app_select_field').on('change', function () {
|
||||||
}
|
self.tgl_search();
|
||||||
|
});
|
||||||
|
self.$search_button.appendTo(self.$buttons);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
app_fields = [];
|
app_fields = [];
|
||||||
@@ -109,22 +112,27 @@ ListView.include({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (app_fields.length > 0) {
|
// 增加参数控制app_show_search_number
|
||||||
self.$search_range = $(QWeb.render('odooApp.SearchRange', {'app_fields': app_fields}))
|
new Model('ir.config_parameter').call('search_read', [[['key', '=', 'app_show_search_number']], ['value']]).then(function (show) {
|
||||||
// self.$search_range.find('.app_search_date_range').click(function() {
|
if (show.length >= 1 && (show[0]['value'] == "True")) {
|
||||||
// self.tgl_search();
|
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.$search_range.find('.app_search_date_range').click(function() {
|
||||||
self.tgl_search();
|
// self.tgl_search();
|
||||||
});
|
// });
|
||||||
self.$search_range.find('.app_start_range').on('change', function() {
|
self.$search_range.find('.app_select_range_field').on('change', function () {
|
||||||
self.tgl_search();
|
self.tgl_search();
|
||||||
});
|
});
|
||||||
self.$search_range.find('.app_end_range').on('change', function() {
|
self.$search_range.find('.app_start_range').on('change', function () {
|
||||||
self.tgl_search();
|
self.tgl_search();
|
||||||
});
|
});
|
||||||
self.$search_range.appendTo(self.$buttons);
|
self.$search_range.find('.app_end_range').on('change', function () {
|
||||||
}
|
self.tgl_search();
|
||||||
|
});
|
||||||
|
self.$search_range.appendTo(self.$buttons);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Dropdown list cho phep chon nhieu
|
// Dropdown list cho phep chon nhieu
|
||||||
_.each(this.ts_context, function(item){
|
_.each(this.ts_context, function(item){
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<templates id="template" xml:space="preserve">
|
<templates id="template" xml:space="preserve">
|
||||||
|
<!--日期类型搜索-->
|
||||||
<t t-name="odooApp.buttons">
|
<t t-name="odooApp.buttons">
|
||||||
<div class="app-search btn-group btn-group-sm" >
|
<div class="app-search btn-group btn-group-sm" >
|
||||||
<!-- <div style="margin-left: 10px; margin-top: 2px;"> -->
|
<!-- <div style="margin-left: 10px; margin-top: 2px;"> -->
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<!-- <br></br> -->
|
<!-- <br></br> -->
|
||||||
</t>
|
</t>
|
||||||
|
<!--数值范围搜索-->
|
||||||
<t t-name="odooApp.SearchRange">
|
<t t-name="odooApp.SearchRange">
|
||||||
<div class="app-search btn-group btn-group-sm" >
|
<div class="app-search btn-group btn-group-sm" >
|
||||||
<!-- <div style="margin-left: 10px; margin-top: 2px;"> -->
|
<!-- <div style="margin-left: 10px; margin-top: 2px;"> -->
|
||||||
|
|||||||
Reference in New Issue
Block a user