Skip to content
Extraits de code Groupes Projets
Valider 15398bd6 rédigé par Benjamin - Le Filament's avatar Benjamin - Le Filament
Parcourir les fichiers

[cgscop #202] paramétrage nb d'heures mensuelles par UR

parent 22ada0f0
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -24,8 +24,12 @@
"views/res_company.xml",
"views/res_partner.xml",
"views/ur_financial_system.xml",
"views/ur_month_timesheet.xml",
"views/ur_regional_convention.xml",
"report/report_hr_timesheet.xml",
"datas/cgscop_timesheet_code_data.xml",
]
],
'qweb': [
'static/src/xml/*.xml',
],
}
......@@ -8,5 +8,6 @@ from . import project
from . import res_company
from . import res_partner
from . import ur_financial_system
from . import ur_month_timesheet
from . import ur_regional_convention
# © 2019 Le Filament (<http://www.le-filament.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models, fields, api
def get_years():
year_list = []
for i in range(2019, 2030):
year_list.append((i, str(i)))
return year_list
MONTHS = [(1, 'Janv'), (2, 'Fév'), (3, 'Mars'), (4, 'Avr'),
(5, 'Mai'), (6, 'Juin'), (7, 'Juil'), (8, 'Août'),
(9, 'Sept'), (10, 'Oct'), (11, 'Nov'), (12, 'Dec')]
class ScopMonthTimesheet(models.Model):
_name = "ur.month.timesheet"
_description = "Heures theoriques mensuelles"
_order = 'year, month'
def _default_ur(self):
return self.env['res.company']._ur_default_get()
year = fields.Selection(
selection=get_years(),
string='Année',
default=fields.Date.today().year)
month = fields.Selection(
selection=MONTHS,
string='Année')
company_id = fields.Many2one(
comodel_name='res.company',
string='Société',
default=lambda self: self.env.user.company_id)
ur_id = fields.Many2one(
'union.regionale',
string='Union Régionale',
index=True,
on_delete='restrict',
default=_default_ur)
working_time = fields.Integer('Heures théoriques')
_sql_constraints = [(
'month_year_uniq',
'UNIQUE (year, month, ur_id)',
'Cette date a déjà été renseignée.'
)]
@api.model
def get_month_values(self):
month_values = self.search([
'&', '|', '&',
('year', '<', fields.Date.today().year),
('month', '>', fields.Date.today().month),
'&',
('year', '<', fields.Date.today().year + 1),
('month', '<=', fields.Date.today().month + 1),
('ur_id', '=', self.env.user.ur_id.id)],
limit=12,
order='year desc, month desc').sorted(reverse=False)
return {
'month': month_values.mapped(lambda x: {
'year': x.year,
'num_month': x.month,
'month': self._fields['month'].selection[x.month-1][1]}),
'values': month_values.mapped('working_time'),
'today': {
'year': fields.Date.today().year,
'month': fields.Date.today().month
}
}
......@@ -12,3 +12,6 @@ access_cgscop_timesheet_sheet_user,access_cgscop_timesheet_sheet_user,model_cgsc
access_ur_regional_convention,access_ur_regional_convention,model_ur_regional_convention,base.group_user,1,0,0,0
access_ur_regional_convention_ur_manager,access_ur_regional_convention_ur,model_ur_regional_convention,cgscop_partner.group_ur_list_modif,1,1,1,1
access_ur_regional_convention_cg_manager,access_ur_regional_convention_cg,model_ur_regional_convention,cgscop_partner.group_cg_administrator,1,1,1,1
access_ur_month_timesheet,access_ur_month_timesheet,model_ur_month_timesheet,base.group_user,1,0,0,0
access_ur_month_timesheet_ur_manager,access_ur_month_timesheet_ur,model_ur_month_timesheet,cgscop_partner.group_ur_list_modif,1,1,1,1
access_ur_month_timesheet_cg_manager,access_ur_month_timesheet_cg,model_ur_month_timesheet,cgscop_partner.group_cg_administrator,1,1,1,1
\ No newline at end of file
// © 2019 Le Filament (<http://www.le-filament.com>)
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
odoo.define('cgscop_timesheet.ur_month_timesheet', function (require) {
"use strict";
var core = require('web.core');
var session = require('web.session');
var AbstractAction = require('web.AbstractAction');
var QWeb = core.qweb;
var ScopMonthTimesheet = AbstractAction.extend({
template: 'ScopMonthTimesheet',
willStart: function() {
var deferred = new jQuery.Deferred();
var self = this;
this.values = {};
this._rpc({
model: 'ur.month.timesheet',
method: 'get_month_values',
args: [],
})
.then(function(results) {
self.values = results;
deferred.resolve();
});
return jQuery.when(this._super.apply(this, arguments),deferred);
},
start: function() {
},
});
core.action_registry.add('cgscop_timesheet.ur_month_timesheet', ScopMonthTimesheet);
});
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2019 Le Filament (<https://www.le-filament.com>)
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<templates xml:space="preserve">
<t t-name="ScopMonthTimesheet">
<table class="table">
<thead>
<tr>
<t t-foreach="widget.values.month" t-as="m">
<t t-if="m.num_month == widget.values.today.month and m.year == widget.values.today.year">
<th class="text-success">
<t t-esc="m.month"/> <t t-esc="m.year"/>
</th>
</t>
<t t-else="">
<th>
<t t-esc="m.month"/> <t t-esc="m.year"/>
</th>
</t>
</t>
</tr>
</thead>
<tbody>
<tr>
<t t-foreach="widget.values.values" t-as="v">
<td><t t-esc="v"/> h</td>
</t>
</tr>
</tbody>
</table>
</t>
</templates>
......@@ -7,6 +7,8 @@
<template id="cgscop_assets_backend" name="account assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<link rel="stylesheet" type="text/css" href="/cgscop_timesheet/static/src/css/style.css"/>
<script type="text/javascript" src="/cgscop_timesheet/static/src/js/ur_month_timesheet.js"></script>
</xpath>
</template>
......
<?xml version="1.0"?>
<!-- Copyright 2019 Le Filament
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<data>
<record id="view_ur_month_timesheet_tree" model="ir.ui.view">
<field name="name">ur.month.timesheet.tree</field>
<field name="model">ur.month.timesheet</field>
<field name="arch" type="xml">
<tree editable='top'>
<field name="year" required="1"/>
<field name="month" required="1"/>
<field name="working_time" required="1"/>
<field name="ur_id" options="{'no_open': True, 'no_create': True}" readonly="1"/>
</tree>
</field>
</record>
<record id="action_ur_month_timesheet" model="ir.actions.act_window">
<field name="name">Temps de travail mensuel</field>
<field name="res_model">ur.month.timesheet</field>
<field name="view_mode">tree</field>
</record>
<record id="action_ur_month_timesheet_show" model="ir.actions.client">
<field name="name">Temps de travail théorique</field>
<field name="tag">cgscop_timesheet.ur_month_timesheet</field>
<field name="target">new</field>
<field name="binding_model_id" ref="model_ur_month_timesheet"/>
<field name="binding_type">action</field>
</record>
<menuitem id="menu_ur_month_timesheet"
name="Temps de travail mensuel"
parent="hr_timesheet.hr_timesheet_menu_configuration"
action="action_ur_month_timesheet"
sequence="50"
groups="cgscop_partner.group_ur_list_modif"/>
<menuitem id="menu_ur_month_timesheet_show"
parent="hr_timesheet.menu_hr_time_tracking"
action="action_ur_month_timesheet_show"
sequence="50"/>
</data>
</odoo>
\ No newline at end of file
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter