diff --git a/mis_builder_cash_flow/README.rst b/mis_builder_cash_flow/README.rst
index 074e80f4..747dbed5 100644
--- a/mis_builder_cash_flow/README.rst
+++ b/mis_builder_cash_flow/README.rst
@@ -43,6 +43,10 @@ To use this module, you need to:
#. Go to Accounting > Reports > MIS Reporting > MIS Reports and choose "Cash Flow" report
#. You can add forecast lines on Accounting > Reports > MIS Reporting > Cash Flow Forecast Line
+#. If you select on "Target Moves" the value "All Posted Entries", you will get only
+ lines for already posted invoices/entries + the forecast lines.
+#. Selecting "All Entries", draft invoices/entries are also included.
+#. In any case, cancelled invoices/entries are not included.
Known issues / Roadmap
======================
@@ -75,6 +79,9 @@ Contributors
* Juan José Scarafía
* Gonzalo Ruzafa
* Alberto Martín
+* `Tecnativa `_:
+
+ * Pedro M. Baeza
Maintainers
~~~~~~~~~~~
diff --git a/mis_builder_cash_flow/__manifest__.py b/mis_builder_cash_flow/__manifest__.py
index 61fcfb0c..b5553c04 100644
--- a/mis_builder_cash_flow/__manifest__.py
+++ b/mis_builder_cash_flow/__manifest__.py
@@ -1,4 +1,5 @@
# Copyright 2019 ADHOC SA
+# Copyright 2021 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
diff --git a/mis_builder_cash_flow/models/__init__.py b/mis_builder_cash_flow/models/__init__.py
index 63bc6fd4..018fab7c 100644
--- a/mis_builder_cash_flow/models/__init__.py
+++ b/mis_builder_cash_flow/models/__init__.py
@@ -1,4 +1,4 @@
-# Copyright 2019 ADHOC SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-from . import mis_cash_flow_forecast_line
from . import account_account
+from . import mis_cash_flow_forecast_line
+from . import mis_report_instance
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/models/mis_report_instance.py b/mis_builder_cash_flow/models/mis_report_instance.py
new file mode 100644
index 00000000..2a5e0659
--- /dev/null
+++ b/mis_builder_cash_flow/models/mis_report_instance.py
@@ -0,0 +1,17 @@
+# Copyright 2021 Tecnativa - Pedro M. Baeza
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+from odoo import models
+
+
+class MisReportInstancePeriod(models.Model):
+ _inherit = "mis.report.instance.period"
+
+ def _get_additional_move_line_filter(self):
+ """Add the posted condition ."""
+ domain = super()._get_additional_move_line_filter()
+ if (
+ self._get_aml_model_name() == "mis.cash_flow"
+ and self.report_instance_id.target_move == "posted"
+ ):
+ domain += [("state", "=", "posted")]
+ return domain
diff --git a/mis_builder_cash_flow/readme/CONTRIBUTORS.rst b/mis_builder_cash_flow/readme/CONTRIBUTORS.rst
index bf76fd12..6c0f8064 100644
--- a/mis_builder_cash_flow/readme/CONTRIBUTORS.rst
+++ b/mis_builder_cash_flow/readme/CONTRIBUTORS.rst
@@ -1,3 +1,6 @@
* Juan José Scarafía
* Gonzalo Ruzafa
* Alberto Martín
+* `Tecnativa `_:
+
+ * Pedro M. Baeza
diff --git a/mis_builder_cash_flow/readme/USAGE.rst b/mis_builder_cash_flow/readme/USAGE.rst
index 44f6253a..4de3545e 100644
--- a/mis_builder_cash_flow/readme/USAGE.rst
+++ b/mis_builder_cash_flow/readme/USAGE.rst
@@ -2,3 +2,7 @@ To use this module, you need to:
#. Go to Accounting > Reports > MIS Reporting > MIS Reports and choose "Cash Flow" report
#. You can add forecast lines on Accounting > Reports > MIS Reporting > Cash Flow Forecast Line
+#. If you select on "Target Moves" the value "All Posted Entries", you will get only
+ lines for already posted invoices/entries + the forecast lines.
+#. Selecting "All Entries", draft invoices/entries are also included.
+#. In any case, cancelled invoices/entries are not included.
diff --git a/mis_builder_cash_flow/report/mis_cash_flow.py b/mis_builder_cash_flow/report/mis_cash_flow.py
index 025e3aca..0c367b54 100644
--- a/mis_builder_cash_flow/report/mis_cash_flow.py
+++ b/mis_builder_cash_flow/report/mis_cash_flow.py
@@ -50,6 +50,12 @@ class MisCashFlow(models.Model):
account_internal_type = fields.Selection(
related="account_id.user_type_id.type", readonly=True
)
+ state = fields.Selection(selection="_selection_parent_state",)
+
+ def _selection_parent_state(self):
+ return self.env["account.move"].fields_get(allfields=["state"])["state"][
+ "selection"
+ ]
def init(self):
query = """
@@ -57,7 +63,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
@@ -75,12 +81,14 @@ class MisCashFlow(models.Model):
aml.partner_id as partner_id,
aml.company_id as company_id,
aml.name as name,
+ aml.parent_state as state,
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
@@ -98,6 +106,7 @@ class MisCashFlow(models.Model):
fl.partner_id as partner_id,
fl.company_id as company_id,
fl.name as name,
+ 'posted' as state,
fl.date as date
FROM mis_cash_flow_forecast_line as fl
"""
diff --git a/mis_builder_cash_flow/static/description/index.html b/mis_builder_cash_flow/static/description/index.html
index a1a00537..02cd4a67 100644
--- a/mis_builder_cash_flow/static/description/index.html
+++ b/mis_builder_cash_flow/static/description/index.html
@@ -394,6 +394,10 @@ The forecast is based on two types of date:
- Go to Accounting > Reports > MIS Reporting > MIS Reports and choose “Cash Flow” report
- You can add forecast lines on Accounting > Reports > MIS Reporting > Cash Flow Forecast Line
+- If you select on “Target Moves” the value “All Posted Entries”, you will get only
+lines for already posted invoices/entries + the forecast lines.
+- Selecting “All Entries”, draft invoices/entries are also included.
+- In any case, cancelled invoices/entries are not included.