diff --git a/__manifest__.py b/__manifest__.py index 853bbdd443839d8491e992fd76c53bf78ad11d0a..4549e14e80f675057461c4cba35765e849032c0e 100644 --- a/__manifest__.py +++ b/__manifest__.py @@ -22,6 +22,7 @@ "views/cgscop_timesheet_sheet.xml", "views/hr_timesheet.xml", "views/hr_timesheet_cgscop.xml", + "views/res_company.xml", "views/res_partner.xml", "views/ur_financial_system.xml", "views/ur_regional_convention.xml", diff --git a/models/__init__.py b/models/__init__.py index 15e2aa43fc51a54c5666dca8e5dbb13ebe25e1f2..035a9fe80a994b8bff66ad6ad19afdba37d676b1 100644 --- a/models/__init__.py +++ b/models/__init__.py @@ -5,6 +5,7 @@ from . import cgscop_timesheet_code from . import cgscop_timesheet_sheet from . import hr_timesheet from . import project +from . import res_company from . import res_partner from . import ur_financial_system from . import ur_regional_convention diff --git a/models/hr_timesheet.py b/models/hr_timesheet.py index f9566a47a445e2d59bcdb52f1fc58c5bc923b370..45ced85de5bc60713f73bc3a93bda0e387b5a28f 100644 --- a/models/hr_timesheet.py +++ b/models/hr_timesheet.py @@ -105,10 +105,13 @@ class ScopHrTimesheet(models.Model): ('date', '=', record.date), ('employee_id', '=', record.employee_id.id)]) total = sum(lines.mapped('unit_amount')) - if total > 8: + if (not self.env.user.company_id.day_working + and total > self.env.user.company_id.day_duration): raise ValidationError( - "Vous ne pourvez imputer plus de 8h sur la même journée.\n" - "Journée du %s" % record.date.strftime("%d/%m/%Y")) + "Vous ne pourvez imputer plus de %sh sur la même journée.\n" + "Journée du %s" % ( + self.env.user.company_id.day_duration, + record.date.strftime("%d/%m/%Y"))) @api.constrains('date') def _check_weekday(self): diff --git a/models/res_company.py b/models/res_company.py new file mode 100644 index 0000000000000000000000000000000000000000..71519325ece5d6a6745f0c5090a7b346ebd8489b --- /dev/null +++ b/models/res_company.py @@ -0,0 +1,18 @@ +# © 2019 Le Filament (<http://www.le-filament.com>) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class ResCompanyTmesheet(models.Model): + _inherit = "res.company" + + day_duration = fields.Float( + string='Nb Heures/Jour', + default=8, + help="Nombre d'heures max pour imputation") + day_working = fields.Boolean( + string='Forfait Jour', + default=False, + help='Si cette option est cochée, un employé peut imputer sans limite' + ' de temps sur une journée') diff --git a/views/res_company.xml b/views/res_company.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e353fe5e59791c9c729ceba682ea506cef4401d --- /dev/null +++ b/views/res_company.xml @@ -0,0 +1,25 @@ +<?xml version="1.0"?> +<!-- Copyright 2019 Le Filament + License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> + +<odoo> + <data> + <record id="company_form_with_ur" model="ir.ui.view"> + <field name="name">scop.res.company.timesheet.form</field> + <field name="model">res.company</field> + <field name="inherit_id" ref="base.view_company_form"/> + <field name="arch" type="xml"> + <xpath expr="//notebook/page" position="after"> + <page name="company_timesheet" string="Feuilles de temps"> + <group> + <group string="Condiguration Imputations"> + <field name="day_working" widget="boolean_toggle"/> + <field name="day_duration" attrs="{'invisible': [('day_working', '=', True)]}"/> + </group> + </group> + </page> + </xpath> + </field> + </record> + </data> +</odoo>