From c595af1012eeb0c48b9a5ecf76174fa95c889522 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Wed, 7 Jul 2021 17:54:34 +0200 Subject: [PATCH] [FIX] mis_builder_cash_flow: Proper SQL expression + default for v13 - On v13, invoices are journal entries, so we have to explicitly exclude cancelled invoices from the expression. We leave draft ones, as they are good for forecasting. - Default value for the company of the forecast line doesn't follow new specification, putting an incorrect value. - Extra improvement: avoid a non needed casting of the fixed column type. --- mis_builder_cash_flow/models/mis_cash_flow_forecast_line.py | 2 +- mis_builder_cash_flow/report/mis_cash_flow.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/mis_builder_cash_flow/models/mis_cash_flow_forecast_line.py b/mis_builder_cash_flow/models/mis_cash_flow_forecast_line.py index e01cd3f7..95eb568f 100644 --- a/mis_builder_cash_flow/models/mis_cash_flow_forecast_line.py +++ b/mis_builder_cash_flow/models/mis_cash_flow_forecast_line.py @@ -23,7 +23,7 @@ class MisCashFlowForecastLine(models.Model): "res.company", string="Company", required=True, - default=lambda self: self.env.user.company_id.id, + default=lambda self: self.env.company, index=True, ) diff --git a/mis_builder_cash_flow/report/mis_cash_flow.py b/mis_builder_cash_flow/report/mis_cash_flow.py index 025e3aca..348ac5c2 100644 --- a/mis_builder_cash_flow/report/mis_cash_flow.py +++ b/mis_builder_cash_flow/report/mis_cash_flow.py @@ -57,7 +57,7 @@ class MisCashFlow(models.Model): -- we use negative id to avoid duplicates and we don't use -- ROW_NUMBER() because the performance was very poor -aml.id as id, - CAST('move_line' AS varchar) as line_type, + 'move_line' as line_type, aml.id as move_line_id, aml.account_id as account_id, CASE @@ -77,10 +77,11 @@ class MisCashFlow(models.Model): aml.name as name, COALESCE(aml.date_maturity, aml.date) as date FROM account_move_line as aml + WHERE aml.parent_state != 'cancel' UNION ALL SELECT fl.id as id, - CAST('forecast_line' AS varchar) as line_type, + 'forecast_line' as line_type, NULL as move_line_id, fl.account_id as account_id, CASE