From 3665fc830b157e5a3a4a0b37ee93e074c73c8cdd Mon Sep 17 00:00:00 2001 From: Benjamin <benjamin@le-filament.com> Date: Mon, 23 Dec 2019 12:39:37 +0100 Subject: [PATCH] [MIG] Make module installable in v12 --- README.rst | 15 +++++++++------ __manifest__.py | 27 +++++---------------------- models/__init__.py | 1 + models/project.py | 6 ++---- models/res_company.py | 15 +++++++++++++++ models/res_config.py | 22 ++++++---------------- views/lefilament_projets_view.xml | 16 +++------------- views/res_config.xml | 28 ++++++++++++++++++++++++++++ 8 files changed, 69 insertions(+), 61 deletions(-) create mode 100644 models/res_company.py create mode 100644 views/res_config.xml diff --git a/README.rst b/README.rst index a6675d5..9f0cbd2 100644 --- a/README.rst +++ b/README.rst @@ -10,23 +10,26 @@ Le Filament - Projets This module depends upon *hr_timesheet* and *hr_expense* modules. This module provides: - - the calculation of imputed hours and costs on the project - - the project estimate (based on a variable of the number of hours per day) - - a progressbar spent / budget - - prospecting hours (new field to set up at the project level and based on the number of hours charged to a task named Prospection) + +* the calculation of imputed hours and costs on the project +* the project estimate (based on a variable of the number of hours per day) +* a progressbar spent / budget +* prospecting hours (new field to set up at the project level and based on the number of hours charged to a task named Prospection) Credits ======= -Contributors ------------ +Contributors +------------ * Benjamin Rivier <benjamin@le-filament.com> * Remi Cazenave <remi@le-filament.com> * Juliana Poudou <juliana@le-filament.com> -Maintainer ---------- +Maintainer +---------- .. image:: https://le-filament.com/img/logo-lefilament.png :alt: Le Filament diff --git a/__manifest__.py b/__manifest__.py index b9be38b..1c44433 100644 --- a/__manifest__.py +++ b/__manifest__.py @@ -1,26 +1,8 @@ { 'name': 'Le Filament - Projets', - - 'summary': """ - Projets Le Filament""", - - 'version': '10.0.1.0.0', + 'summary': "Projects Le Filament", + 'version': '12.0.1.0.0', 'license': 'AGPL-3', - 'description': """ - - Module Projet Le Filament - - This module depends upon *hr_timesheet* and *hr_expense* modules. - - This module provides: - - the calculation of imputed hours and costs on the project - - the project estimate (based on a variable of the number of hours per day) - - a progressbar spent / budget - - prospecting hours (new field to set up at the project level and based on - the number of hours charged to a task named Prospection) - - """, - 'author': 'LE FILAMENT', 'category': 'Project', 'depends': ['hr_timesheet', 'hr_expense'], @@ -31,10 +13,11 @@ ], 'website': 'https://le-filament.com', 'data': [ + 'security/ir.model.access.csv', 'views/assets.xml', - 'views/lefilament_projets_view.xml', 'views/account_analytic_view.xml', - 'security/ir.model.access.csv', + 'views/lefilament_projets_view.xml', + 'views/res_config.xml', ], 'qweb': [ ], diff --git a/models/__init__.py b/models/__init__.py index d5e155f..bf89ba5 100644 --- a/models/__init__.py +++ b/models/__init__.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- from . import project +from . import res_company from . import res_config diff --git a/models/project.py b/models/project.py index 6d1f04c..458bb30 100644 --- a/models/project.py +++ b/models/project.py @@ -34,8 +34,7 @@ class FilamentProjet(models.Model): @api.one def _taux_horaire(self): - lf_heures_jour = self.env['ir.values'].get_default( - 'project.config.settings', 'lf_heures_jour') + lf_heures_jour = self.env.user.company_id.lf_heures_jour self.lf_taux_horaire = self.lf_tarif_jour / lf_heures_jour @api.one @@ -95,8 +94,7 @@ class FilamentProjet(models.Model): @api.one def _total_heures(self): - lf_heures_jour = self.env['ir.values'].get_default( - 'project.config.settings', 'lf_heures_jour') + lf_heures_jour = self.env.user.company_id.lf_heures_jour if self.lf_tarif_jour != 0.0: self.lf_heures_projet = (self.lf_heures_budget / self.lf_tarif_jour) * lf_heures_jour diff --git a/models/res_company.py b/models/res_company.py new file mode 100644 index 0000000..f91e569 --- /dev/null +++ b/models/res_company.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# © 2019 Le Filament (<https://www.le-filament.com>) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class ResCompany(models.Model): + _inherit = 'res.company' + + lf_heures_jour = fields.Float( + 'Hours / Day', + help="Time base for calculating the number of hours sold per project \ + (default 7h)", + default=7.0) diff --git a/models/res_config.py b/models/res_config.py index 0840c99..bd4becc 100644 --- a/models/res_config.py +++ b/models/res_config.py @@ -1,28 +1,18 @@ # -*- coding: utf-8 -*- - -# © 2017 Le Filament (<https://www.le-filament.com>) +# © 2019 Le Filament (<https://www.le-filament.com>) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from odoo import api, fields, models class ProjectLFConfiguration(models.TransientModel): - _name = 'project.config.settings' - _inherit = 'project.config.settings' + _name = 'res.config.settings' + _inherit = 'res.config.settings' lf_heures_jour = fields.Float( 'Hours / Day', help="Time base for calculating the number of hours sold per project \ (default 7h)", - default=7.0) - - @api.multi - def set_default_lf_heures_jour(self): - return self.env['ir.values'].sudo().set_default( - 'project.config.settings', 'lf_heures_jour', self.lf_heures_jour) - - @api.multi - def get_default_lf_heures_jour(self, field): - lf_heures_jour = self.env['ir.values'].get_default( - 'project.config.settings', 'lf_heures_jour') - return {'lf_heures_jour': lf_heures_jour if lf_heures_jour else 7.0} + default=7.0, + related="company_id.lf_heures_jour", + readonly=False) diff --git a/views/lefilament_projets_view.xml b/views/lefilament_projets_view.xml index 1dd91a7..2e4c840 100644 --- a/views/lefilament_projets_view.xml +++ b/views/lefilament_projets_view.xml @@ -9,7 +9,7 @@ <field name="model">project.project</field> <field name="inherit_id" ref="project.edit_project"/> <field name="arch" type="xml"> - <xpath expr="//field[@name='use_tasks']" position="before"> + <xpath expr="//label[@for='label_tasks']" position="before"> <div> <field name="use_prospection" class="oe_inline"/> <label for="use_prospection" class="oe_inline"/> @@ -88,7 +88,7 @@ </tbody> </table> <div class="project-progress"> - <field name="lf_heures_restantes" widget="progress" options="{'current_value': 'lf_heures_passees', 'max_value': 'lf_heures_projet', 'editable': false, 'edit_max_value': false, }" /> + <field name="lf_heures_restantes" widget="progressbar" options="{'current_value': 'lf_heures_passees', 'max_value': 'lf_heures_projet', 'editable': false, 'edit_max_value': false, }" /> </div> <table class="budget_table"> <tbody> @@ -113,7 +113,7 @@ <table class="budget_table"> <tbody> <tr> - <td><a t-if="record.use_tasks.raw_value" name="%(project.act_project_project_2_project_task_all)d" type="action">Tasks</a></td> + <td><a name="%(project.act_project_project_2_project_task_all)d" type="action">Tasks</a></td> <td><a type="open">Project</a></td> </tr> </tbody> @@ -126,15 +126,5 @@ </field> </record> - <record id="view_lf_project_config_settings" model="ir.ui.view"> - <field name="name">project lf settings</field> - <field name="model">project.config.settings</field> - <field name="inherit_id" ref="project.view_config_settings"/> - <field name="arch" type="xml"> - <xpath expr="//field[@name='module_rating_project']" position="after"> - <field name="lf_heures_jour" class="oe_inline oe_text_right" /> - </xpath> - </field> - </record> </data> </odoo> diff --git a/views/res_config.xml b/views/res_config.xml new file mode 100644 index 0000000..743852a --- /dev/null +++ b/views/res_config.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<odoo> + + <record id="lefilament_projets_config_settings" model="ir.ui.view"> + <field name="name">Le Filament Projets Settings</field> + <field name="model">res.config.settings</field> + <field name="inherit_id" ref="project.res_config_settings_view_form"/> + <field name="arch" type="xml"> + <div id="use_collaborative_pad" position="before"> + <div class="col-12 col-lg-6 o_setting_box" id="lf_projects_setting"> + <div class="o_setting_left_pane"> + </div> + <div class="o_setting_right_pane"> + <div class="text-muted"> + Time base for calculating the number of hours sold per project (default 7h) + </div> + <div class="content-group" > + <div class="row mt16"> + <field name="lf_heures_jour"/> + </div> + </div> + </div> + </div> + </div> + </field> + </record> + +</odoo> \ No newline at end of file -- GitLab