Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • lefilament/cgscop/cgscop_timesheet
  • hsilvant/cgscop_timesheet
2 results
Select Git revision
Show changes
Commits on Source (23)
Showing
with 460 additions and 62 deletions
......@@ -6,6 +6,8 @@ exclude: |
^setup/|/static/description/index\.html$|
# We don't want to mess with tool-generated files
.svg$|/tests/([^/]+/)?cassettes/|^.copier-answers.yml$|^.github/|
# Maybe reactivate this when all README files include prettier ignore tags?
^README\.md$|
# Library files can have extraneous formatting (even minimized)
/static/(src/)?lib/|
# Repos using Sphinx to generate docs don't need prettying
......@@ -25,8 +27,13 @@ repos:
entry: found forbidden files; remove them
language: fail
files: "\\.rej$"
- id: en-po-files
name: en.po files cannot exist
entry: found a en.po file
language: fail
files: '[a-zA-Z0-9_]*/i18n/en\.po$'
- repo: https://github.com/oca/maintainer-tools
rev: 7d8a9f9ad73db0976fb03cbee43d953bc29b89e9
rev: ab1d7f6
hooks:
# update the NOT INSTALLABLE ADDONS section above
- id: oca-update-pre-commit-excluded-addons
......@@ -48,7 +55,7 @@ repos:
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.6.2
rev: v2.1.2
hooks:
- id: prettier
name: prettier (with plugin-xml)
......@@ -59,7 +66,7 @@ repos:
- --plugin=@prettier/plugin-xml
files: \.(css|htm|html|js|json|jsx|less|md|scss|toml|ts|xml|yaml|yml)$
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v8.15.0
rev: v7.8.1
hooks:
- id: eslint
verbose: true
......@@ -67,7 +74,7 @@ repos:
- --color
- --fix
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
rev: v3.2.0
hooks:
- id: trailing-whitespace
# exclude autogenerated files
......@@ -89,37 +96,33 @@ repos:
- id: mixed-line-ending
args: ["--fix=lf"]
- repo: https://github.com/asottile/pyupgrade
rev: v2.32.1
rev: v2.7.2
hooks:
- id: pyupgrade
args: ["--keep-percent-format"]
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort
name: isort except __init__.py
args:
- --settings=.
exclude: /__init__\.py$
- repo: https://gitlab.com/PyCQA/flake8
rev: 3.9.2
- repo: https://github.com/PyCQA/flake8
rev: 3.8.3
hooks:
- id: flake8
name: flake8
additional_dependencies: ["flake8-bugbear==20.1.4"]
- repo: https://github.com/PyCQA/pylint
rev: v2.11.1
- repo: https://github.com/OCA/pylint-odoo
rev: 7.0.2
hooks:
- id: pylint
- id: pylint_odoo
name: pylint with optional checks
args:
- --rcfile=.pylintrc
- --exit-zero
verbose: true
additional_dependencies: &pylint_deps
- pylint-odoo==5.0.5
- id: pylint
name: pylint with mandatory checks
- id: pylint_odoo
args:
- --rcfile=.pylintrc-mandatory
additional_dependencies: *pylint_deps
# © 2019 Le Filament (<http://www.le-filament.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models
from . import models, wizard
......@@ -18,6 +18,7 @@
"data": [
"security/ir.model.access.csv",
"security/security_rules.xml",
"wizard/cgscop_timesheet_print_wizard.xml",
"views/assets.xml",
"views/cgscop_timesheet_code.xml",
"views/cgscop_timesheet_sheet.xml",
......@@ -29,6 +30,7 @@
"views/ur_month_timesheet.xml",
"views/ur_regional_convention.xml",
"report/report_hr_timesheet.xml",
"report/report_hr_timesheet_act.xml",
"datas/cgscop_timesheet_code_data.xml",
],
"qweb": [
......
......@@ -123,3 +123,69 @@ class ScopHrTimesheetSheet(models.Model):
return self.env.ref(
"cgscop_timesheet.cgscop_timesheet_sheet_report"
).report_action(self)
# ------------------------------------------------------
# Retourne les lignes de la Fdt avec les totaux par projet
# ------------------------------------------------------
def _to_duration(self, infloat):
return "{:02.0f}:{:02.0f}".format(*divmod(infloat * 60, 60))
def _get_timesheet_line_act(self):
for sheet in self:
lines = sheet.timesheet_line_ids.sorted(
key=lambda b: (b.project_id.name, b.date)
)
rows = []
last_project = False
tot_project = 0
for line in lines:
# On insère un total intermédiaire
if last_project != line.project_id.name and tot_project != 0:
rows.append(
{
"total": 1,
"name": False,
"partner": False,
"project": False,
"date": False,
"ur_financial_system": "Total "
+ last_project
+ " : "
+ self._to_duration(tot_project),
"unit_amount": False,
}
)
tot_project = 0
# On insère la ligne lue
rows.append(
{
"total": 0,
"name": line.name,
"partner": line.partner_id.name,
"project": line.project_id.name,
"date": line.date,
"ur_financial_system": line.ur_financial_system_id.name,
"unit_amount": self._to_duration(line.unit_amount),
}
)
last_project = line.project_id.name
tot_project = tot_project + line.unit_amount
# On insère le dernier total
rows.append(
{
"total": 1,
"name": False,
"partner": False,
"project": False,
"date": False,
"ur_financial_system": "Total "
+ last_project
+ " : "
+ self._to_duration(tot_project),
"unit_amount": False,
}
)
return rows
......@@ -63,8 +63,30 @@ class ScopHrTimesheet(models.Model):
string="Nb conventions régionales", compute="_compute_ur_system_nb"
)
is_present = fields.Boolean("Présentiel")
location = fields.Selection(
[
("R", "Rendez-vous"),
("D", "Déplacement"),
("B", "Bureau"),
],
string="Lieu",
)
justificatifs = fields.Char(string="Justificatifs", required=False)
is_overtime = fields.Boolean(
string="Heures supplémentaires",
default=False,
)
is_overtime_allowed = fields.Boolean(
string="Heures supplémentaires autorisées",
compute="_compute_overtime_allowed",
)
travel_time = fields.Float(
string="Temps déplacement",
)
is_travel_time_allowed = fields.Boolean(
string="Temps de déplacement autorisé",
compute="_compute_travel_time_allowed",
)
calendar_l1 = fields.Char(
string="Ligne 1 calendrier",
compute="_compute_calendar_l1",
......@@ -77,6 +99,16 @@ class ScopHrTimesheet(models.Model):
# ------------------------------------------------------
# Compute Functions
# ------------------------------------------------------
@api.depends("ur_id")
def _compute_overtime_allowed(self):
for rec in self:
rec.is_overtime_allowed = self.env.company.overtime_working
@api.depends("ur_id")
def _compute_travel_time_allowed(self):
for rec in self:
rec.is_travel_time_allowed = self.env.company.use_travel_time
@api.depends("ur_id")
def _compute_ur_system_nb(self):
for timesheet in self:
......@@ -182,6 +214,10 @@ class ScopHrTimesheet(models.Model):
@api.constrains("date")
def _check_weekday(self):
if self.env.company.weekend_working:
return
for line in self:
dt = datetime.combine(line.date, time(12, 00))
holiday = self.env["resource.calendar.leaves"].search(
......@@ -191,9 +227,10 @@ class ScopHrTimesheet(models.Model):
("company_id", "=", self.env.company.id),
("date_from", "<=", dt),
("date_to", ">=", dt),
("resource_id", "=", False),
]
)
if line.date.weekday() in (5, 6) or holiday:
if not line.holiday_id and (line.date.weekday() in (5, 6) or holiday):
raise ValidationError(
_(
"Vous ne pouvez imputer du temps sur un weekend "
......@@ -244,3 +281,30 @@ class ScopHrTimesheet(models.Model):
"default_name": self[0].name if len(self) == 1 else "",
},
}
# ------------------------------------------------------
# Modification du context pour cacher les colonnes
# ------------------------------------------------------
@api.model
def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):
custom_context = self.env.context.copy()
current_ur_id = self.env.context['current_ur_id']
nbfs = self.env["ur.financial.system"].search([("ur_id", "=", current_ur_id)])
if len(nbfs) == 0:
custom_context['hide_financial_system'] = True
nbrc = self.env["ur.regional.convention"].search([("ur_id", "=", current_ur_id)])
if len(nbrc) == 0:
custom_context['hide_regional_convention'] = True
overtime_allowed = self.env.company.overtime_working
if not overtime_allowed:
custom_context['hide_overtime'] = True
travel_time_allowed = self.env.company.use_travel_time
if not travel_time_allowed:
custom_context['hide_travel_time'] = True
res = super(ScopHrTimesheet, self.with_context(custom_context)).fields_view_get(
view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu)
return res
......@@ -21,6 +21,9 @@ class ScopProjectTimesheet(models.Model):
ondelete="restrict",
default=_default_ur,
)
creation_invoiced = fields.Boolean(
string="Facturé au titre de la création",
)
@api.onchange("name")
def onchange_name(self):
......
......@@ -18,3 +18,18 @@ class ResCompanyTmesheet(models.Model):
help="Si cette option est cochée, un employé peut imputer sans limite"
" de temps sur une journée",
)
overtime_working = fields.Boolean(
string="Heures supplémentaires",
default=False,
help="Si cette option est cochée, un employé peut déclarer des heures supplémentaire"
)
weekend_working = fields.Boolean(
string="Travail le weekend",
default=False,
help="Si cette option est cochée, un employé peut imputer le weekend",
)
use_travel_time = fields.Boolean(
string="Saisie des temps de déplacement",
default=False,
help="Si cette option est cochée, un employé peut saisir ses temps de déplacement"
)
......@@ -140,6 +140,5 @@
<field name="report_file">cgscop_timesheet.report_timesheet_sheet</field>
<field name="paperformat_id" ref="cgscop_paperformat_a4_landscape" />
</record>
</data>
</odoo>
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<data>
<template id="report_timesheet_document_act">
<t t-call="web.external_layout">
<div class="page">
<h2>
Feuille de Temps par activité <t
t-if="o.state == 'draft'"
> - Brouillon</t>
</h2>
<h3>
<t t-esc="o.name" />
</h3>
<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.employee_id.name" />
</div>
<div class="col-auto mw-100 mb-2">
<strong>Soumis le</strong>
<p class="m-0" t-field="o.submit_date" />
</div>
<div class="col-auto mw-100 mb-2" name="date_end">
<strong>Validé le</strong>
<p class="m-0" t-field="o.validation_date" />
</div>
<div class="col-auto mw-100 mb-2" name="date_end">
<strong>Total</strong>
<p
class="m-0"
t-field="o.total_hour"
t-options="{'widget': 'duration', 'digital': True, 'unit': 'hour', 'round': 'minute'}"
/>
</div>
</div>
<table
class="table table-sm o_main_table"
name="invoice_line_table"
>
<thead>
<tr>
<th class="text-left"><span>Code activité UR</span></th>
<th class="text-left"><span>Date</span></th>
<th class="text-left"><span>Contact</span></th>
<th class="text-left"><span>Description</span></th>
<th class="text-left"><span
>Dispositif Financier</span></th>
<th class="text-left"><span>Durée</span></th>
</tr>
</thead>
<tbody class="invoice_tbody">
<t t-foreach="o._get_timesheet_line_act()" t-as="line">
<tr>
<td><span><t t-esc="line['project']" /></span></td>
<td><span><t t-esc="line['date']" /></span></td>
<td><span><t t-esc="line['partner']" /></span></td>
<td><span><t t-esc="line['name']" /></span></td>
<td><span>
<t t-if="line['total']==1">
<strong>
<t t-esc="line['ur_financial_system']" />
</strong>
</t>
<t t-if="line['total']==0">
<t t-esc="line['ur_financial_system']" />
</t>
</span></td>
<td class="text-right"><span>
<t t-esc="line['unit_amount']" />
</span></td>
</tr>
</t>
<tr>
<td />
<td />
<td />
<td />
<td class="text-right"><strong>Total</strong></td>
<td class="text-right"><strong
t-esc="o.total_hour"
t-options="{'widget': 'duration', 'digital': True, 'unit': 'hour', 'round': 'minute'}"
/></td>
</tr>
</tbody>
</table>
<div
t-if="o.state == 'draft'"
>Cette feuille de temps a été éditée en brouillon.</div>
<div t-else="">
<table style="float: right;">
<tr>
<td
style="width: 300px; border-bottom: 1px solid #495057; text-align: center;"
>
Visa salarié
</td>
<td
style="width: 300px; border-bottom: 1px solid #495057; text-align: center;"
>
Visa direction
</td>
</tr>
<tr>
<td><br /><br /><br /></td>
<td><br /><br /><br /></td>
</tr>
</table>
</div>
</div>
</t>
</template>
<template id="report_timesheet_sheet_act">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="cgscop_timesheet.report_timesheet_document_act" />
</t>
</t>
</template>
<record id="cgscop_timesheet_sheet_report_act" model="ir.actions.report">
<field name="name">CG Scop - Feuille de Temps par activité</field>
<field name="model">cgscop.timesheet.sheet</field>
<field name="report_type">qweb-pdf</field>
<field
name="report_name"
>cgscop_timesheet.report_timesheet_sheet_act</field>
<field
name="report_file"
>cgscop_timesheet.report_timesheet_sheet_act</field>
<field name="paperformat_id" ref="cgscop_paperformat_a4_landscape" />
</record>
</data>
</odoo>
......@@ -15,3 +15,4 @@ access_ur_regional_convention_cg_manager,access_ur_regional_convention_cg,model_
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
access_cgscop_timesheet_print_wizard,access_cgscop_timesheet_print_wizard,model_cgscop_timesheet_print_wizard,base.group_user,1,1,1,1
......@@ -3,7 +3,7 @@
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<data>
<!-- UR Financial System -->
<record id="ur_financial_system_rule_ur" model="ir.rule">
<field name="name">ur financial system rule per ur</field>
<field name="model_id" ref="model_ur_financial_system" />
......@@ -11,7 +11,7 @@
<field name="groups" eval="[(6, 0, [ref('base.group_user')])]" />
<field eval="True" name="global" />
</record>
<!-- UR Regional Convention -->
<record id="ur_regional_convention_rule_ur" model="ir.rule">
<field name="name">ur regional convention rule per ur</field>
<field name="model_id" ref="model_ur_regional_convention" />
......@@ -19,7 +19,7 @@
<field name="groups" eval="[(6, 0, [ref('base.group_user')])]" />
<field eval="True" name="global" />
</record>
<!-- UR Month Timesheet -->
<record id="ur_month_timesheet_rule_ur" model="ir.rule">
<field name="name">ur month timesheet rule per ur</field>
<field name="model_id" ref="model_ur_month_timesheet" />
......@@ -28,6 +28,7 @@
<field eval="True" name="global" />
</record>
<!-- Project -->
<record id="project_rule_ur" model="ir.rule">
<field name="name">project rule per ur</field>
<field name="model_id" ref="project.model_project_project" />
......@@ -35,7 +36,6 @@
<field name="groups" eval="[(6, 0, [ref('base.group_user')])]" />
<field eval="True" name="global" />
</record>
<record id="project_rule_administrator_ur" model="ir.rule">
<field name="name">project rule for administrator</field>
<field name="model_id" ref="project.model_project_project" />
......@@ -47,32 +47,20 @@
<field eval="True" name="global" />
</record>
<!-- Analytic Line -->
<record id="analytic_line_ur_rule" model="ir.rule">
<field name="name">Analytic line UR rule</field>
<field name="model_id" ref="analytic.model_account_analytic_line" />
<field name="groups" eval="[(6, 0, [ref('base.group_user')])]" />
<field eval="True" name="global" />
<field name="domain_force">[('company_id','in',company_ids)]</field>
<field name="domain_force">[('ur_id','=',user.current_ur_id.id)]</field>
</record>
<record id="analytic_rule_administrator_ur" model="ir.rule">
<field name="name">Analytic line UR administrator rule</field>
<field name="model_id" ref="analytic.model_account_analytic_line" />
<field name="domain_force">[(1,'=',1)]</field>
<field
name="groups"
eval="[(6, 0, [ref('cgscop_partner.group_cg_administrator')])]"
/>
<field eval="True" name="global" />
</record>
<record id="analytic.analytic_line_comp_rule" model="ir.rule">
<field name="name">Analytic line multi company rule</field>
<field name="model_id" ref="model_account_analytic_line" />
<field eval="True" name="global" />
<field name="active" eval="False" />
</record>
<record id="account.account_analytic_line_rule_billing_user" model="ir.rule">
<field name="name">analytic.analytic.line.billing.user</field>
<field name="model_id" ref="model_account_analytic_line" />
......@@ -83,29 +71,16 @@
<field name="active" eval="False" />
</record>
<!-- CGScop Timesheet Sheet -->
<record id="timesheet_sheet_rule_ur" model="ir.rule">
<field name="name">Feuilles de temps de mon UR</field>
<field
name="model_id"
ref="cgscop_timesheet.model_cgscop_timesheet_sheet"
/>
<field name="domain_force">[('company_id','in',company_ids)]</field>
<field name="domain_force">[('ur_id','=',user.current_ur_id.id)]</field>
<field name="groups" eval="[(6, 0, [ref('base.group_user')])]" />
<field eval="True" name="global" />
</record>
<record id="timesheet_sheet_rule_administrator_ur" model="ir.rule">
<field name="name">Feuilles de temps administrator</field>
<field
name="model_id"
ref="cgscop_timesheet.model_cgscop_timesheet_sheet"
/>
<field name="domain_force">[(1,'=',1)]</field>
<field
name="groups"
eval="[(6, 0, [ref('cgscop_partner.group_cg_administrator')])]"
/>
<field eval="True" name="global" />
</record>
</data>
</odoo>
......@@ -46,9 +46,10 @@
class="oe_highlight"
/>
<button
name="print_timesheet"
string="Imprimer"
type="object"
type="action"
name="%(cgscop_timesheet_print_act)d"
class="oe_read_only"
/>
<button
name="reset_timesheet_sheets"
......
......@@ -105,9 +105,25 @@
/>
<field name="name" />
<field name="unit_amount" widget="float_time" />
<field name="is_overtime_allowed" invisible="1" />
<field name="is_travel_time_allowed" invisible="1" />
<field
name="travel_time"
widget="float_time"
attrs="{'invisible': [('is_travel_time_allowed', '=', False)]}"
/>
<field
name="is_overtime"
widget="boolean_toggle"
attrs="{'invisible': [('is_overtime_allowed', '=', False)]}"
/>
</group>
<group string="Divers">
<field name="is_present" widget="boolean_toggle" />
<field
name="location"
attrs="{'invisible': [('ur_id', '!=', %(cgscop_partner.riga_14233)d)]}"
/>
</group>
<group
name="DF"
......@@ -175,9 +191,26 @@
/>
<field name="name" />
<field name="unit_amount" widget="float_time" />
<field name="is_overtime_allowed" invisible="1" />
<field name="is_travel_time_allowed" invisible="1" />
<field
name="travel_time"
widget="float_time"
attrs="{'invisible': [('is_travel_time_allowed', '=', False)]}"
/>
<field
name="is_overtime"
widget="boolean_toggle"
attrs="{'invisible': [('is_overtime_allowed', '=', False)]}"
/>
</group>
<group string="Divers">
<field name="is_present" widget="boolean_toggle" />
<field
name="location"
attrs="{'invisible': [('ur_id', '!=', %(cgscop_partner.riga_14233)d)]}"
/>
</group>
<group
name="DF"
......@@ -244,6 +277,10 @@
attrs="{'readonly': [('state', 'in', ('submit', 'valid'))]}"
/>
<field name="is_present" widget="boolean_toggle" />
<field
name="location"
attrs="{'invisible': [('ur_id', '!=', %(cgscop_partner.riga_14233)d)]}"
/>
</field>
<field name="task_id" position="attributes">
<attribute name="invisible">True</attribute>
......@@ -255,17 +292,29 @@
>{'readonly': [('state', 'in', ('submit', 'valid'))]}</attribute>
</field>
<field name="unit_amount" position="after">
<field
name="travel_time"
widget="float_time"
invisible="context.get('hide_travel_time')"
/>
<field
name="is_overtime"
widget="boolean_toggle"
invisible="context.get('hide_overtime')"
/>
<field name="ur_regional_convention_nb" invisible="1" />
<field name="ur_financial_system_nb" invisible="1" />
<field
name="ur_financial_system_id"
options="{'no_open': True, 'no_create': True}"
attrs="{'required': [('ur_financial_system_nb', '>', 0)], 'invisible': [('ur_financial_system_nb', '&lt;', 1)], 'readonly': [('state', 'in', ('submit', 'valid'))]}"
invisible="context.get('hide_financial_system')"
attrs="{'required': [('ur_financial_system_nb', '>', 0)], 'readonly': [('state', 'in', ('submit', 'valid'))]}"
/>
<field
name="ur_regional_convention_id"
options="{'no_open': True, 'no_create': True}"
attrs="{'required':[('ur_regional_convention_nb', '>', 0)], 'invisible':[('ur_regional_convention_nb', '&lt;', 1)], 'readonly': [('state', 'in', ('submit', 'valid'))]}"
invisible="context.get('hide_regional_convention')"
attrs="{'required':[('ur_regional_convention_nb', '>', 0)], 'readonly': [('state', 'in', ('submit', 'valid'))]}"
/>
<field
name="justificatifs"
......@@ -384,11 +433,6 @@ if records:
Menus
-->
<!-- affichage du menu employé uniquement pour le groupe Fonctionnaire -->
<record model="ir.ui.menu" id="hr.menu_hr_root">
<field name="groups_id" eval="[(6,0,[ref('hr.group_hr_user')])]" />
</record>
<!-- ajoute des droits sur le menu Configuration -->
<record model="ir.ui.menu" id="hr_timesheet.hr_timesheet_menu_configuration">
<field
......
......@@ -68,6 +68,7 @@
placeholder="Code activité National"
options="{'no_open': True, 'no_create': True}"
/>
<field name="creation_invoiced" widget="boolean_toggle" />
<field name="analytic_account_id" invisible="1" />
<field name="privacy_visibility" invisible="1" />
<field name="allow_timesheets" invisible="1" />
......
......@@ -17,6 +17,9 @@
name="day_duration"
attrs="{'invisible': [('day_working', '=', True)]}"
/>
<field name="overtime_working" widget="boolean_toggle" />
<field name="weekend_working" widget="boolean_toggle" />
<field name="use_travel_time" widget="boolean_toggle" />
</group>
</group>
</page>
......
# © 2020 Le Filament (<https://www.le-filament.com>)
# © 2020 Confédération Générale des Scop (<https://www.les-scop.coop>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import cgscop_timesheet_print_wizard
# © 2020 Le Filament (<https://www.le-filament.com>)
# © 2020 Confédération Générale des Scop (<https://www.les-scop.coop>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models
class CgscopTimesheetPrintWizard(models.TransientModel):
_name = "cgscop_timesheet.print.wizard"
_description = "Wizard de sélection de l'impression"
@api.model
def _default_timesheet_id(self):
return self.env.context.get("active_id")
timesheet_id = fields.Many2one(
comodel_name="cgscop.timesheet.sheet",
string="Fdt",
default=_default_timesheet_id,
)
print_type = fields.Selection(
string="Type de sortie",
selection=[("0", "Tri par date"), ("1", "Tri par code activité")],
required=True,
default="0",
)
# ------------------------------------------------------
# Validation du wizard
# ------------------------------------------------------
def valid_wizard(self):
report_name = "cgscop_timesheet.cgscop_timesheet_sheet_report"
if self.print_type == "0":
report_name = "cgscop_timesheet.cgscop_timesheet_sheet_report"
elif self.print_type == "1":
report_name = "cgscop_timesheet.cgscop_timesheet_sheet_report_act"
return self.env.ref(report_name).report_action(self.timesheet_id)
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<!-- WIZARD FORM -->
<record model="ir.ui.view" id="cgscop_timesheet_print_wizard">
<field name="name">cgscop_timesheet_print_wizard</field>
<field name="model">cgscop_timesheet.print.wizard</field>
<field name="arch" type="xml">
<form string="Sélection du format de sortie">
<group>
<field name="print_type" widget="radio" />
</group>
<footer>
<button
class="btn btn-sm btn-primary"
name="valid_wizard"
string="Impression"
type="object"
/>
<button
class="btn btn-sm btn-default"
special="cancel"
string="Retour"
/>
</footer>
</form>
</field>
</record>
<record model="ir.actions.act_window" id="cgscop_timesheet_print_act">
<field name="name">Sélection du format de sortie</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">cgscop_timesheet.print.wizard</field>
<field name="view_mode">form</field>
<field name="view_id" ref="cgscop_timesheet_print_wizard" />
<field name="target">new</field>
</record>
</odoo>