From aeb330846e482cdb29fb19bc1791338ef8744297 Mon Sep 17 00:00:00 2001 From: Benjamin <Benjamin@MBP-de-Benj.(none)> Date: Thu, 3 Aug 2017 18:16:07 +0200 Subject: [PATCH] =?UTF-8?q?[modif]=20migration=20:=20-=20changement=20de?= =?UTF-8?q?=20m=C3=A9thode=20de=20calcul=20des=20heures=20via=20project=5F?= =?UTF-8?q?id=20de=20la=20table=20account=5Fanalytic=5Fline=20-=20changeme?= =?UTF-8?q?nt=20de=20m=C3=A9thode=20de=20calcul=20des=20co=C3=BBts=20annex?= =?UTF-8?q?es=20via=20l'account=5Fanalytic=5Fid=20sur=20la=20table=20hr=5F?= =?UTF-8?q?expense=20-=20surcharge=20du=20widget=20PROGRESSBAR=20pour=20qu?= =?UTF-8?q?'il=20marque=20l'overflow=20sur=20les=20projets=20(comme=20dans?= =?UTF-8?q?=20la=20v9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lefilament_projets.py | 9 +++--- static/src/js/widget.js | 46 +++++++++++++++++++++++++++++++ static/src/less/style.less | 4 ++- views/lefilament_projets_view.xml | 2 ++ 4 files changed, 55 insertions(+), 6 deletions(-) create mode 100644 static/src/js/widget.js diff --git a/lefilament_projets.py b/lefilament_projets.py index 45469a3..d84cc32 100644 --- a/lefilament_projets.py +++ b/lefilament_projets.py @@ -28,9 +28,9 @@ class FilamentProjet(models.Model): @api.one def _total_heures_passees(self): res = 0.0 - account = self.analytic_account_id.id - ############## Calcul couts annexes ################ - self.env.cr.execute("select sum(unit_amount) from account_analytic_line where account_id=%s;", (account, ) ) + project = self.id + ############## Calcul heures ################ + self.env.cr.execute("select sum(unit_amount) from account_analytic_line where project_id=%s;", (project, ) ) heures_passees = self.env.cr.fetchone()[0] if heures_passees: self.lf_heures_passees = heures_passees @@ -49,8 +49,7 @@ class FilamentProjet(models.Model): def _couts_annexes(self): account = self.analytic_account_id.id ############## Calcul couts annexes ################ - ## self.env.cr.execute("select sum(amount) from account_analytic_line where amount<0 and is_timesheet=FALSE and account_id=%s;", (account, ) ) - self.env.cr.execute("select sum(amount) from account_analytic_line where amount<0 and account_id=%s;", (account, ) ) + self.env.cr.execute("select sum(untaxed_amount) from hr_expense where analytic_account_id=%s;", (account, ) ) couts_annexes = self.env.cr.fetchone()[0] if couts_annexes: self.lf_couts_annexes = couts_annexes * (-1.0) diff --git a/static/src/js/widget.js b/static/src/js/widget.js new file mode 100644 index 0000000..b6ea209 --- /dev/null +++ b/static/src/js/widget.js @@ -0,0 +1,46 @@ +// path_to_your_module/static/src/js/form_widgets.js +odoo.define('lefilament_projets.progress_bar', function (require) { + "use strict"; + + var core = require('web.core'); + var utils = require('web.utils'); + var Widget = require('web.Widget'); + var ProgressBar = require('web.ProgressBar'); + + ProgressBar.include({ + _render_value: function(v) { + var value = this.value; + var max_value = this.max_value; + if(!isNaN(v)) { + if(this.edit_max_value) { + max_value = v; + } else { + value = v; + } + } + value = value || 0; + max_value = max_value || 0; + + var widthComplete; + if(value <= max_value) { + widthComplete = value/max_value * 100; + } else { + widthComplete = max_value/value * 100; + } + + this.$('.o_progress').toggleClass('o_progress_overflow', value > max_value); + this.$('.o_progressbar_complete').css('width', widthComplete + '%'); + + if(this.readonly) { + if(max_value !== 100) { + this.$('.o_progressbar_value').html(utils.human_number(value) + " / " + utils.human_number(max_value)); + } else { + this.$('.o_progressbar_value').html(utils.human_number(value) + "%"); + } + } else if(isNaN(v)) { + this.$('.o_progressbar_value').val(this.edit_max_value ? max_value : value); + } + } + }); + +}); \ No newline at end of file diff --git a/static/src/less/style.less b/static/src/less/style.less index f3ed8ea..28e5e18 100644 --- a/static/src/less/style.less +++ b/static/src/less/style.less @@ -14,4 +14,6 @@ } .project-progress .o_progressbar .o_progress.o_progress_overflow { background-color: rgb(246, 172, 162); -} \ No newline at end of file +} +.o_kanban_view.o_kanban_dashboard.o_project_kanban .o_project_kanban_main { margin-bottom: 0; } +.o_kanban_view .o_invisible { height: 0;} \ No newline at end of file diff --git a/views/lefilament_projets_view.xml b/views/lefilament_projets_view.xml index 554c1a7..c9e7be6 100644 --- a/views/lefilament_projets_view.xml +++ b/views/lefilament_projets_view.xml @@ -7,6 +7,8 @@ <template id="assets_backend" name="project assets le filament" inherit_id="web.assets_backend"> <xpath expr="." position="inside"> <link rel="stylesheet" href="/lefilament_projets/static/src/less/style.less"/> + + <script type="text/javascript" src="/lefilament_projets/static/src/js/widget.js"></script> </xpath> </template> -- GitLab