Skip to content
Extraits de code Groupes Projets
Valider fe77ca84 rédigé par Juliana's avatar Juliana
Parcourir les fichiers

Merge filtre

Merge branch '12.0' of https://bitbucket.org/lefilament/cgscop_timesheet into 12.
0
parents fca87058 ef80dbc4
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import models
from . import wizard
......@@ -15,12 +15,15 @@
],
"data": [
"security/ir.model.access.csv",
"security/security_rules.xml",
"views/assets.xml",
"views/cgscop_timesheet_code.xml",
"views/hr_timesheet.xml",
"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",
]
}
......@@ -6,12 +6,7 @@ from odoo import models, fields
class ScopTimesheetCode(models.Model):
_name = "cgscop.timesheet.code"
_description = "Code activite cgscop"
_description = "Code activité National"
_order = 'name'
name = fields.Char('Nom')
company_id = fields.Many2one(
comodel_name='res.company',
string='Company',
required=True,
default=lambda self: self.env.user.company_id)
......@@ -22,4 +22,3 @@ class ScopHrTimesheet(models.Model):
@api.onchange('project_id')
def onchange_project_id(self):
self.partner_id = self.project_id.partner_id
......@@ -7,10 +7,16 @@ from odoo import models, fields
class ScopProjectTimesheet(models.Model):
_inherit = "project.project"
def _default_ur(self):
return self.env['res.company']._ur_default_get()
cgscop_timesheet_code_id = fields.Many2one(
comodel_name='cgscop.timesheet.code',
string='Code Activité CG')
string='Code Activité National')
privacy_visibility = fields.Selection(default="employees")
ur_id = fields.Many2one(
'union.regionale',
string='Union Régionale',
index=True,
on_delete='restrict',
default=_default_ur)
......@@ -8,8 +8,17 @@ class ScopTimesheetCode(models.Model):
_name = "ur.financial.system"
_description = "Dispositif financier UR"
def _default_ur(self):
return self.env['res.company']._ur_default_get()
name = fields.Char('Nom')
company_id = fields.Many2one(
comodel_name='res.company',
string='UR',
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)
<?xml version="1.0"?>
<!-- Copyright 2019 Le Filament
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<data noupdate="1">
<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"/>
<field name="domain_force">[('ur_id','=',user.company_id.ur_id.id)]</field>
<field name="groups" eval="[(6, 0, [ref('base.group_user')])]"/>
<field eval="True" name="global"/>
</record>
<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"/>
<field name="domain_force">[('ur_id','=',user.company_id.ur_id.id)]</field>
<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"/>
<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>
......@@ -10,23 +10,22 @@
<field name="arch" type="xml">
<tree editable='top'>
<field name="name" />
<field name="company_id" groups="base.group_no_one" />
</tree>
</field>
</record>
<record id="action_cgscop_timesheet_code_tree" model="ir.actions.act_window">
<field name="name">Codes activité CG</field>
<field name="name">Codes Activité National</field>
<field name="res_model">cgscop.timesheet.code</field>
<field name="view_mode">tree</field>
<field name="help">Affiche et gère les Codes activité CG</field>
<field name="help">Affiche et gère les Codes activité Nationaux</field>
</record>
<menuitem id="menu_cgscop_timesheet_code"
name="Codes activité National"
name="Codes Activité National"
parent="hr_timesheet.hr_timesheet_menu_configuration"
action="action_cgscop_timesheet_code_tree"
sequence="50"
sequence="40"
groups="cgscop_partner.group_cg_administrator"/>
</data>
......
......@@ -27,11 +27,11 @@
<field name="arch" type="xml">
<field name="name" position="replace"/>
<field name="project_id" position="attributes" >
<attribute name="options">{'no_create_edit': True}</attribute>
<attribute name="options">{'no_open': True, 'no_create': True}</attribute>
<attribute name="string">Code activité UR</attribute>
</field>
<field name="project_id" position="after" >
<field name="partner_id" domain="[('is_company', '=', True)]" required="True" class="td-ellipsis" />
<field name="partner_id" domain="[('is_company', '=', True)]" required="True" class="td-ellipsis" options="{'no_open': True, 'no_create': True}" string="Contact"/>
<field name="name" class="td-minwidth" />
</field>
<field name="task_id" position="attributes">
......@@ -39,7 +39,7 @@
</field>
<field name="unit_amount" widget="timesheet_uom" sum="Total"/>
<field name="unit_amount" position="after">
<field name="ur_financial_system_id" options="{'no_create_edit': True}"/>
<field name="ur_financial_system_id" options="{'no_open': True, 'no_create': True}"/>
</field>
</field>
</record>
......
......@@ -28,11 +28,12 @@
</div>
<group>
<group>
<field name="partner_id" string="Contact par défaut" help="Contact par défaut auquel est rattaché cette activité. Ce contact sera sélectionné automatiquement dans les feuilles de temps"/>
<field name="company_id" groups="base.group_multi_company" string="UR" />
<field name="partner_id" string="Contact par défaut" help="Contact par défaut auquel est rattaché cette activité. Ce contact sera sélectionné automatiquement dans les feuilles de temps" options="{'no_open': True, 'no_create': True}"/>
<field name="ur_id" string="Union Régionale" options="{'no_open': True, 'no_create': True}" required="1" />
<field name="company_id" groups="base.group_multi_company" options="{'no_open': True, 'no_create': True}" string="Société" invisible="1" />
</group>
<group>
<field name="cgscop_timesheet_code_id" required="1" placeholder="Code activité CG"/>
<field name="cgscop_timesheet_code_id" required="1" placeholder="Code activité National" options="{'no_open': True, 'no_create': True}"/>
<field name="privacy_visibility" invisible="1"/>
<field name="allow_timesheets" invisible="1"/>
</group>
......@@ -41,9 +42,8 @@
<group string="Configuration" name="project_config" groups="base.group_no_one">
<group>
<field name="user_id" string="Project Manager"
attrs="{'readonly':[('active','=',False)]}"/>
attrs="{'readonly':[('active','=',False)]}" options="{'no_open': True, 'no_create': True}"/>
<field name="sequence" groups="base.group_no_one"/>
<field name="company_id" groups="base.group_multi_company"/>
</group>
<group >
<field name="allow_timesheets" />
......@@ -67,7 +67,7 @@
<field name="arch" type="xml">
<search string="Search Project">
<field name="name" string="Code activité UR"/>
<field name="cgscop_timesheet_code_id" string="Code activité CG"/>
<field name="cgscop_timesheet_code_id" string="Code activité National"/>
<field name="partner_id" string="Contact par défaut"/>
<filter string="Archived" name="inactive" domain="[('active','=',False)]"/>
......@@ -88,8 +88,8 @@
<field name="sequence" widget="handle"/>
<field name="active" invisible="1"/>
<field name="name" />
<field name="cgscop_timesheet_code_id" />
<field name="partner_id" string="Contact"/>
<field name="cgscop_timesheet_code_id" options="{'no_open': True, 'no_create': True}"/>
<field name="partner_id" string="Contact" options="{'no_open': True, 'no_create': True}"/>
</tree>
</field>
</record>
......
......@@ -10,7 +10,8 @@
<field name="arch" type="xml">
<tree editable='top'>
<field name="name" />
<field name="company_id" groups="base.group_no_one" />
<field name="ur_id" options="{'no_open': True, 'no_create': True}"/>
<field name="company_id" groups="base.group_no_one" options="{'no_open': True, 'no_create': True}"/>
</tree>
</field>
</record>
......
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import print_timesheet
# 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)
<?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>
<?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>
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