处理datetime与date类型的区别

todo:处理pivot视图
This commit is contained in:
ivan deng
2017-11-16 03:40:41 +08:00
parent 9877161b4c
commit ba8d281846
9 changed files with 46 additions and 13 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 113 KiB

After

Width:  |  Height:  |  Size: 325 KiB

View File

@@ -2,7 +2,7 @@
<div class="oe_row oe_spaced">
<h2 class="oe_slogan" style="color:#875A7B;">Date range</h2>
<div class="oe_demo oe_picture oe_screenshot">
<img src="date_range.png">
<img src="date_range.jpg">
</div>
</div>
</section>
@@ -11,7 +11,16 @@
<div class="oe_row oe_spaced">
<h2 class="oe_slogan" style="color:#875A7B;">Value range</h2>
<div class="oe_demo oe_picture oe_screenshot">
<img src="value_range.png">
<img src="value_range.jpg">
</div>
</div>
</section>
<section class="oe_container oe_dark">
<div class="oe_row oe_spaced">
<h2 class="oe_slogan" style="color:#875A7B;">Pivot View</h2>
<div class="oe_demo oe_picture oe_screenshot">
<img src="list_pivot.jpg">
</div>
</div>
</section>

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 205 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 KiB

After

Width:  |  Height:  |  Size: 246 KiB

View File

@@ -52,7 +52,7 @@ ListView.include({
var l10n = _t.database.parameters;
var datepickers_options = {
pickTime: true,
pickTime: false,
startDate: moment({ y: 1900 }),
endDate: moment().add(200, "y"),
calendarWeeks: true,
@@ -74,7 +74,7 @@ ListView.include({
if (show.length >= 1 && (show[0]['value'] == "True")) {
_.each(self.columns, function (value, key, list) {
if (value.store && value.type === "datetime" || value.type === "date") {
date_fields.push([value.name, value.string]);
date_fields.push([value.name, value.string, value.type]);
}
});
if (date_fields.length > 0) {
@@ -213,22 +213,46 @@ ListView.include({
// }
// }
});
// todo: 时区处理
// todo: 注意date和datetime型的处理是不同的已处理完datetime类型还有date类型
if (self.$search_button) {
var start_date = self.$search_button.find('.app_start_date').val(),
end_date = self.$search_button.find('.app_end_date').val(),
field = self.$search_button.find('.app_select_field').val();
field = self.$search_button.find('.app_select_field').val(),
field_type = 'datetime';
var tz = session.user_context.tz,
start_utc,
end_utc;
_.each(self.columns, function (value, key, list) {
if (value.name == field) {
field_type = value.type;
}
});
moment.locale(tz);
var l10n = _t.database.parameters;
if (start_date) {
if (field_type = 'date') {
//日期类型无须utc处理
start_date = moment(moment(start_date, time.strftime_to_moment_format(l10n.date_format))).format('YYYY-MM-DD');
domain.push([field, '>=', start_date]);
} else {
//日期时间处理utc
start_date = moment(moment(start_date, time.strftime_to_moment_format(l10n.date_format))).format('YYYY-MM-DD 00:00:00');
start_utc = moment(start_date)
domain.push([field, '>=', start_utc]);
}
}
if (end_date) {
if (field_type = 'date') {
end_date = moment(moment(end_date, time.strftime_to_moment_format(l10n.date_format))).format('YYYY-MM-DD');
domain.push([field, '<=', end_date]);
domain.push([field, '>=', end_date]);
} else {
end_date = moment(moment(end_date, time.strftime_to_moment_format(l10n.date_format))).format('YYYY-MM-DD 00:00:00');
end_utc = moment(end_date)
domain.push([field, '<=', end_utc]);
}
}
}
if (self.$search_range) {

View File

@@ -8,7 +8,7 @@
<span style="float: left;">
<select class="app_select_field form-control" style="height: 30px;" >
<option t-foreach="date_fields" t-as="field" t-att-value="field[0]">
<option t-foreach="date_fields" t-as="field" t-att-value="field[0]" t-att-type="field[2]">
<t t-esc="field[1]"/>
</option>
</select>