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):
return result
def _employee_time(self, date_start=None, date_end=None):
clause = ""
clause = "where 1=1 "
if date_start:
clause += f"and aal.date >= '{date_start}'"
clause += f"and line_date >= '{date_start}' "
if date_end:
clause += f"and aal.date <= '{date_end}'"
clause += f"and line_date <= '{date_end}' "
query = """
select
e.name as "Personne",
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(case when aal.partner_id = 1 and aal.holiday_id is null then unit_amount else 0 end) as "Interne"
employee as "Employé",
sum(production) as "Prod",
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
account_analytic_line aal
left join
......@@ -466,11 +494,10 @@ class LeFilamentTdb(models.Model):
where
aal.project_id is not null
and (lt.active is true or lt.active is null)
) query
%s
group by
e.name
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
group by employee
order by sum(production) desc
"""
self.env.cr.execute(query, (AsIs(clause),))
......
......@@ -72,6 +72,7 @@
<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('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" />
</div>
</qweb>
......@@ -103,6 +104,11 @@
<t t-call="lefilament_tdb.dashboard_detail_table">
<t t-set="data" t-value="employee_time" />
</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>
......
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