[IMP] hr_timesheet_sheet: Simplify line adding

Before this commit, you had to click on "Add a line", then select
a value in the m2o which appeared, then click on "Add". Now, the m2o
is always there in edit mode and you just have to click "Add" once.
This commit is contained in:
qsm-odoo
2015-09-08 14:14:32 +02:00
parent 7c18c68f96
commit fd3e17795d
6 changed files with 98 additions and 97 deletions
@@ -1,45 +0,0 @@
.o_web_client .oe_timesheet_weekly {
overflow-x: auto;
}
.o_web_client .oe_timesheet_weekly > table {
width: 100%;
}
.o_web_client .oe_timesheet_weekly > table > tbody > tr.oe_timesheet_weekly_add_row {
display: none;
}
.o_web_client .oe_timesheet_weekly > table > tbody > tr.oe_timesheet_weekly_add_row > td {
text-align: left;
}
.o_web_client .oe_timesheet_weekly > table > tbody > tr > td {
text-align: right;
}
.o_web_client .oe_timesheet_weekly > table > tbody > tr > td.oe_timesheet_total {
font-weight: bold;
}
.o_web_client .oe_timesheet_weekly > table > tbody > tr > td.oe_timesheet_weekly_account {
white-space: nowrap;
text-align: left;
}
.o_web_client .oe_timesheet_weekly > table > tbody > tr > td input.oe_timesheet_weekly_input {
display: inline-block;
width: 40px;
text-align: right;
}
.o_web_client .oe_timesheet_weekly > table > tbody > tr > th {
text-align: center;
font-size: 10px;
background: #eee;
}
.o_web_client .oe_timesheet_weekly .oe_timesheet_total {
background: #eee;
}
.o_web_client .oe_timesheet_weekly .oe_timesheet_button_add {
float: left;
}
.o_web_client .oe_timesheet_weekly .oe_timesheet_weekly_today {
background: #fde;
}
.openerp .oe_timesheet_weekly > table > tbody > tr > th {
color: #069;
}
@@ -1,38 +0,0 @@
@charset "utf-8"
.o_web_client
.oe_timesheet_weekly
overflow-x: auto
> table
width: 100%
> tbody > tr
&.oe_timesheet_weekly_add_row
display: none
> td
text-align: left
> td
text-align: right
&.oe_timesheet_total
font-weight: bold
&.oe_timesheet_weekly_account
white-space: nowrap
text-align: left
input.oe_timesheet_weekly_input
display: inline-block
width: 40px
text-align: right
> th
text-align: center
font-size: 10px
background: #eee
.oe_timesheet_total
background: #eee
.oe_timesheet_button_add
float: left
.oe_timesheet_weekly_today
background: #fde
.openerp
.oe_timesheet_weekly
> table > tbody > tr > th
color: #069
@@ -235,7 +235,9 @@ var WeeklyTimesheet = form_common.FormWidget.extend(form_common.ReinitializeWidg
});
});
self.display_totals();
self.$(".oe_timesheet_button_add").click(_.bind(this.init_add_account, this));
if(!this.get('effective_readonly')) {
this.init_add_account();
}
},
init_add_account: function() {
if (this.dfm) {
@@ -261,10 +263,10 @@ var WeeklyTimesheet = form_common.FormWidget.extend(form_common.ReinitializeWidg
modifiers: '{"required": true}',
},
});
this.account_m2o.prependTo(this.$(".oe_timesheet_weekly_add_row td")).then(function() {
self.account_m2o.$el.addClass('oe_inline');
this.account_m2o.prependTo(this.$(".o_add_timesheet_line > div")).then(function() {
self.account_m2o.$el.addClass('oe_edit_only');
});
this.$(".oe_timesheet_weekly_add_row button").click(function() {
this.$(".oe_timesheet_button_add").click(function() {
var id = self.account_m2o.get_value();
if (id === false) {
self.dfm.set({display_invalid_fields: true});
@@ -0,0 +1,83 @@
.o_web_client .oe_timesheet_weekly {
overflow-x: auto;
> table {
width: 100%;
> tbody > tr {
> th {
text-align: center;
font-size: 10px;
background-color: @odoo-brand-lightsecondary;
}
> td {
text-align: right;
&.oe_timesheet_weekly_account {
white-space: nowrap;
text-align: left;
}
input.oe_timesheet_weekly_input {
display: inline-block;
width: 40px;
text-align: right;
}
.oe_timesheet_button_add {
margin-left: 8px;
}
.o_with_button + .oe_timesheet_button_add {
margin-left: 45px;
}
}
.oe_timesheet_weekly_today {
background-color: lighten(@odoo-brand-primary, 40%);
}
.oe_timesheet_total {
font-weight: bold;
background-color: @odoo-brand-lightsecondary;
}
.o_add_timesheet_line {
width: 1%;
background-color: @odoo-brand-lightsecondary;
> div {
.o-flex-display();
.o-align-items(center);
.o_form_field_many2one {
min-width: 200px;
margin: 0;
}
.o_external_button {
background-color: @odoo-brand-lightsecondary;
padding-top: 0;
padding-bottom: 0;
}
.oe_timesheet_button_add {
.o-flex(0, 0, auto);
margin-left: 8px;
}
.o_with_button + .oe_timesheet_button_add {
margin-left: 45px;
}
}
}
}
}
}
.openerp .oe_timesheet_weekly {
> table > tbody > tr {
> th {
color: #069;
}
.o_add_timesheet_line {
width: auto;
}
}
}
@@ -4,7 +4,7 @@
<div class="oe_timesheet_weekly">
<table class="table table-condensed table-responsive">
<tr>
<th class="oe_timesheet_first_col"/>
<th class="oe_timesheet_first_col" colspan="2"/>
<t t-foreach="widget.dates" t-as="date">
<th t-att-class="'oe_timesheet_weekly_date_head' + (moment().format('DD-MM-YYYY') === moment(date).format('DD-MM-YYYY') ? ' oe_timesheet_weekly_today' : '')">
<t t-esc="moment(date).format('ddd')"/><br/>
@@ -14,7 +14,7 @@
<th class="oe_timesheet_weekly_date_head">Total</th>
</tr>
<tr t-foreach="widget.accounts" t-as="account">
<td class="oe_timesheet_weekly_account"><a href="javascript:void(0)" t-att-data-id="JSON.stringify(account.account)"><t t-esc="widget.account_names[account.account]"/></a></td>
<td class="oe_timesheet_weekly_account" colspan="2"><a href="javascript:void(0)" t-att-data-id="JSON.stringify(account.account)"><t t-esc="widget.account_names[account.account]"/></a></td>
<t t-set="day_count" t-value="0"/>
<t t-foreach="account.days" t-as="day">
<td t-att-class="moment().format('DD-MM-YYYY') === moment(day.day).format('DD-MM-YYYY') ? 'oe_timesheet_weekly_today' : ''">
@@ -27,14 +27,13 @@
</t>
<td t-att-data-account-total="account.account" class="oe_timesheet_total"/>
</tr>
<tr class="oe_timesheet_weekly_add_row">
<td t-att-colspan="widget.dates.length + 2">
<button class="btn btn-sm btn-default">Add</button>
<tr>
<td class="o_add_timesheet_line">
<div>
<button t-if="!widget.get('effective_readonly')" class="btn btn-sm btn-primary oe_edit_only oe_timesheet_button_add">Add a Line</button>
</div>
</td>
</tr>
<tr class="oe_timesheet_total">
<td>
<button t-if="!widget.get('effective_readonly')" class="btn btn-sm btn-primary oe_edit_only oe_timesheet_button_add">Add a Line</button>
<td class="oe_timesheet_total">
Total
</td>
<t t-set="day_count" t-value="0"/>
@@ -3,7 +3,7 @@
<data>
<template id="assets_backend" name="hr_timesheet_sheet assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<link rel="stylesheet" href="/hr_timesheet_sheet/static/src/css/timesheet.css"/>
<link rel="stylesheet" href="/hr_timesheet_sheet/static/src/less/timesheet.less"/>
<script type="text/javascript" src="/hr_timesheet_sheet/static/src/js/timesheet.js"></script>
</xpath>
</template>