diff --git a/__init__.py b/__init__.py index a466ab60178673ae32b8bbfc522c3e85a091e698..93aa2c1f84b46bf5c841c4b4526a02d30c6fe128 100644 --- a/__init__.py +++ b/__init__.py @@ -1,3 +1,4 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from . import models \ No newline at end of file +from . import models +from . import wizard diff --git a/__manifest__.py b/__manifest__.py index d26de549b348bfde84187fa24f8b23a721a808cb..f5d7c8c2227022572be3c5b2cce3a0d19079916e 100644 --- a/__manifest__.py +++ b/__manifest__.py @@ -21,6 +21,8 @@ "views/hr_timesheet_cgscop.xml", "views/res_partner.xml", "views/ur_financial_system.xml", + "wizard/print_timesheet.xml", + "wizard/report_hr_timesheet.xml", "datas/cgscop.timesheet.code.csv", ] } diff --git a/wizard/__init__.py b/wizard/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..c23811f435b5e1f64fa475979e5177fbb95f5db0 --- /dev/null +++ b/wizard/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import print_timesheet diff --git a/wizard/print_timesheet.py b/wizard/print_timesheet.py new file mode 100644 index 0000000000000000000000000000000000000000..cc2e109ba3b682a09299f735b9d97095bdef20f7 --- /dev/null +++ b/wizard/print_timesheet.py @@ -0,0 +1,32 @@ +# Copyright 2019 Le Filament (<http://www.le-filament.com>) +# License AGPL-3 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import models, fields, api + + +class CGscopTimesheetPrintWizard(models.TransientModel): + _name = "cgscop.timesheet.print" + _description = "Wizard Timesheet Impression" + + date_start = fields.Date('Date de début', required=True) + date_end = fields.Date('Date de fin', required=True) + user_id = fields.Many2one( + comodel_name="res.users", + string="Employé", + default=lambda self: self.env.user, + required=True) + timesheet_ids = fields.Many2many( + comodel_name="account.analytic.line") + + @api.multi + def print_timesheet(self): + self.timesheet_ids = self.env['account.analytic.line'].sudo().search([ + ['user_id', '=', self.user_id.id], + ['date', '>=', self.date_start], + ['date', '<=', self.date_end]]) + + print(self) + print(self.timesheet_ids) + return self.env.ref( + 'cgscop_timesheet.cgscop_timesheet_report').report_action(self) + diff --git a/wizard/print_timesheet.xml b/wizard/print_timesheet.xml new file mode 100644 index 0000000000000000000000000000000000000000..f8673d0fec86f180390a5e465d74141cd420611d --- /dev/null +++ b/wizard/print_timesheet.xml @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8"?> +<odoo> + <record id="cgscop_timesheet_print_view_form" model="ir.ui.view"> + <field name="name">cgscop.timesheet.print.form</field> + <field name="model">cgscop.timesheet.print</field> + <field name="arch" type="xml"> + <form string="Impression feuille de temps"> + <group> + <group> + <field name="date_start"/> + </group> + <group> + <field name="date_end"/> + </group> + </group> + <group> + <group> + <field name="user_id" /> + </group> + </group> + <footer> + <button class="btn btn-sm btn-primary" name="print_timesheet" string="Imprimer" type="object"/> + <button class="btn btn-sm btn-default" special="cancel" string="Fermer"/> + </footer> + </form> + </field> + </record> + + <record id="cgscop_timesheet_print_action" model="ir.actions.act_window"> + <field name="name">Imprimer Feuille de Temps</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">cgscop.timesheet.print</field> + <field name="view_mode">form</field> + <field name="view_id" ref="cgscop_timesheet_print_view_form"/> + <field name="target">new</field> + </record> + + <menuitem action="cgscop_timesheet_print_action" id="menu_cgscop_timesheet_print" name="Imprimer Feuille de Temps" parent="hr_timesheet.menu_hr_time_tracking" sequence="50" /> +</odoo> diff --git a/wizard/report_hr_timesheet.xml b/wizard/report_hr_timesheet.xml new file mode 100644 index 0000000000000000000000000000000000000000..98d8e63f8e8431de48e3011a84be2b0dd65b1704 --- /dev/null +++ b/wizard/report_hr_timesheet.xml @@ -0,0 +1,82 @@ +<?xml version="1.0" encoding="utf-8"?> +<odoo> + <data> + <template id="report_timesheet_document"> + <t t-call="web.external_layout"> + <t t-set="o" t-value="o.with_context(lang=lang)" /> + <div class="page"> + <h2> + Feuille de Temps + </h2> + + <div id="informations" class="row mt32 mb32"> + <div class="col-auto mw-100 mb-2" name="employee"> + <strong>Employé</strong> + <p class="m-0" t-field="o.user_id.name"/> + </div> + <div class="col-auto mw-100 mb-2" > + <strong>Date de début</strong> + <p class="m-0" t-field="o.date_start"/> + </div> + <div class="col-auto mw-100 mb-2" name="date_end"> + <strong>Date de fin</strong> + <p class="m-0" t-field="o.date_end"/> + </div> + </div> + + <table class="table table-sm o_main_table" name="invoice_line_table"> + <thead> + <tr> + <th class="text-left"><span>Date</span></th> + <th class="text-left"><span>Code activité UR</span></th> + <th class="text-left"><span>Contact</span></th> + <th class="text-left"><span>Dispositif</span></th> + <th class="text-left"><span>Durée</span></th> + </tr> + </thead> + <tbody class="invoice_tbody"> + <t t-foreach="o.timesheet_ids" t-as="line"> + <tr> + <td><span t-field="line.date"/></td> + <td><span t-field="line.project_id"/></td> + <td><span t-field="line.partner_id"/></td> + <td><span t-field="line.ur_financial_system_id"/></td> + <td class="text-right"><span t-field="line.unit_amount" t-options="{'widget': 'duration', 'digital': True, 'unit': 'hour', 'round': 'minute'}"/></td> + </tr> + <tr> + <td /> + <td /> + <td /> + <td class="text-right"><strong>Total</strong></td> + <td class="text-right"><strong t-esc="sum(o.timesheet_ids.mapped('unit_amount'))" t-options="{'widget': 'duration', 'digital': True, 'unit': 'hour', 'round': 'minute'}"/></td> + </tr> + </t> + </tbody> + </table> + </div> + </t> + </template> + + <template id="report_timesheet"> + <t t-call="web.html_container"> + <t t-foreach="docs" t-as="o"> + <t t-set="lang" t-value="o.user_id.lang"/> + <t t-call="cgscop_timesheet.report_timesheet_document" t-lang="lang"/> + </t> + </t> + </template> + + <!-- QWeb Reports --> + <report + id="cgscop_timesheet_report" + model="cgscop.timesheet.print" + string="Feuilles de Temps" + report_type="qweb-pdf" + name="cgscop_timesheet.report_timesheet" + file="cgscop_timesheet.report_timesheet" + menu="False" + /> + + + </data> +</odoo>