[FIX] sale: fix sales team goal not updated in CRM pipelines
Reproduce this issue
- Install CRM & Sales
- Create 2 sales team in CRM settings
- Create some invoices and register payments for the 2 teams
- Go in CRM > Sales > Team pipelines
The invoicing amount is still 0 for both teams.
Cause
- The `_compute_invoiced` method in `CrmTeam` models use a SQL
query to retrieve the invoices lines but it returns an empty
recordset because the dates are not right ordered.
- The line balance are negatives values, doing a SUM() will always
returns 0
This commit re-order the dates and invert the sign of line.balance.
OPW-2119819
closes odoo/odoo#40115
X-original-commit: 578dacc3af04996754d1ec67108106379a9c3c38
Signed-off-by: Jason Van Malder <jasonvanmalder@users.noreply.github.com>
This commit is contained in:
@@ -76,7 +76,7 @@ class CrmTeam(models.Model):
|
||||
query = '''
|
||||
SELECT
|
||||
move.team_id AS team_id,
|
||||
SUM(line.balance) AS amount_untaxed_signed
|
||||
SUM(-line.balance) AS amount_untaxed_signed
|
||||
FROM account_move move
|
||||
LEFT JOIN account_move_line line ON line.move_id = move.id
|
||||
WHERE move.type IN ('out_invoice', 'out_refund', 'in_invoice', 'in_refund')
|
||||
@@ -90,7 +90,7 @@ class CrmTeam(models.Model):
|
||||
GROUP BY move.team_id
|
||||
'''
|
||||
today = fields.Date.today()
|
||||
params = [tuple(self.ids), fields.Date.to_string(today), fields.Date.to_string(today.replace(day=1))]
|
||||
params = [tuple(self.ids), fields.Date.to_string(today.replace(day=1)), fields.Date.to_string(today)]
|
||||
self._cr.execute(query, params)
|
||||
|
||||
data_map = dict((v[0], v[1]) for v in self._cr.fetchall())
|
||||
|
||||
Reference in New Issue
Block a user