From fd3e17795d956aa8d025f013262de926071997cd Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Tue, 8 Sep 2015 11:58:25 +0200 Subject: [PATCH] [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. --- .../static/src/css/timesheet.css | 45 ---------- .../static/src/css/timesheet.sass | 38 --------- .../static/src/js/timesheet.js | 10 ++- .../static/src/less/timesheet.less | 83 +++++++++++++++++++ .../static/src/xml/timesheet.xml | 17 ++-- .../views/hr_timesheet_sheet.xml | 2 +- 6 files changed, 98 insertions(+), 97 deletions(-) delete mode 100644 addons/hr_timesheet_sheet/static/src/css/timesheet.css delete mode 100644 addons/hr_timesheet_sheet/static/src/css/timesheet.sass create mode 100644 addons/hr_timesheet_sheet/static/src/less/timesheet.less diff --git a/addons/hr_timesheet_sheet/static/src/css/timesheet.css b/addons/hr_timesheet_sheet/static/src/css/timesheet.css deleted file mode 100644 index f91e6342e2a..00000000000 --- a/addons/hr_timesheet_sheet/static/src/css/timesheet.css +++ /dev/null @@ -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; -} diff --git a/addons/hr_timesheet_sheet/static/src/css/timesheet.sass b/addons/hr_timesheet_sheet/static/src/css/timesheet.sass deleted file mode 100644 index 32dbd4a46ab..00000000000 --- a/addons/hr_timesheet_sheet/static/src/css/timesheet.sass +++ /dev/null @@ -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 \ No newline at end of file diff --git a/addons/hr_timesheet_sheet/static/src/js/timesheet.js b/addons/hr_timesheet_sheet/static/src/js/timesheet.js index 853edaaeb71..51008cc3082 100644 --- a/addons/hr_timesheet_sheet/static/src/js/timesheet.js +++ b/addons/hr_timesheet_sheet/static/src/js/timesheet.js @@ -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}); diff --git a/addons/hr_timesheet_sheet/static/src/less/timesheet.less b/addons/hr_timesheet_sheet/static/src/less/timesheet.less new file mode 100644 index 00000000000..c052e99fc47 --- /dev/null +++ b/addons/hr_timesheet_sheet/static/src/less/timesheet.less @@ -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; + } + } +} diff --git a/addons/hr_timesheet_sheet/static/src/xml/timesheet.xml b/addons/hr_timesheet_sheet/static/src/xml/timesheet.xml index e9478ba1629..f75bd094cad 100644 --- a/addons/hr_timesheet_sheet/static/src/xml/timesheet.xml +++ b/addons/hr_timesheet_sheet/static/src/xml/timesheet.xml @@ -4,7 +4,7 @@
- - + - - + - - - diff --git a/addons/hr_timesheet_sheet/views/hr_timesheet_sheet.xml b/addons/hr_timesheet_sheet/views/hr_timesheet_sheet.xml index 2bd85c34db5..1f6a905756d 100644 --- a/addons/hr_timesheet_sheet/views/hr_timesheet_sheet.xml +++ b/addons/hr_timesheet_sheet/views/hr_timesheet_sheet.xml @@ -3,7 +3,7 @@
+
@@ -14,7 +14,7 @@
Total
@@ -27,14 +27,13 @@
- +
+
+ +
- + Total