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

[UPD] employee query

parent 72ac948f
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -444,17 +444,45 @@ class LeFilamentTdb(models.Model): ...@@ -444,17 +444,45 @@ class LeFilamentTdb(models.Model):
return result return result
def _employee_time(self, date_start=None, date_end=None): def _employee_time(self, date_start=None, date_end=None):
clause = "" clause = "where 1=1 "
if date_start: if date_start:
clause += f"and aal.date >= '{date_start}'" clause += f"and line_date >= '{date_start}' "
if date_end: if date_end:
clause += f"and aal.date <= '{date_end}'" clause += f"and line_date <= '{date_end}' "
query = """ query = """
select select
e.name as "Personne", employee as "Employé",
sum(case when aal.partner_id != 1 or aal.partner_id is null and aal.holiday_id is null then unit_amount else 0 end) as "Prod", sum(production) as "Prod",
sum(case when aal.partner_id = 1 and aal.holiday_id is null then unit_amount else 0 end) as "Interne" sum(internal) as "Interne",
sum(revenue) as "CA"
from
(
select
p.name as employee,
0 as production,
0 as internal,
aal.amount as revenue,
aal.date as line_date
from
account_analytic_line aal
left join
account_analytic_account aa on aal.account_id = aa.id
left join
account_analytic_plan aap on aa.plan_id = aap.id
left join
res_partner p on aa.partner_id = p.id
where
aap.id = 3
union
select
e.name as employee,
case when aal.partner_id != 1 or aal.partner_id is null and aal.holiday_id is null then unit_amount else 0 end as production,
case when aal.partner_id = 1 and aal.holiday_id is null then unit_amount else 0 end as internal,
0 as revenue,
aal.date as line_date
from from
account_analytic_line aal account_analytic_line aal
left join left join
...@@ -466,11 +494,10 @@ class LeFilamentTdb(models.Model): ...@@ -466,11 +494,10 @@ class LeFilamentTdb(models.Model):
where where
aal.project_id is not null aal.project_id is not null
and (lt.active is true or lt.active is null) and (lt.active is true or lt.active is null)
) query
%s %s
group by group by employee
e.name order by sum(production) desc
order by
sum(case when aal.partner_id != 1 or aal.partner_id is null and aal.holiday_id is null then unit_amount else 0 end) desc
""" """
self.env.cr.execute(query, (AsIs(clause),)) self.env.cr.execute(query, (AsIs(clause),))
......
...@@ -72,6 +72,7 @@ ...@@ -72,6 +72,7 @@
<t t-value="records.dashboard_detail_values()" t-set="init_data" /> <t t-value="records.dashboard_detail_values()" t-set="init_data" />
<t t-value="init_data.get('customer')" t-set="customer" /> <t t-value="init_data.get('customer')" t-set="customer" />
<t t-value="init_data.get('employee_time')" t-set="employee_time" /> <t t-value="init_data.get('employee_time')" t-set="employee_time" />
<t t-value="init_data.get('employee_revenue')" t-set="employee_revenue" />
<t t-call="lefilament_tdb.dashboard_detail_values" /> <t t-call="lefilament_tdb.dashboard_detail_values" />
</div> </div>
</qweb> </qweb>
...@@ -103,6 +104,11 @@ ...@@ -103,6 +104,11 @@
<t t-call="lefilament_tdb.dashboard_detail_table"> <t t-call="lefilament_tdb.dashboard_detail_table">
<t t-set="data" t-value="employee_time" /> <t t-set="data" t-value="employee_time" />
</t> </t>
<h3 class="text-uppercase py-2 mb-0 mt-5">CA par employé</h3>
<hr class="mt-0" />
<t t-call="lefilament_tdb.dashboard_detail_table">
<t t-set="data" t-value="employee_revenue" />
</t>
</div> </div>
</div> </div>
</div> </div>
......
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