diff --git a/lefilament_projets.py b/lefilament_projets.py index 45469a31223bc5e4c1aa7688da8995671dfeba29..d84cc32dabff5d09096d28e0ba18dc656e872004 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 0000000000000000000000000000000000000000..b6ea2098e4c7350872fd65559a90470a2ad7f0f6 --- /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 f3ed8ea371e5fc956995b689821fac05a48c3478..28e5e18384d34c6f7b1e9c6a680210c40b7b40fa 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 554c1a763afb05673d375221367357bda2cbcad5..c9e7be6361995d0dd84826afe4624bbe9368bf12 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>