[FIX] Account journal dashboard bar graph
Fix _get_bar_graph_select_query to correctly compute the residual amount when calculating the values for the graph of a bill or invoice journal. closes odoo/odoo#41592 X-original-commit: 73d28be404901378dc06e756868e5a1ef6cf7b0b Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
This commit is contained in:
@@ -200,18 +200,17 @@ class account_journal(models.Model):
|
||||
the bar graph's data as its first element, and the arguments dictionary
|
||||
for it as its second.
|
||||
"""
|
||||
sign = '' if self.type == 'sale' else '-'
|
||||
return ('''
|
||||
SELECT
|
||||
SUM((CASE WHEN move.type IN %(purchase_types)s THEN -1 else 1 END) * line.amount_residual) AS total,
|
||||
''' + sign + ''' + SUM(move.amount_residual_signed) AS total,
|
||||
MIN(invoice_date_due) AS aggr_date
|
||||
FROM account_move_line line
|
||||
JOIN account_move move ON move.id = line.move_id
|
||||
FROM account_move move
|
||||
WHERE move.journal_id = %(journal_id)s
|
||||
AND move.state = 'posted'
|
||||
AND move.invoice_payment_state = 'not_paid'
|
||||
AND move.type IN %(invoice_types)s
|
||||
''', {
|
||||
'purchase_types': tuple(self.env['account.move'].get_purchase_types(True)),
|
||||
'invoice_types': tuple(self.env['account.move'].get_invoice_types(True)),
|
||||
'journal_id': self.id
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user